2011-06-29 Yuta Kitamura <yutak@chromium.org>
[WebKit-https.git] / Tools / DumpRenderTree / chromium / WebPreferences.cpp
1 /*
2  * Copyright (C) 2010 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  *     * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following disclaimer
12  * in the documentation and/or other materials provided with the
13  * distribution.
14  *     * Neither the name of Google Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30
31 #include "config.h"
32 #include "WebPreferences.h"
33
34 #include "WebView.h"
35
36 using namespace WebKit;
37
38 void WebPreferences::reset()
39 {
40 #if OS(MAC_OS_X)
41     cursiveFontFamily = WebString::fromUTF8("Apple Chancery");
42     fantasyFontFamily = WebString::fromUTF8("Papyrus");
43     WebString serif = WebString::fromUTF8("Times");
44 #else
45     // These two fonts are picked from the intersection of
46     // Win XP font list and Vista font list :
47     //   http://www.microsoft.com/typography/fonts/winxp.htm
48     //   http://blogs.msdn.com/michkap/archive/2006/04/04/567881.aspx
49     // Some of them are installed only with CJK and complex script
50     // support enabled on Windows XP and are out of consideration here.
51     // (although we enabled both on our buildbots.)
52     // They (especially Impact for fantasy) are not typical cursive
53     // and fantasy fonts, but it should not matter for layout tests
54     // as long as they're available.
55     cursiveFontFamily = WebString::fromUTF8("Comic Sans MS");
56     fantasyFontFamily = WebString::fromUTF8("Impact");
57     // NOTE: case matters here, this must be 'times new roman', else
58     // some layout tests fail.
59     WebString serif = WebString::fromUTF8("times new roman");
60 #endif
61     serifFontFamily = serif;
62     standardFontFamily = serif;
63     fixedFontFamily = WebString::fromUTF8("Courier");
64     sansSerifFontFamily = WebString::fromUTF8("Helvetica");
65
66     defaultFontSize = 16;
67     defaultFixedFontSize = 13;
68     minimumFontSize = 0;
69     minimumLogicalFontSize = 9;
70
71     DOMPasteAllowed = true;
72     XSSAuditorEnabled = false;
73     allowDisplayOfInsecureContent = true;
74     allowFileAccessFromFileURLs = true;
75     allowRunningOfInsecureContent = true;
76     authorAndUserStylesEnabled = true;
77     defaultTextEncodingName = WebString::fromUTF8("ISO-8859-1");
78     developerExtrasEnabled = true;
79     experimentalWebGLEnabled = false;
80     javaEnabled = false;
81     javaScriptCanAccessClipboard = true;
82     javaScriptCanOpenWindowsAutomatically = true;
83     javaScriptEnabled = true;
84     loadsImagesAutomatically = true;
85     localStorageEnabled = true;
86     offlineWebApplicationCacheEnabled = true;
87     pluginsEnabled = true;
88     shrinksStandaloneImagesToFit = false;
89     textAreasAreResizable = false;
90     userStyleSheetLocation = WebURL();
91     usesPageCache = false;
92     webSecurityEnabled = true;
93     caretBrowsingEnabled = false;
94
95     // Allow those layout tests running as local files, i.e. under
96     // LayoutTests/http/tests/local, to access http server.
97     allowUniversalAccessFromFileURLs = true;
98
99 #if OS(DARWIN)
100     editingBehavior = WebSettings::EditingBehaviorMac;
101 #else
102     editingBehavior = WebSettings::EditingBehaviorWin;
103 #endif
104
105     tabsToLinks = false;
106     hyperlinkAuditingEnabled = false;
107     acceleratedCompositingEnabled = false;
108     compositeToTexture = false;
109     accelerated2dCanvasEnabled = false;
110     legacyAccelerated2dCanvasEnabled = false;
111     acceleratedDrawingEnabled = false;
112     forceCompositingMode = false;
113     hixie76WebSocketProtocolEnabled = true;
114 }
115
116 void WebPreferences::applyTo(WebView* webView)
117 {
118     WebSettings* settings = webView->settings();
119     settings->setCursiveFontFamily(cursiveFontFamily);
120     settings->setFantasyFontFamily(fantasyFontFamily);
121     settings->setSerifFontFamily(serifFontFamily);
122     settings->setStandardFontFamily(standardFontFamily);
123     settings->setFixedFontFamily(fixedFontFamily);
124     settings->setSansSerifFontFamily(sansSerifFontFamily);
125
126     settings->setDefaultFontSize(defaultFontSize);
127     settings->setDefaultFixedFontSize(defaultFixedFontSize);
128     settings->setMinimumFontSize(minimumFontSize);
129     settings->setMinimumLogicalFontSize(minimumLogicalFontSize);
130
131     settings->setDOMPasteAllowed(DOMPasteAllowed);
132     settings->setXSSAuditorEnabled(XSSAuditorEnabled);
133     settings->setAllowDisplayOfInsecureContent(allowDisplayOfInsecureContent);
134     settings->setAllowFileAccessFromFileURLs(allowFileAccessFromFileURLs);
135     settings->setAllowRunningOfInsecureContent(allowRunningOfInsecureContent);
136     settings->setAuthorAndUserStylesEnabled(authorAndUserStylesEnabled);
137     settings->setDefaultTextEncodingName(defaultTextEncodingName);
138     settings->setDeveloperExtrasEnabled(developerExtrasEnabled);
139     settings->setExperimentalWebGLEnabled(experimentalWebGLEnabled);
140     settings->setJavaEnabled(javaEnabled);
141     settings->setJavaScriptCanAccessClipboard(javaScriptCanAccessClipboard);
142     settings->setJavaScriptCanOpenWindowsAutomatically(javaScriptCanOpenWindowsAutomatically);
143     settings->setJavaScriptEnabled(javaScriptEnabled);
144     settings->setLoadsImagesAutomatically(loadsImagesAutomatically);
145     settings->setLocalStorageEnabled(localStorageEnabled);
146     settings->setOfflineWebApplicationCacheEnabled(offlineWebApplicationCacheEnabled);
147     settings->setPluginsEnabled(pluginsEnabled);
148     settings->setShrinksStandaloneImagesToFit(shrinksStandaloneImagesToFit);
149     settings->setTextAreasAreResizable(textAreasAreResizable);
150     settings->setUserStyleSheetLocation(userStyleSheetLocation);
151     settings->setUsesPageCache(usesPageCache);
152     settings->setWebSecurityEnabled(webSecurityEnabled);
153     settings->setAllowUniversalAccessFromFileURLs(allowUniversalAccessFromFileURLs);
154     settings->setEditingBehavior(editingBehavior);
155     settings->setHyperlinkAuditingEnabled(hyperlinkAuditingEnabled);
156     // LayoutTests were written with Safari Mac in mind which does not allow
157     // tabbing to links by default.
158     webView->setTabsToLinks(tabsToLinks);
159     settings->setCaretBrowsingEnabled(caretBrowsingEnabled);
160     settings->setAcceleratedCompositingEnabled(acceleratedCompositingEnabled);
161     settings->setCompositeToTextureEnabled(compositeToTexture);
162     settings->setForceCompositingMode(forceCompositingMode);
163     settings->setAccelerated2dCanvasEnabled(accelerated2dCanvasEnabled);
164     settings->setLegacyAccelerated2dCanvasEnabled(legacyAccelerated2dCanvasEnabled);
165     settings->setAcceleratedDrawingEnabled(acceleratedDrawingEnabled);
166     settings->setHixie76WebSocketProtocolEnabled(hixie76WebSocketProtocolEnabled);
167
168     // Fixed values.
169     settings->setShouldPaintCustomScrollbars(true);
170     settings->setTextDirectionSubmenuInclusionBehaviorNeverIncluded();
171     settings->setDownloadableBinaryFontsEnabled(true);
172     settings->setAllowScriptsToCloseWindows(false);
173     settings->setNeedsSiteSpecificQuirks(true);
174     settings->setEditableLinkBehaviorNeverLive();
175     settings->setFontRenderingModeNormal();
176     settings->setTextDirectionSubmenuInclusionBehaviorNeverIncluded();
177     settings->setUsesEncodingDetector(false);
178     settings->setImagesEnabled(true);
179     settings->setInteractiveFormValidationEnabled(true);
180     // Enable fullscreen so the fullscreen layout tests can run.
181     settings->setFullScreenEnabled(true);
182     settings->setValidationMessageTimerMagnification(-1);
183 }
184