[Arrange Tizen Local Patch] Remove viewWidth and viewHeight from Setting(Preferences).
[framework/web/webkit-efl.git] / Source / WebKit2 / Shared / WebPreferencesStore.h
1 /*
2  * Copyright (C) 2010, 2011 Apple 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
6  * are met:
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.
12  *
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.
24  */
25
26 #ifndef WebPreferencesStore_h
27 #define WebPreferencesStore_h
28
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>
34
35 namespace WebKit {
36
37 // macro(KeyUpper, KeyLower, TypeNameUpper, TypeName, DefaultValue) 
38
39 #if PLATFORM(WIN)
40 #define DEFAULT_WEBKIT_AVFOUNDATION_ENABLED false
41 #else
42 #define DEFAULT_WEBKIT_AVFOUNDATION_ENABLED true
43 #endif
44
45 #if PLATFORM(GTK)
46 #define DEFAULT_WEBKIT_TABSTOLINKS_ENABLED true
47 #else
48 #define DEFAULT_WEBKIT_TABSTOLINKS_ENABLED false
49 #endif
50
51 #if PLATFORM(EFL)
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
56 #else
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
61 #endif
62
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) \
130     \
131
132 #define FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(macro) \
133     macro(PDFScaleFactor, pdfScaleFactor, Double, double, 0) \
134     \
135
136 #if PLATFORM(WIN)
137 #define DEFAULT_WEBKIT_FONT_SMOOTHING_LEVEL FontSmoothingLevelWindows
138 #else
139 #define DEFAULT_WEBKIT_FONT_SMOOTHING_LEVEL FontSmoothingLevelMedium
140 #endif
141
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) \
154     \
155
156 #if PLATFORM(WIN)
157
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") \
166     \
167
168 #elif PLATFORM(MAC)
169
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") \
178     \
179
180 #elif PLATFORM(QT) || PLATFORM(GTK) || PLATFORM(EFL)
181
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") \
190     \
191
192 #endif
193
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, "") \
198     \
199
200
201 #if ENABLE(TIZEN_PREFERENCE)
202
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(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) \
211     macro(StyleScopedEnabled, styleScopedEnabled, Bool, bool, true) \
212     macro(LinkMagnifierEnabled, linkMagnifierEnabled, Bool, bool, false) \
213     \
214
215 #else
216
217 #define FOR_EACH_WEBKIT_TIZEN_BOOL_PREFERENCE(macro) \
218     macro(AsynchronousSpellCheckingEnabled, asynchronousSpellCheckingEnabled, Bool, bool, false) \
219     macro(UsesEncodingDetector, usesEncodingDetector, Bool, bool, false) \
220     macro(LoadRemoteImages, loadRemoteImages, Bool, bool, true) \
221     macro(EnableDefaultKeypad, defaultKeypadEnabled, Bool, bool, true) \
222     macro(InteractiveFormValidationEnabled, interactiveFormValidationEnabled, Bool, bool, true) \
223     macro(GeolocationEnabled, geolocationEnabled, Bool, bool, true) \
224     macro(TextZoomEnabled, textZoomEnabled, Bool, bool, false) \
225     macro(StyleScopedEnabled, styleScopedEnabled, Bool, bool, true) \
226     macro(LinkMagnifierEnabled, linkMagnifierEnabled, Bool, bool, false) \
227     \
228
229 #endif
230
231 #define FOR_EACH_WEBKIT_TIZEN_DOUBLE_PREFERENCE(macro) \
232     macro(DefaultViewLevel, defaultViewLevel, Double, double, 1.0) \
233     \
234
235 #define FOR_EACH_WEBKIT_PREFERENCE(macro) \
236     FOR_EACH_WEBKIT_BOOL_PREFERENCE(macro) \
237     FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(macro) \
238     FOR_EACH_WEBKIT_UINT32_PREFERENCE(macro) \
239     FOR_EACH_WEBKIT_STRING_PREFERENCE(macro) \
240     FOR_EACH_WEBKIT_TIZEN_BOOL_PREFERENCE(macro) \
241     FOR_EACH_WEBKIT_TIZEN_DOUBLE_PREFERENCE(macro) \
242     \
243
244 #else
245
246 #define FOR_EACH_WEBKIT_PREFERENCE(macro) \
247     FOR_EACH_WEBKIT_BOOL_PREFERENCE(macro) \
248     FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(macro) \
249     FOR_EACH_WEBKIT_UINT32_PREFERENCE(macro) \
250     FOR_EACH_WEBKIT_STRING_PREFERENCE(macro) \
251     \
252
253 #endif
254
255 namespace WebPreferencesKey {
256
257 #define DECLARE_KEY_GETTERS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) const String& KeyLower##Key();
258
259 FOR_EACH_WEBKIT_PREFERENCE(DECLARE_KEY_GETTERS)
260
261 #undef DECLARE_KEY_GETTERS
262
263 } // namespace WebPreferencesKey
264
265 struct WebPreferencesStore {
266     WebPreferencesStore();
267
268     void encode(CoreIPC::ArgumentEncoder*) const;
269     static bool decode(CoreIPC::ArgumentDecoder*, WebPreferencesStore&);
270
271     // NOTE: The getters in this class have non-standard names to aid in the use of the preference macros.
272
273     bool setStringValueForKey(const String& key, const String& value);
274     String getStringValueForKey(const String& key) const;
275
276     bool setBoolValueForKey(const String& key, bool value);
277     bool getBoolValueForKey(const String& key) const;
278
279     bool setUInt32ValueForKey(const String& key, uint32_t value);
280     uint32_t getUInt32ValueForKey(const String& key) const;
281
282     bool setDoubleValueForKey(const String& key, double value);
283     double getDoubleValueForKey(const String& key) const;
284
285     // For WebKitTestRunner usage.
286     static void overrideBoolValueForKey(const String& key, bool value);
287     static void removeTestRunnerOverrides();
288
289     HashMap<String, String> m_stringValues;
290     HashMap<String, bool> m_boolValues;
291     HashMap<String, uint32_t> m_uint32Values;
292     HashMap<String, double> m_doubleValues;
293 };
294
295 } // namespace WebKit
296
297 #endif // WebPreferencesStore_h