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
51 #define FOR_EACH_WEBKIT_BOOL_PREFERENCE(macro) \
52 macro(JavaScriptEnabled, javaScriptEnabled, Bool, bool, true) \
53 macro(LoadsImagesAutomatically, loadsImagesAutomatically, Bool, bool, true) \
54 macro(LoadsSiteIconsIgnoringImageLoadingPreference, loadsSiteIconsIgnoringImageLoadingPreference, Bool, bool, false) \
55 macro(PluginsEnabled, pluginsEnabled, Bool, bool, true) \
56 macro(JavaEnabled, javaEnabled, Bool, bool, true) \
57 macro(OfflineWebApplicationCacheEnabled, offlineWebApplicationCacheEnabled, Bool, bool, false) \
58 macro(LocalStorageEnabled, localStorageEnabled, Bool, bool, true) \
59 macro(DatabasesEnabled, databasesEnabled, Bool, bool, true) \
60 macro(XSSAuditorEnabled, xssAuditorEnabled, Bool, bool, true) \
61 macro(FrameFlatteningEnabled, frameFlatteningEnabled, Bool, bool, false) \
62 macro(DeveloperExtrasEnabled, developerExtrasEnabled, Bool, bool, false) \
63 macro(PrivateBrowsingEnabled, privateBrowsingEnabled, Bool, bool, false) \
64 macro(TextAreasAreResizable, textAreasAreResizable, Bool, bool, true) \
65 macro(JavaScriptCanOpenWindowsAutomatically, javaScriptCanOpenWindowsAutomatically, Bool, bool, true) \
66 macro(HyperlinkAuditingEnabled, hyperlinkAuditingEnabled, Bool, bool, true) \
67 macro(NeedsSiteSpecificQuirks, needsSiteSpecificQuirks, Bool, bool, false) \
68 macro(AcceleratedCompositingEnabled, acceleratedCompositingEnabled, Bool, bool, true) \
69 macro(AcceleratedDrawingEnabled, acceleratedDrawingEnabled, Bool, bool, false) \
70 macro(CanvasUsesAcceleratedDrawing, canvasUsesAcceleratedDrawing, Bool, bool, true) \
71 macro(CompositingBordersVisible, compositingBordersVisible, Bool, bool, false) \
72 macro(CompositingRepaintCountersVisible, compositingRepaintCountersVisible, Bool, bool, false) \
73 macro(WebGLEnabled, webGLEnabled, Bool, bool, false) \
74 macro(ForceFTPDirectoryListings, forceFTPDirectoryListings, Bool, bool, false) \
75 macro(TabsToLinks, tabsToLinks, Bool, bool, DEFAULT_WEBKIT_TABSTOLINKS_ENABLED) \
76 macro(DNSPrefetchingEnabled, dnsPrefetchingEnabled, Bool, bool, false) \
77 macro(WebArchiveDebugModeEnabled, webArchiveDebugModeEnabled, Bool, bool, false) \
78 macro(LocalFileContentSniffingEnabled, localFileContentSniffingEnabled, Bool, bool, false) \
79 macro(UsesPageCache, usesPageCache, Bool, bool, true) \
80 macro(AuthorAndUserStylesEnabled, authorAndUserStylesEnabled, Bool, bool, true) \
81 macro(PaginateDuringLayoutEnabled, paginateDuringLayoutEnabled, Bool, bool, false) \
82 macro(DOMPasteAllowed, domPasteAllowed, Bool, bool, false) \
83 macro(JavaScriptCanAccessClipboard, javaScriptCanAccessClipboard, Bool, bool, false) \
84 macro(ShouldPrintBackgrounds, shouldPrintBackgrounds, Bool, bool, false) \
85 macro(FullScreenEnabled, fullScreenEnabled, Bool, bool, false) \
86 macro(WebSecurityEnabled, webSecurityEnabled, Bool, bool, true) \
87 macro(AllowUniversalAccessFromFileURLs, allowUniversalAccessFromFileURLs, Bool, bool, false) \
88 macro(AllowFileAccessFromFileURLs, allowFileAccessFromFileURLs, Bool, bool, false) \
89 macro(AVFoundationEnabled, isAVFoundationEnabled, Bool, bool, DEFAULT_WEBKIT_AVFOUNDATION_ENABLED) \
90 macro(Hixie76WebSocketProtocolEnabled, hixie76WebSocketProtocolEnabled, Bool, bool, true) \
91 macro(MediaPlaybackRequiresUserGesture, mediaPlaybackRequiresUserGesture, Bool, bool, false) \
92 macro(MediaPlaybackAllowsInline, mediaPlaybackAllowsInline, Bool, bool, true) \
93 macro(InspectorStartsAttached, inspectorStartsAttached, Bool, bool, true) \
94 macro(ShowsToolTipOverTruncatedText, showsToolTipOverTruncatedText, Bool, bool, false) \
97 #define FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(macro) \
98 macro(PDFScaleFactor, pdfScaleFactor, Double, double, 0) \
102 #define DEFAULT_WEBKIT_FONT_SMOOTHING_LEVEL FontSmoothingLevelWindows
104 #define DEFAULT_WEBKIT_FONT_SMOOTHING_LEVEL FontSmoothingLevelMedium
107 #define FOR_EACH_WEBKIT_UINT32_PREFERENCE(macro) \
108 macro(FontSmoothingLevel, fontSmoothingLevel, UInt32, uint32_t, DEFAULT_WEBKIT_FONT_SMOOTHING_LEVEL) \
109 macro(MinimumFontSize, minimumFontSize, UInt32, uint32_t, 0) \
110 macro(MinimumLogicalFontSize, minimumLogicalFontSize, UInt32, uint32_t, 9) \
111 macro(DefaultFontSize, defaultFontSize, UInt32, uint32_t, 16) \
112 macro(DefaultFixedFontSize, defaultFixedFontSize, UInt32, uint32_t, 13) \
113 macro(LayoutFallbackWidth, layoutFallbackWidth, UInt32, uint32_t, 980) \
114 macro(DeviceDPI, deviceDPI, UInt32, uint32_t, 240) \
115 macro(DeviceWidth, deviceWidth, UInt32, uint32_t, 480) \
116 macro(DeviceHeight, deviceHeight, UInt32, uint32_t, 854) \
117 macro(PDFDisplayMode, pdfDisplayMode, UInt32, uint32_t, 1) \
118 macro(EditableLinkBehavior, editableLinkBehavior, UInt32, uint32_t, WebCore::EditableLinkNeverLive) \
123 #define FOR_EACH_WEBKIT_FONT_FAMILY_PREFERENCE(macro) \
124 macro(StandardFontFamily, standardFontFamily, String, String, "Times New Roman") \
125 macro(CursiveFontFamily, cursiveFontFamily, String, String, "Comic Sans MS") \
126 macro(FantasyFontFamily, fantasyFontFamily, String, String, "Comic Sans MS") \
127 macro(FixedFontFamily, fixedFontFamily, String, String, "Courier New") \
128 macro(SansSerifFontFamily, sansSerifFontFamily, String, String, "Arial") \
129 macro(SerifFontFamily, serifFontFamily, String, String, "Times New Roman") \
130 macro(PictographFontFamily, pictographFontFamily, String, String, "Times New Roman") \
135 #define FOR_EACH_WEBKIT_FONT_FAMILY_PREFERENCE(macro) \
136 macro(StandardFontFamily, standardFontFamily, String, String, "Times") \
137 macro(CursiveFontFamily, cursiveFontFamily, String, String, "Apple Chancery") \
138 macro(FantasyFontFamily, fantasyFontFamily, String, String, "Papyrus") \
139 macro(FixedFontFamily, fixedFontFamily, String, String, "Courier") \
140 macro(SansSerifFontFamily, sansSerifFontFamily, String, String, "Helvetica") \
141 macro(SerifFontFamily, serifFontFamily, String, String, "Times") \
142 macro(PictographFontFamily, pictographFontFamily, String, String, "Apple Color Emoji") \
145 #elif PLATFORM(QT) || PLATFORM(GTK)
147 #define FOR_EACH_WEBKIT_FONT_FAMILY_PREFERENCE(macro) \
148 macro(StandardFontFamily, standardFontFamily, String, String, "Times") \
149 macro(CursiveFontFamily, cursiveFontFamily, String, String, "Comic Sans MS") \
150 macro(FantasyFontFamily, fantasyFontFamily, String, String, "Impact") \
151 macro(FixedFontFamily, fixedFontFamily, String, String, "Courier New") \
152 macro(SansSerifFontFamily, sansSerifFontFamily, String, String, "Helvetica") \
153 macro(SerifFontFamily, serifFontFamily, String, String, "Times") \
154 macro(PictographFontFamily, pictographFontFamily, String, String, "Times") \
159 #define FOR_EACH_WEBKIT_STRING_PREFERENCE(macro) \
160 FOR_EACH_WEBKIT_FONT_FAMILY_PREFERENCE(macro) \
161 macro(DefaultTextEncodingName, defaultTextEncodingName, String, String, "ISO-8859-1") \
162 macro(FTPDirectoryTemplatePath, ftpDirectoryTemplatePath, String, String, "") \
166 #define FOR_EACH_WEBKIT_PREFERENCE(macro) \
167 FOR_EACH_WEBKIT_BOOL_PREFERENCE(macro) \
168 FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(macro) \
169 FOR_EACH_WEBKIT_UINT32_PREFERENCE(macro) \
170 FOR_EACH_WEBKIT_STRING_PREFERENCE(macro) \
173 namespace WebPreferencesKey {
175 #define DECLARE_KEY_GETTERS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) const String& KeyLower##Key();
177 FOR_EACH_WEBKIT_PREFERENCE(DECLARE_KEY_GETTERS)
179 #undef DECLARE_KEY_GETTERS
181 } // namespace WebPreferencesKey
183 struct WebPreferencesStore {
184 WebPreferencesStore();
186 void encode(CoreIPC::ArgumentEncoder*) const;
187 static bool decode(CoreIPC::ArgumentDecoder*, WebPreferencesStore&);
189 // NOTE: The getters in this class have non-standard names to aid in the use of the preference macros.
191 bool setStringValueForKey(const String& key, const String& value);
192 String getStringValueForKey(const String& key) const;
194 bool setBoolValueForKey(const String& key, bool value);
195 bool getBoolValueForKey(const String& key) const;
197 bool setUInt32ValueForKey(const String& key, uint32_t value);
198 uint32_t getUInt32ValueForKey(const String& key) const;
200 bool setDoubleValueForKey(const String& key, double value);
201 double getDoubleValueForKey(const String& key) const;
203 static void overrideXSSAuditorEnabledForTestRunner(bool);
204 static void removeTestRunnerOverrides();
206 HashMap<String, String> m_stringValues;
207 HashMap<String, bool> m_boolValues;
208 HashMap<String, uint32_t> m_uint32Values;
209 HashMap<String, double> m_doubleValues;
212 } // namespace WebKit
214 #endif // WebPreferencesStore_h