2 * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef WebPreferencesStore_h
27 #define WebPreferencesStore_h
29 #include "ArgumentDecoder.h"
30 #include "ArgumentEncoder.h"
31 #include <wtf/HashMap.h>
32 #include <wtf/text/StringHash.h>
33 #include <wtf/text/WTFString.h>
37 // macro(KeyUpper, KeyLower, TypeNameUpper, TypeName, DefaultValue)
40 #define DEFAULT_WEBKIT_AVFOUNDATION_ENABLED false
42 #define DEFAULT_WEBKIT_AVFOUNDATION_ENABLED true
46 #define DEFAULT_WEBKIT_TABSTOLINKS_ENABLED true
48 #define DEFAULT_WEBKIT_TABSTOLINKS_ENABLED false
52 #define DEFAULT_WEBKIT_FULLSCREENAPI_ENABLED true
53 #define DEFAULT_WEBKIT_OFFLINEWEBAPPLICATIONCACHE_ENABLED true
54 #define DEFAULT_WEBKIT_WEBAUDIO_ENABLED true
55 #define DEFAULT_WEBKIT_WEBGL_ENABLED true
57 #define DEFAULT_WEBKIT_FULLSCREENAPI_ENABLED false
58 #define DEFAULT_WEBKIT_OFFLINEWEBAPPLICATIONCACHE_ENABLED false
59 #define DEFAULT_WEBKIT_WEBAUDIO_ENABLED false
60 #define DEFAULT_WEBKIT_WEBGL_ENABLED false
63 #define FOR_EACH_WEBKIT_BOOL_PREFERENCE(macro) \
64 macro(JavaScriptEnabled, javaScriptEnabled, Bool, bool, true) \
65 macro(LoadsImagesAutomatically, loadsImagesAutomatically, Bool, bool, true) \
66 macro(LoadsSiteIconsIgnoringImageLoadingPreference, loadsSiteIconsIgnoringImageLoadingPreference, Bool, bool, false) \
67 macro(PluginsEnabled, pluginsEnabled, Bool, bool, true) \
68 macro(JavaEnabled, javaEnabled, Bool, bool, true) \
69 macro(JavaEnabledForLocalFiles, javaEnabledForLocalFiles, Bool, bool, true) \
70 macro(OfflineWebApplicationCacheEnabled, offlineWebApplicationCacheEnabled, Bool, bool, DEFAULT_WEBKIT_OFFLINEWEBAPPLICATIONCACHE_ENABLED) \
71 macro(LocalStorageEnabled, localStorageEnabled, Bool, bool, true) \
72 macro(DatabasesEnabled, databasesEnabled, Bool, bool, true) \
73 macro(XSSAuditorEnabled, xssAuditorEnabled, Bool, bool, true) \
74 macro(FrameFlatteningEnabled, frameFlatteningEnabled, Bool, bool, false) \
75 macro(DeveloperExtrasEnabled, developerExtrasEnabled, Bool, bool, false) \
76 macro(JavaScriptExperimentsEnabled, javaScriptExperimentsEnabled, Bool, bool, false) \
77 macro(PrivateBrowsingEnabled, privateBrowsingEnabled, Bool, bool, false) \
78 macro(TextAreasAreResizable, textAreasAreResizable, Bool, bool, true) \
79 macro(JavaScriptCanOpenWindowsAutomatically, javaScriptCanOpenWindowsAutomatically, Bool, bool, true) \
80 macro(HyperlinkAuditingEnabled, hyperlinkAuditingEnabled, Bool, bool, true) \
81 macro(NeedsSiteSpecificQuirks, needsSiteSpecificQuirks, Bool, bool, false) \
82 macro(AcceleratedCompositingEnabled, acceleratedCompositingEnabled, Bool, bool, true) \
83 macro(ForceCompositingMode, forceCompositingMode, Bool, bool, false) \
84 macro(AcceleratedDrawingEnabled, acceleratedDrawingEnabled, Bool, bool, false) \
85 macro(CanvasUsesAcceleratedDrawing, canvasUsesAcceleratedDrawing, Bool, bool, true) \
86 macro(CompositingBordersVisible, compositingBordersVisible, Bool, bool, false) \
87 macro(CompositingRepaintCountersVisible, compositingRepaintCountersVisible, Bool, bool, false) \
88 macro(CSSCustomFilterEnabled, cssCustomFilterEnabled, Bool, bool, true) \
89 macro(WebGLEnabled, webGLEnabled, Bool, bool, DEFAULT_WEBKIT_WEBGL_ENABLED) \
90 macro(CSSRegionsEnabled, cssRegionsEnabled, Bool, bool, true) \
91 macro(CSSGridLayoutEnabled, cssGridLayoutEnabled, Bool, bool, false) \
92 macro(RegionBasedColumnsEnabled, regionBasedColumnsEnabled, Bool, bool, false) \
93 macro(ForceFTPDirectoryListings, forceFTPDirectoryListings, Bool, bool, false) \
94 macro(TabsToLinks, tabsToLinks, Bool, bool, DEFAULT_WEBKIT_TABSTOLINKS_ENABLED) \
95 macro(DNSPrefetchingEnabled, dnsPrefetchingEnabled, Bool, bool, false) \
96 macro(WebArchiveDebugModeEnabled, webArchiveDebugModeEnabled, Bool, bool, false) \
97 macro(LocalFileContentSniffingEnabled, localFileContentSniffingEnabled, Bool, bool, false) \
98 macro(UsesPageCache, usesPageCache, Bool, bool, true) \
99 macro(PageCacheSupportsPlugins, pageCacheSupportsPlugins, Bool, bool, true) \
100 macro(AuthorAndUserStylesEnabled, authorAndUserStylesEnabled, Bool, bool, true) \
101 macro(PaginateDuringLayoutEnabled, paginateDuringLayoutEnabled, Bool, bool, false) \
102 macro(DOMPasteAllowed, domPasteAllowed, Bool, bool, false) \
103 macro(JavaScriptCanAccessClipboard, javaScriptCanAccessClipboard, Bool, bool, false) \
104 macro(ShouldPrintBackgrounds, shouldPrintBackgrounds, Bool, bool, false) \
105 macro(FullScreenEnabled, fullScreenEnabled, Bool, bool, DEFAULT_WEBKIT_FULLSCREENAPI_ENABLED) \
106 macro(WebSecurityEnabled, webSecurityEnabled, Bool, bool, true) \
107 macro(AllowUniversalAccessFromFileURLs, allowUniversalAccessFromFileURLs, Bool, bool, false) \
108 macro(AllowFileAccessFromFileURLs, allowFileAccessFromFileURLs, Bool, bool, false) \
109 macro(AVFoundationEnabled, isAVFoundationEnabled, Bool, bool, DEFAULT_WEBKIT_AVFOUNDATION_ENABLED) \
110 macro(Hixie76WebSocketProtocolEnabled, hixie76WebSocketProtocolEnabled, Bool, bool, false) \
111 macro(MediaPlaybackRequiresUserGesture, mediaPlaybackRequiresUserGesture, Bool, bool, false) \
112 macro(MediaPlaybackAllowsInline, mediaPlaybackAllowsInline, Bool, bool, true) \
113 macro(InspectorStartsAttached, inspectorStartsAttached, Bool, bool, true) \
114 macro(InspectorUsesWebKitUserInterface, inspectorUsesWebKitUserInterface, Bool, bool, false) \
115 macro(ShowsToolTipOverTruncatedText, showsToolTipOverTruncatedText, Bool, bool, false) \
116 macro(MockScrollbarsEnabled, mockScrollbarsEnabled, Bool, bool, false) \
117 macro(WebAudioEnabled, webAudioEnabled, Bool, bool, DEFAULT_WEBKIT_WEBAUDIO_ENABLED) \
118 macro(ApplicationChromeModeEnabled, applicationChromeMode, Bool, bool, false) \
119 macro(SuppressesIncrementalRendering, suppressesIncrementalRendering, Bool, bool, false) \
120 macro(BackspaceKeyNavigationEnabled, backspaceKeyNavigationEnabled, Bool, bool, true) \
121 macro(CaretBrowsingEnabled, caretBrowsingEnabled, Bool, bool, false) \
122 macro(ShouldDisplaySubtitles, shouldDisplaySubtitles, Bool, bool, false) \
123 macro(ShouldDisplayCaptions, shouldDisplayCaptions, Bool, bool, false) \
124 macro(ShouldDisplayTextDescriptions, shouldDisplayTextDescriptions, Bool, bool, false) \
125 macro(NotificationsEnabled, notificationsEnabled, Bool, bool, true) \
126 macro(ShouldRespectImageOrientation, shouldRespectImageOrientation, Bool, bool, false) \
127 macro(WantsBalancedSetDefersLoadingBehavior, wantsBalancedSetDefersLoadingBehavior, Bool, bool, false) \
128 macro(RequestAnimationFrameEnabled, requestAnimationFrameEnabled, Bool, bool, true) \
131 #define FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(macro) \
132 macro(DevicePixelRatio, devicePixelRatio, Double, double, 1.0) \
133 macro(PDFScaleFactor, pdfScaleFactor, Double, double, 0) \
137 #define DEFAULT_WEBKIT_FONT_SMOOTHING_LEVEL FontSmoothingLevelWindows
139 #define DEFAULT_WEBKIT_FONT_SMOOTHING_LEVEL FontSmoothingLevelMedium
142 #define FOR_EACH_WEBKIT_UINT32_PREFERENCE(macro) \
143 macro(FontSmoothingLevel, fontSmoothingLevel, UInt32, uint32_t, DEFAULT_WEBKIT_FONT_SMOOTHING_LEVEL) \
144 macro(MinimumFontSize, minimumFontSize, UInt32, uint32_t, 0) \
145 macro(MinimumLogicalFontSize, minimumLogicalFontSize, UInt32, uint32_t, 9) \
146 macro(DefaultFontSize, defaultFontSize, UInt32, uint32_t, 16) \
147 macro(DefaultFixedFontSize, defaultFixedFontSize, UInt32, uint32_t, 13) \
148 macro(LayoutFallbackWidth, layoutFallbackWidth, UInt32, uint32_t, 980) \
149 macro(DeviceWidth, deviceWidth, UInt32, uint32_t, 480) \
150 macro(DeviceHeight, deviceHeight, UInt32, uint32_t, 854) \
151 macro(PDFDisplayMode, pdfDisplayMode, UInt32, uint32_t, 1) \
152 macro(EditableLinkBehavior, editableLinkBehavior, UInt32, uint32_t, WebCore::EditableLinkNeverLive) \
153 macro(InspectorAttachedHeight, inspectorAttachedHeight, UInt32, uint32_t, 300) \
158 #define FOR_EACH_WEBKIT_FONT_FAMILY_PREFERENCE(macro) \
159 macro(StandardFontFamily, standardFontFamily, String, String, "Times New Roman") \
160 macro(CursiveFontFamily, cursiveFontFamily, String, String, "Comic Sans MS") \
161 macro(FantasyFontFamily, fantasyFontFamily, String, String, "Comic Sans MS") \
162 macro(FixedFontFamily, fixedFontFamily, String, String, "Courier New") \
163 macro(SansSerifFontFamily, sansSerifFontFamily, String, String, "Arial") \
164 macro(SerifFontFamily, serifFontFamily, String, String, "Times New Roman") \
165 macro(PictographFontFamily, pictographFontFamily, String, String, "Times New Roman") \
170 #define FOR_EACH_WEBKIT_FONT_FAMILY_PREFERENCE(macro) \
171 macro(StandardFontFamily, standardFontFamily, String, String, "Times") \
172 macro(CursiveFontFamily, cursiveFontFamily, String, String, "Apple Chancery") \
173 macro(FantasyFontFamily, fantasyFontFamily, String, String, "Papyrus") \
174 macro(FixedFontFamily, fixedFontFamily, String, String, "Courier") \
175 macro(SansSerifFontFamily, sansSerifFontFamily, String, String, "Helvetica") \
176 macro(SerifFontFamily, serifFontFamily, String, String, "Times") \
177 macro(PictographFontFamily, pictographFontFamily, String, String, "Apple Color Emoji") \
180 #elif PLATFORM(QT) || PLATFORM(GTK) || PLATFORM(EFL)
182 #define FOR_EACH_WEBKIT_FONT_FAMILY_PREFERENCE(macro) \
183 macro(StandardFontFamily, standardFontFamily, String, String, "Times") \
184 macro(CursiveFontFamily, cursiveFontFamily, String, String, "Comic Sans MS") \
185 macro(FantasyFontFamily, fantasyFontFamily, String, String, "Impact") \
186 macro(FixedFontFamily, fixedFontFamily, String, String, "Courier New") \
187 macro(SansSerifFontFamily, sansSerifFontFamily, String, String, "Helvetica") \
188 macro(SerifFontFamily, serifFontFamily, String, String, "Times") \
189 macro(PictographFontFamily, pictographFontFamily, String, String, "Times") \
194 #define FOR_EACH_WEBKIT_STRING_PREFERENCE(macro) \
195 FOR_EACH_WEBKIT_FONT_FAMILY_PREFERENCE(macro) \
196 macro(DefaultTextEncodingName, defaultTextEncodingName, String, String, "ISO-8859-1") \
197 macro(FTPDirectoryTemplatePath, ftpDirectoryTemplatePath, String, String, "") \
201 #if ENABLE(TIZEN_PREFERENCE)
203 #define FOR_EACH_WEBKIT_TIZEN_BOOL_PREFERENCE(macro) \
204 macro(UsesEncodingDetector, usesEncodingDetector, Bool, bool, false) \
205 macro(LoadRemoteImages, loadRemoteImages, Bool, bool, true) \
206 macro(ShowImeOnAutofocus, showImeOnAutofocus, Bool, bool, true) \
207 macro(EnableDefaultKeypad, defaultKeypadEnabled, Bool, bool, true) \
208 macro(InteractiveFormValidationEnabled, interactiveFormValidationEnabled, Bool, bool, true) \
209 macro(GeolocationEnabled, geolocationEnabled, Bool, bool, true) \
210 macro(TextZoomEnabled, textZoomEnabled, Bool, bool, false) \
213 #define FOR_EACH_WEBKIT_TIZEN_DOUBLE_PREFERENCE(macro) \
214 macro(DefaultViewLevel, defaultViewLevel, Double, double, 1.0) \
217 #define FOR_EACH_WEBKIT_TIZEN_UINT32_PREFERENCE(macro) \
218 macro(ViewWidth, viewWidth, UInt32, uint32_t, 480) \
219 macro(ViewHeight, viewHeight, UInt32, uint32_t, 800) \
222 #define FOR_EACH_WEBKIT_PREFERENCE(macro) \
223 FOR_EACH_WEBKIT_BOOL_PREFERENCE(macro) \
224 FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(macro) \
225 FOR_EACH_WEBKIT_UINT32_PREFERENCE(macro) \
226 FOR_EACH_WEBKIT_STRING_PREFERENCE(macro) \
227 FOR_EACH_WEBKIT_TIZEN_BOOL_PREFERENCE(macro) \
228 FOR_EACH_WEBKIT_TIZEN_DOUBLE_PREFERENCE(macro) \
229 FOR_EACH_WEBKIT_TIZEN_UINT32_PREFERENCE(macro) \
234 #define FOR_EACH_WEBKIT_PREFERENCE(macro) \
235 FOR_EACH_WEBKIT_BOOL_PREFERENCE(macro) \
236 FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(macro) \
237 FOR_EACH_WEBKIT_UINT32_PREFERENCE(macro) \
238 FOR_EACH_WEBKIT_STRING_PREFERENCE(macro) \
243 namespace WebPreferencesKey {
245 #define DECLARE_KEY_GETTERS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) const String& KeyLower##Key();
247 FOR_EACH_WEBKIT_PREFERENCE(DECLARE_KEY_GETTERS)
249 #undef DECLARE_KEY_GETTERS
251 } // namespace WebPreferencesKey
253 struct WebPreferencesStore {
254 WebPreferencesStore();
256 void encode(CoreIPC::ArgumentEncoder*) const;
257 static bool decode(CoreIPC::ArgumentDecoder*, WebPreferencesStore&);
259 // NOTE: The getters in this class have non-standard names to aid in the use of the preference macros.
261 bool setStringValueForKey(const String& key, const String& value);
262 String getStringValueForKey(const String& key) const;
264 bool setBoolValueForKey(const String& key, bool value);
265 bool getBoolValueForKey(const String& key) const;
267 bool setUInt32ValueForKey(const String& key, uint32_t value);
268 uint32_t getUInt32ValueForKey(const String& key) const;
270 bool setDoubleValueForKey(const String& key, double value);
271 double getDoubleValueForKey(const String& key) const;
273 // For WebKitTestRunner usage.
274 static void overrideBoolValueForKey(const String& key, bool value);
275 static void removeTestRunnerOverrides();
277 HashMap<String, String> m_stringValues;
278 HashMap<String, bool> m_boolValues;
279 HashMap<String, uint32_t> m_uint32Values;
280 HashMap<String, double> m_doubleValues;
283 } // namespace WebKit
285 #endif // WebPreferencesStore_h