• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2003, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3  *           (C) 2006 Graham Dennis (graham.dennis@gmail.com)
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26 
27 #ifndef Settings_h
28 #define Settings_h
29 
30 #include "AtomicString.h"
31 #include "FontRenderingMode.h"
32 #include "KURL.h"
33 
34 namespace WebCore {
35 
36     class Page;
37 
38     enum EditableLinkBehavior {
39         EditableLinkDefaultBehavior,
40         EditableLinkAlwaysLive,
41         EditableLinkOnlyLiveWithShiftKey,
42         EditableLinkLiveWhenNotFocused,
43         EditableLinkNeverLive
44     };
45 
46     enum TextDirectionSubmenuInclusionBehavior {
47         TextDirectionSubmenuNeverIncluded,
48         TextDirectionSubmenuAutomaticallyIncluded,
49         TextDirectionSubmenuAlwaysIncluded
50     };
51 
52     // There are multiple editing details that are different on Windows than Macintosh.
53     // We use a single switch for all of them. Some examples:
54     //
55     //    1) Clicking below the last line of an editable area puts the caret at the end
56     //       of the last line on Mac, but in the middle of the last line on Windows.
57     //    2) Pushing the down arrow key on the last line puts the caret at the end of the
58     //       last line on Mac, but does nothing on Windows. A similar case exists on the
59     //       top line.
60     //
61     // This setting is intended to control these sorts of behaviors. There are some other
62     // behaviors with individual function calls on EditorClient (smart copy and paste and
63     // selecting the space after a double click) that could be combined with this if
64     // if possible in the future.
65     enum EditingBehavior { EditingMacBehavior, EditingWindowsBehavior };
66 
67     class Settings {
68     public:
69         Settings(Page*);
70 
71 #ifdef ANDROID_LAYOUT
72         // FIXME: How do we determine the margins other than guessing?
73         #define ANDROID_SSR_MARGIN_PADDING  3
74         #define ANDROID_FCTS_MARGIN_PADDING  10
75 
76         enum LayoutAlgorithm {
77             kLayoutNormal,
78             kLayoutSSR,
79             kLayoutFitColumnToScreen
80         };
81 #endif
82         void setStandardFontFamily(const AtomicString&);
standardFontFamily()83         const AtomicString& standardFontFamily() const { return m_standardFontFamily; }
84 
85         void setFixedFontFamily(const AtomicString&);
fixedFontFamily()86         const AtomicString& fixedFontFamily() const { return m_fixedFontFamily; }
87 
88 #ifdef ANDROID_LAYOUT
layoutAlgorithm()89         LayoutAlgorithm layoutAlgorithm() const { return m_layoutAlgorithm; }
setLayoutAlgorithm(LayoutAlgorithm algorithm)90         void setLayoutAlgorithm(LayoutAlgorithm algorithm) { m_layoutAlgorithm = algorithm; }
91 
useWideViewport()92         bool useWideViewport() const { return m_useWideViewport; }
setUseWideViewport(bool use)93         void setUseWideViewport(bool use) { m_useWideViewport = use; }
94 #endif
95 
96         void setSerifFontFamily(const AtomicString&);
serifFontFamily()97         const AtomicString& serifFontFamily() const { return m_serifFontFamily; }
98 
99         void setSansSerifFontFamily(const AtomicString&);
sansSerifFontFamily()100         const AtomicString& sansSerifFontFamily() const { return m_sansSerifFontFamily; }
101 
102         void setCursiveFontFamily(const AtomicString&);
cursiveFontFamily()103         const AtomicString& cursiveFontFamily() const { return m_cursiveFontFamily; }
104 
105         void setFantasyFontFamily(const AtomicString&);
fantasyFontFamily()106         const AtomicString& fantasyFontFamily() const { return m_fantasyFontFamily; }
107 
108         void setMinimumFontSize(int);
minimumFontSize()109         int minimumFontSize() const { return m_minimumFontSize; }
110 
111         void setMinimumLogicalFontSize(int);
minimumLogicalFontSize()112         int minimumLogicalFontSize() const { return m_minimumLogicalFontSize; }
113 
114         void setDefaultFontSize(int);
defaultFontSize()115         int defaultFontSize() const { return m_defaultFontSize; }
116 
117         void setDefaultFixedFontSize(int);
defaultFixedFontSize()118         int defaultFixedFontSize() const { return m_defaultFixedFontSize; }
119 
120         void setLoadsImagesAutomatically(bool);
loadsImagesAutomatically()121         bool loadsImagesAutomatically() const { return m_loadsImagesAutomatically; }
122 
123 #ifdef ANDROID_BLOCK_NETWORK_IMAGE
124         void setBlockNetworkImage(bool);
blockNetworkImage()125         bool blockNetworkImage() const { return m_blockNetworkImage; }
126 #endif
127         void setJavaScriptEnabled(bool);
isJavaScriptEnabled()128         bool isJavaScriptEnabled() const { return m_isJavaScriptEnabled; }
129 
130         void setWebSecurityEnabled(bool);
isWebSecurityEnabled()131         bool isWebSecurityEnabled() const { return m_isWebSecurityEnabled; }
132 
133         void setAllowUniversalAccessFromFileURLs(bool);
allowUniversalAccessFromFileURLs()134         bool allowUniversalAccessFromFileURLs() const { return m_allowUniversalAccessFromFileURLs; }
135 
136         void setJavaScriptCanOpenWindowsAutomatically(bool);
javaScriptCanOpenWindowsAutomatically()137         bool javaScriptCanOpenWindowsAutomatically() const { return m_javaScriptCanOpenWindowsAutomatically; }
138 
139         void setJavaEnabled(bool);
isJavaEnabled()140         bool isJavaEnabled() const { return m_isJavaEnabled; }
141 
142         void setPluginsEnabled(bool);
arePluginsEnabled()143         bool arePluginsEnabled() const { return m_arePluginsEnabled; }
144 
145         void setDatabasesEnabled(bool);
databasesEnabled()146         bool databasesEnabled() const { return m_databasesEnabled; }
147 
148         void setLocalStorageEnabled(bool);
localStorageEnabled()149         bool localStorageEnabled() const { return m_localStorageEnabled; }
150 
151         void setSessionStorageEnabled(bool);
sessionStorageEnabled()152         bool sessionStorageEnabled() const { return m_sessionStorageEnabled; }
153 
154         void setPrivateBrowsingEnabled(bool);
privateBrowsingEnabled()155         bool privateBrowsingEnabled() const { return m_privateBrowsingEnabled; }
156 
157         void setCaretBrowsingEnabled(bool);
caretBrowsingEnabled()158         bool caretBrowsingEnabled() const { return m_caretBrowsingEnabled; }
159 
160         void setDefaultTextEncodingName(const String&);
defaultTextEncodingName()161         const String& defaultTextEncodingName() const { return m_defaultTextEncodingName; }
162 
163         void setUsesEncodingDetector(bool);
usesEncodingDetector()164         bool usesEncodingDetector() const { return m_usesEncodingDetector; }
165 
166         void setUserStyleSheetLocation(const KURL&);
userStyleSheetLocation()167         const KURL& userStyleSheetLocation() const { return m_userStyleSheetLocation; }
168 
169         void setShouldPrintBackgrounds(bool);
shouldPrintBackgrounds()170         bool shouldPrintBackgrounds() const { return m_shouldPrintBackgrounds; }
171 
172         void setTextAreasAreResizable(bool);
textAreasAreResizable()173         bool textAreasAreResizable() const { return m_textAreasAreResizable; }
174 
175         void setEditableLinkBehavior(EditableLinkBehavior);
editableLinkBehavior()176         EditableLinkBehavior editableLinkBehavior() const { return m_editableLinkBehavior; }
177 
178         void setTextDirectionSubmenuInclusionBehavior(TextDirectionSubmenuInclusionBehavior);
textDirectionSubmenuInclusionBehavior()179         TextDirectionSubmenuInclusionBehavior textDirectionSubmenuInclusionBehavior() const { return m_textDirectionSubmenuInclusionBehavior; }
180 
181 #if ENABLE(DASHBOARD_SUPPORT)
182         void setUsesDashboardBackwardCompatibilityMode(bool);
usesDashboardBackwardCompatibilityMode()183         bool usesDashboardBackwardCompatibilityMode() const { return m_usesDashboardBackwardCompatibilityMode; }
184 #endif
185 
186         void setNeedsAdobeFrameReloadingQuirk(bool);
needsAcrobatFrameReloadingQuirk()187         bool needsAcrobatFrameReloadingQuirk() const { return m_needsAdobeFrameReloadingQuirk; }
188 
189         void setNeedsKeyboardEventDisambiguationQuirks(bool);
needsKeyboardEventDisambiguationQuirks()190         bool needsKeyboardEventDisambiguationQuirks() const { return m_needsKeyboardEventDisambiguationQuirks; }
191 
192         void setTreatsAnyTextCSSLinkAsStylesheet(bool);
treatsAnyTextCSSLinkAsStylesheet()193         bool treatsAnyTextCSSLinkAsStylesheet() const { return m_treatsAnyTextCSSLinkAsStylesheet; }
194 
195         void setNeedsLeopardMailQuirks(bool);
needsLeopardMailQuirks()196         bool needsLeopardMailQuirks() const { return m_needsLeopardMailQuirks; }
197 
198         void setNeedsTigerMailQuirks(bool);
needsTigerMailQuirks()199         bool needsTigerMailQuirks() const { return m_needsTigerMailQuirks; }
200 
201         void setDOMPasteAllowed(bool);
isDOMPasteAllowed()202         bool isDOMPasteAllowed() const { return m_isDOMPasteAllowed; }
203 
204         void setUsesPageCache(bool);
usesPageCache()205         bool usesPageCache() const { return m_usesPageCache; }
206 
207         void setShrinksStandaloneImagesToFit(bool);
shrinksStandaloneImagesToFit()208         bool shrinksStandaloneImagesToFit() const { return m_shrinksStandaloneImagesToFit; }
209 
210         void setShowsURLsInToolTips(bool);
showsURLsInToolTips()211         bool showsURLsInToolTips() const { return m_showsURLsInToolTips; }
212 
213         void setFTPDirectoryTemplatePath(const String&);
ftpDirectoryTemplatePath()214         const String& ftpDirectoryTemplatePath() const { return m_ftpDirectoryTemplatePath; }
215 
216         void setForceFTPDirectoryListings(bool);
forceFTPDirectoryListings()217         bool forceFTPDirectoryListings() const { return m_forceFTPDirectoryListings; }
218 
219         void setDeveloperExtrasEnabled(bool);
developerExtrasEnabled()220         bool developerExtrasEnabled() const { return m_developerExtrasEnabled; }
221 
222 #ifdef ANDROID_META_SUPPORT
223         void resetMetadataSettings();
224         void setMetadataSettings(const String& key, const String& value);
225 
viewportWidth()226         int viewportWidth() const { return m_viewport_width; }
viewportHeight()227         int viewportHeight() const { return m_viewport_height; }
viewportInitialScale()228         int viewportInitialScale() const { return m_viewport_initial_scale; }
viewportMinimumScale()229         int viewportMinimumScale() const { return m_viewport_minimum_scale; }
viewportMaximumScale()230         int viewportMaximumScale() const { return m_viewport_maximum_scale; }
viewportUserScalable()231         bool viewportUserScalable() const { return m_viewport_user_scalable; }
viewportTargetDensityDpi()232         int viewportTargetDensityDpi() const { return m_viewport_target_densitydpi; }
formatDetectionAddress()233         bool formatDetectionAddress() const { return m_format_detection_address; }
formatDetectionEmail()234         bool formatDetectionEmail() const { return m_format_detection_email; }
formatDetectionTelephone()235         bool formatDetectionTelephone() const { return m_format_detection_telephone; }
236 #endif
237 #ifdef ANDROID_MULTIPLE_WINDOWS
supportMultipleWindows()238         bool supportMultipleWindows() const { return m_supportMultipleWindows; }
setSupportMultipleWindows(bool support)239         void setSupportMultipleWindows(bool support) { m_supportMultipleWindows = support; }
240 #endif
241         void setAuthorAndUserStylesEnabled(bool);
authorAndUserStylesEnabled()242         bool authorAndUserStylesEnabled() const { return m_authorAndUserStylesEnabled; }
243 
244         void setFontRenderingMode(FontRenderingMode mode);
245         FontRenderingMode fontRenderingMode() const;
246 
247         void setNeedsSiteSpecificQuirks(bool);
needsSiteSpecificQuirks()248         bool needsSiteSpecificQuirks() const { return m_needsSiteSpecificQuirks; }
249 
250         void setWebArchiveDebugModeEnabled(bool);
webArchiveDebugModeEnabled()251         bool webArchiveDebugModeEnabled() const { return m_webArchiveDebugModeEnabled; }
252 
253         void setLocalFileContentSniffingEnabled(bool);
localFileContentSniffingEnabled()254         bool localFileContentSniffingEnabled() const { return m_localFileContentSniffingEnabled; }
255 
256         void setLocalStorageDatabasePath(const String&);
localStorageDatabasePath()257         const String& localStorageDatabasePath() const { return m_localStorageDatabasePath; }
258 
259         void setApplicationChromeMode(bool);
inApplicationChromeMode()260         bool inApplicationChromeMode() const { return m_inApplicationChromeMode; }
261 
262         void setOfflineWebApplicationCacheEnabled(bool);
offlineWebApplicationCacheEnabled()263         bool offlineWebApplicationCacheEnabled() const { return m_offlineWebApplicationCacheEnabled; }
264 
265         void setShouldPaintCustomScrollbars(bool);
shouldPaintCustomScrollbars()266         bool shouldPaintCustomScrollbars() const { return m_shouldPaintCustomScrollbars; }
267 
268         void setZoomsTextOnly(bool);
zoomsTextOnly()269         bool zoomsTextOnly() const { return m_zoomsTextOnly; }
270 
271         void setEnforceCSSMIMETypeInStrictMode(bool);
enforceCSSMIMETypeInStrictMode()272         bool enforceCSSMIMETypeInStrictMode() { return m_enforceCSSMIMETypeInStrictMode; }
273 
setMaximumDecodedImageSize(size_t size)274         void setMaximumDecodedImageSize(size_t size) { m_maximumDecodedImageSize = size; }
maximumDecodedImageSize()275         size_t maximumDecodedImageSize() const { return m_maximumDecodedImageSize; }
276 
277 #if USE(SAFARI_THEME)
278         // Windows debugging pref (global) for switching between the Aqua look and a native windows look.
279         static void setShouldPaintNativeControls(bool);
shouldPaintNativeControls()280         static bool shouldPaintNativeControls() { return gShouldPaintNativeControls; }
281 #endif
282 
283         void setAllowScriptsToCloseWindows(bool);
allowScriptsToCloseWindows()284         bool allowScriptsToCloseWindows() const { return m_allowScriptsToCloseWindows; }
285 
setEditingBehavior(EditingBehavior behavior)286         void setEditingBehavior(EditingBehavior behavior) { m_editingBehavior = behavior; }
editingBehavior()287         EditingBehavior editingBehavior() const { return static_cast<EditingBehavior>(m_editingBehavior); }
288 
289         void setDownloadableBinaryFontsEnabled(bool);
downloadableBinaryFontsEnabled()290         bool downloadableBinaryFontsEnabled() const { return m_downloadableBinaryFontsEnabled; }
291 
292         void setXSSAuditorEnabled(bool);
xssAuditorEnabled()293         bool xssAuditorEnabled() const { return m_xssAuditorEnabled; }
294 
295         void setAcceleratedCompositingEnabled(bool);
acceleratedCompositingEnabled()296         bool acceleratedCompositingEnabled() const { return m_acceleratedCompositingEnabled; }
297 
298     private:
299         Page* m_page;
300 
301         String m_defaultTextEncodingName;
302         String m_ftpDirectoryTemplatePath;
303         String m_localStorageDatabasePath;
304         KURL m_userStyleSheetLocation;
305         AtomicString m_standardFontFamily;
306         AtomicString m_fixedFontFamily;
307         AtomicString m_serifFontFamily;
308         AtomicString m_sansSerifFontFamily;
309         AtomicString m_cursiveFontFamily;
310         AtomicString m_fantasyFontFamily;
311 #ifdef ANDROID_LAYOUT
312         LayoutAlgorithm m_layoutAlgorithm;
313 #endif
314         EditableLinkBehavior m_editableLinkBehavior;
315         TextDirectionSubmenuInclusionBehavior m_textDirectionSubmenuInclusionBehavior;
316         int m_minimumFontSize;
317         int m_minimumLogicalFontSize;
318         int m_defaultFontSize;
319         int m_defaultFixedFontSize;
320 #ifdef ANDROID_META_SUPPORT
321         // range is from 200 to 10,000. 0 is a special value means device-width.
322         // default is -1, which means undefined.
323         int m_viewport_width;
324         // range is from 223 to 10,000. 0 is a special value means device-height
325         // default is -1, which means undefined.
326         int m_viewport_height;
327         // range is from 1 to 1000 in percent. default is 0, which means undefined.
328         int m_viewport_initial_scale;
329         // range is from 1 to 1000 in percent. default is 0, which means undefined.
330         int m_viewport_minimum_scale;
331         // range is from 1 to 1000 in percent. default is 0, which means undefined.
332         int m_viewport_maximum_scale;
333         // default is yes
334         bool m_viewport_user_scalable : 1;
335         // range is from 70 to 400. 0 is a special value means device-dpi
336         // default is -1, which means undefined.
337         int m_viewport_target_densitydpi;
338         // default is yes
339         bool m_format_detection_telephone : 1;
340         // default is yes
341         bool m_format_detection_address : 1;
342         // default is yes
343         bool m_format_detection_email : 1;
344 #endif
345 #ifdef ANDROID_LAYOUT
346         bool m_useWideViewport : 1;
347 #endif
348 #ifdef ANDROID_MULTIPLE_WINDOWS
349         bool m_supportMultipleWindows : 1;
350 #endif
351 #ifdef ANDROID_BLOCK_NETWORK_IMAGE
352         bool m_blockNetworkImage : 1;
353 #endif
354         size_t m_maximumDecodedImageSize;
355         bool m_isJavaEnabled : 1;
356         bool m_loadsImagesAutomatically : 1;
357         bool m_privateBrowsingEnabled : 1;
358         bool m_caretBrowsingEnabled : 1;
359         bool m_arePluginsEnabled : 1;
360         bool m_databasesEnabled : 1;
361         bool m_localStorageEnabled : 1;
362         bool m_sessionStorageEnabled : 1;
363         bool m_isJavaScriptEnabled : 1;
364         bool m_isWebSecurityEnabled : 1;
365         bool m_allowUniversalAccessFromFileURLs: 1;
366         bool m_javaScriptCanOpenWindowsAutomatically : 1;
367         bool m_shouldPrintBackgrounds : 1;
368         bool m_textAreasAreResizable : 1;
369 #if ENABLE(DASHBOARD_SUPPORT)
370         bool m_usesDashboardBackwardCompatibilityMode : 1;
371 #endif
372         bool m_needsAdobeFrameReloadingQuirk : 1;
373         bool m_needsKeyboardEventDisambiguationQuirks : 1;
374         bool m_treatsAnyTextCSSLinkAsStylesheet : 1;
375         bool m_needsLeopardMailQuirks : 1;
376         bool m_needsTigerMailQuirks : 1;
377         bool m_isDOMPasteAllowed : 1;
378         bool m_shrinksStandaloneImagesToFit : 1;
379         bool m_usesPageCache: 1;
380         bool m_showsURLsInToolTips : 1;
381         bool m_forceFTPDirectoryListings : 1;
382         bool m_developerExtrasEnabled : 1;
383         bool m_authorAndUserStylesEnabled : 1;
384         bool m_needsSiteSpecificQuirks : 1;
385         unsigned m_fontRenderingMode : 1;
386         bool m_webArchiveDebugModeEnabled : 1;
387         bool m_localFileContentSniffingEnabled : 1;
388         bool m_inApplicationChromeMode : 1;
389         bool m_offlineWebApplicationCacheEnabled : 1;
390         bool m_shouldPaintCustomScrollbars : 1;
391         bool m_zoomsTextOnly : 1;
392         bool m_enforceCSSMIMETypeInStrictMode : 1;
393         bool m_usesEncodingDetector : 1;
394         bool m_allowScriptsToCloseWindows : 1;
395         unsigned m_editingBehavior : 1;
396         bool m_downloadableBinaryFontsEnabled : 1;
397         bool m_xssAuditorEnabled : 1;
398         bool m_acceleratedCompositingEnabled : 1;
399 
400 #if USE(SAFARI_THEME)
401         static bool gShouldPaintNativeControls;
402 #endif
403     };
404 
405 } // namespace WebCore
406 
407 #endif // Settings_h
408