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(MediaPlaybackRequiresUserGesture, mediaPlaybackRequiresUserGesture, Bool, bool, false) \
111 macro(MediaPlaybackAllowsInline, mediaPlaybackAllowsInline, Bool, bool, true) \
112 macro(InspectorStartsAttached, inspectorStartsAttached, Bool, bool, true) \
113 macro(InspectorUsesWebKitUserInterface, inspectorUsesWebKitUserInterface, Bool, bool, false) \
114 macro(ShowsToolTipOverTruncatedText, showsToolTipOverTruncatedText, Bool, bool, false) \
115 macro(MockScrollbarsEnabled, mockScrollbarsEnabled, Bool, bool, false) \
116 macro(WebAudioEnabled, webAudioEnabled, Bool, bool, DEFAULT_WEBKIT_WEBAUDIO_ENABLED) \
117 macro(ApplicationChromeModeEnabled, applicationChromeMode, Bool, bool, false) \
118 macro(SuppressesIncrementalRendering, suppressesIncrementalRendering, Bool, bool, false) \
119 macro(BackspaceKeyNavigationEnabled, backspaceKeyNavigationEnabled, Bool, bool, true) \
120 macro(CaretBrowsingEnabled, caretBrowsingEnabled, Bool, bool, false) \
121 macro(ShouldDisplaySubtitles, shouldDisplaySubtitles, Bool, bool, false) \
122 macro(ShouldDisplayCaptions, shouldDisplayCaptions, Bool, bool, false) \
123 macro(ShouldDisplayTextDescriptions, shouldDisplayTextDescriptions, Bool, bool, false) \
124 macro(NotificationsEnabled, notificationsEnabled, Bool, bool, true) \
125 macro(ShouldRespectImageOrientation, shouldRespectImageOrientation, Bool, bool, false) \
126 macro(WantsBalancedSetDefersLoadingBehavior, wantsBalancedSetDefersLoadingBehavior, Bool, bool, false) \
127 macro(RequestAnimationFrameEnabled, requestAnimationFrameEnabled, Bool, bool, true) \
128 macro(DiagnosticLoggingEnabled, diagnosticLoggingEnabled, Bool, bool, false) \
129 macro(TextAutosizingEnabled, textAutosizingEnabled, Bool, bool, false) \
132 #define FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(macro) \
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, 0) \
150 macro(DeviceHeight, deviceHeight, UInt32, uint32_t, 0) \
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 #if !ENABLE(TIZEN_WEBKIT2_ASYNCHRONOUS_SPELLCHECKING)
204 #define FOR_EACH_WEBKIT_TIZEN_BOOL_PREFERENCE(macro) \
205 macro(UsesEncodingDetector, usesEncodingDetector, Bool, bool, false) \
206 macro(LoadRemoteImages, loadRemoteImages, Bool, bool, true) \
207 macro(LinkEffectEnabled, linkEffectEnabled, Bool, bool, true) \
208 macro(EnableDefaultKeypad, defaultKeypadEnabled, Bool, bool, true) \
209 macro(InteractiveFormValidationEnabled, interactiveFormValidationEnabled, Bool, bool, true) \
210 macro(GeolocationEnabled, geolocationEnabled, Bool, bool, true) \
211 macro(TextZoomEnabled, textZoomEnabled, Bool, bool, false) \
212 macro(StyleScopedEnabled, styleScopedEnabled, Bool, bool, true) \
213 macro(LinkMagnifierEnabled, linkMagnifierEnabled, Bool, bool, false) \
214 macro(AutoFittingEnabled, autoFittingEnabled, Bool, bool, true) \
219 #define FOR_EACH_WEBKIT_TIZEN_BOOL_PREFERENCE(macro) \
220 macro(AsynchronousSpellCheckingEnabled, asynchronousSpellCheckingEnabled, Bool, bool, false) \
221 macro(UsesEncodingDetector, usesEncodingDetector, Bool, bool, false) \
222 macro(LoadRemoteImages, loadRemoteImages, Bool, bool, true) \
223 macro(LinkEffectEnabled, linkEffectEnabled, Bool, bool, true) \
224 macro(EnableDefaultKeypad, defaultKeypadEnabled, Bool, bool, true) \
225 macro(InteractiveFormValidationEnabled, interactiveFormValidationEnabled, Bool, bool, true) \
226 macro(GeolocationEnabled, geolocationEnabled, Bool, bool, true) \
227 macro(TextZoomEnabled, textZoomEnabled, Bool, bool, false) \
228 macro(StyleScopedEnabled, styleScopedEnabled, Bool, bool, true) \
229 macro(LinkMagnifierEnabled, linkMagnifierEnabled, Bool, bool, false) \
230 macro(AutoFittingEnabled, autoFittingEnabled, Bool, bool, true) \
235 #define FOR_EACH_WEBKIT_TIZEN_DOUBLE_PREFERENCE(macro) \
236 macro(DefaultViewLevel, defaultViewLevel, Double, double, 1.0) \
239 #define FOR_EACH_WEBKIT_PREFERENCE(macro) \
240 FOR_EACH_WEBKIT_BOOL_PREFERENCE(macro) \
241 FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(macro) \
242 FOR_EACH_WEBKIT_UINT32_PREFERENCE(macro) \
243 FOR_EACH_WEBKIT_STRING_PREFERENCE(macro) \
244 FOR_EACH_WEBKIT_TIZEN_BOOL_PREFERENCE(macro) \
245 FOR_EACH_WEBKIT_TIZEN_DOUBLE_PREFERENCE(macro) \
250 #define FOR_EACH_WEBKIT_PREFERENCE(macro) \
251 FOR_EACH_WEBKIT_BOOL_PREFERENCE(macro) \
252 FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(macro) \
253 FOR_EACH_WEBKIT_UINT32_PREFERENCE(macro) \
254 FOR_EACH_WEBKIT_STRING_PREFERENCE(macro) \
259 namespace WebPreferencesKey {
261 #define DECLARE_KEY_GETTERS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) const String& KeyLower##Key();
263 FOR_EACH_WEBKIT_PREFERENCE(DECLARE_KEY_GETTERS)
265 #undef DECLARE_KEY_GETTERS
267 } // namespace WebPreferencesKey
269 struct WebPreferencesStore {
270 WebPreferencesStore();
272 void encode(CoreIPC::ArgumentEncoder*) const;
273 static bool decode(CoreIPC::ArgumentDecoder*, WebPreferencesStore&);
275 // NOTE: The getters in this class have non-standard names to aid in the use of the preference macros.
277 bool setStringValueForKey(const String& key, const String& value);
278 String getStringValueForKey(const String& key) const;
280 bool setBoolValueForKey(const String& key, bool value);
281 bool getBoolValueForKey(const String& key) const;
283 bool setUInt32ValueForKey(const String& key, uint32_t value);
284 uint32_t getUInt32ValueForKey(const String& key) const;
286 bool setDoubleValueForKey(const String& key, double value);
287 double getDoubleValueForKey(const String& key) const;
289 // For WebKitTestRunner usage.
290 static void overrideBoolValueForKey(const String& key, bool value);
291 static void removeTestRunnerOverrides();
293 HashMap<String, String> m_stringValues;
294 HashMap<String, bool> m_boolValues;
295 HashMap<String, uint32_t> m_uint32Values;
296 HashMap<String, double> m_doubleValues;
299 } // namespace WebKit
301 #endif // WebPreferencesStore_h