1 /* 2 * Copyright (C) 2003, 2006, 2007, 2008 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 "FontDescription.h" 32 #include "KURL.h" 33 34 namespace WebCore { 35 36 class Page; 37 38 enum EditableLinkBehavior { 39 EditableLinkDefaultBehavior = 0, 40 EditableLinkAlwaysLive, 41 EditableLinkOnlyLiveWithShiftKey, 42 EditableLinkLiveWhenNotFocused, 43 EditableLinkNeverLive 44 }; 45 46 enum TextDirectionSubmenuInclusionBehavior { 47 TextDirectionSubmenuNeverIncluded, 48 TextDirectionSubmenuAutomaticallyIncluded, 49 TextDirectionSubmenuAlwaysIncluded 50 }; 51 52 class Settings { 53 public: 54 Settings(Page*); 55 56 #ifdef ANDROID_LAYOUT 57 // FIXME: How do we determine the margins other than guessing? 58 #define ANDROID_SSR_MARGIN_PADDING 3 59 #define ANDROID_FCTS_MARGIN_PADDING 10 60 61 enum LayoutAlgorithm { 62 kLayoutNormal, 63 kLayoutSSR, 64 kLayoutFitColumnToScreen 65 }; 66 #endif 67 void setStandardFontFamily(const AtomicString&); standardFontFamily()68 const AtomicString& standardFontFamily() const { return m_standardFontFamily; } 69 70 void setFixedFontFamily(const AtomicString&); fixedFontFamily()71 const AtomicString& fixedFontFamily() const { return m_fixedFontFamily; } 72 73 #ifdef ANDROID_LAYOUT layoutAlgorithm()74 LayoutAlgorithm layoutAlgorithm() const { return m_layoutAlgorithm; } setLayoutAlgorithm(LayoutAlgorithm algorithm)75 void setLayoutAlgorithm(LayoutAlgorithm algorithm) { m_layoutAlgorithm = algorithm; } 76 useWideViewport()77 bool useWideViewport() const { return m_useWideViewport; } setUseWideViewport(bool use)78 void setUseWideViewport(bool use) { m_useWideViewport = use; } 79 #endif 80 81 void setSerifFontFamily(const AtomicString&); serifFontFamily()82 const AtomicString& serifFontFamily() const { return m_serifFontFamily; } 83 84 void setSansSerifFontFamily(const AtomicString&); sansSerifFontFamily()85 const AtomicString& sansSerifFontFamily() const { return m_sansSerifFontFamily; } 86 87 void setCursiveFontFamily(const AtomicString&); cursiveFontFamily()88 const AtomicString& cursiveFontFamily() const { return m_cursiveFontFamily; } 89 90 void setFantasyFontFamily(const AtomicString&); fantasyFontFamily()91 const AtomicString& fantasyFontFamily() const { return m_fantasyFontFamily; } 92 93 void setMinimumFontSize(int); minimumFontSize()94 int minimumFontSize() const { return m_minimumFontSize; } 95 96 void setMinimumLogicalFontSize(int); minimumLogicalFontSize()97 int minimumLogicalFontSize() const { return m_minimumLogicalFontSize; } 98 99 void setDefaultFontSize(int); defaultFontSize()100 int defaultFontSize() const { return m_defaultFontSize; } 101 102 void setDefaultFixedFontSize(int); defaultFixedFontSize()103 int defaultFixedFontSize() const { return m_defaultFixedFontSize; } 104 105 void setLoadsImagesAutomatically(bool); loadsImagesAutomatically()106 bool loadsImagesAutomatically() const { return m_loadsImagesAutomatically; } 107 108 #ifdef ANDROID_BLOCK_NETWORK_IMAGE 109 void setBlockNetworkImage(bool); blockNetworkImage()110 bool blockNetworkImage() const { return m_blockNetworkImage; } 111 #endif 112 void setJavaScriptEnabled(bool); isJavaScriptEnabled()113 bool isJavaScriptEnabled() const { return m_isJavaScriptEnabled; } 114 115 void setJavaScriptCanOpenWindowsAutomatically(bool); JavaScriptCanOpenWindowsAutomatically()116 bool JavaScriptCanOpenWindowsAutomatically() const { return m_javaScriptCanOpenWindowsAutomatically; } 117 118 void setJavaEnabled(bool); isJavaEnabled()119 bool isJavaEnabled() const { return m_isJavaEnabled; } 120 121 void setPluginsEnabled(bool); arePluginsEnabled()122 bool arePluginsEnabled() const { return m_arePluginsEnabled; } 123 124 #ifdef ANDROID_PLUGINS 125 void setPluginsPath(const String& pluginsPath); pluginsPath()126 const String& pluginsPath() const { return m_pluginsPath; } 127 #endif 128 129 void setDatabasesEnabled(bool); databasesEnabled()130 bool databasesEnabled() const { return m_databasesEnabled; } 131 132 void setLocalStorageEnabled(bool); localStorageEnabled()133 bool localStorageEnabled() const { return m_localStorageEnabled; } 134 135 void setPrivateBrowsingEnabled(bool); privateBrowsingEnabled()136 bool privateBrowsingEnabled() const { return m_privateBrowsingEnabled; } 137 138 void setDefaultTextEncodingName(const String&); defaultTextEncodingName()139 const String& defaultTextEncodingName() const { return m_defaultTextEncodingName; } 140 141 void setUserStyleSheetLocation(const KURL&); userStyleSheetLocation()142 const KURL& userStyleSheetLocation() const { return m_userStyleSheetLocation; } 143 144 void setShouldPrintBackgrounds(bool); shouldPrintBackgrounds()145 bool shouldPrintBackgrounds() const { return m_shouldPrintBackgrounds; } 146 147 void setTextAreasAreResizable(bool); textAreasAreResizable()148 bool textAreasAreResizable() const { return m_textAreasAreResizable; } 149 150 void setEditableLinkBehavior(EditableLinkBehavior); editableLinkBehavior()151 EditableLinkBehavior editableLinkBehavior() const { return m_editableLinkBehavior; } 152 153 void setTextDirectionSubmenuInclusionBehavior(TextDirectionSubmenuInclusionBehavior); textDirectionSubmenuInclusionBehavior()154 TextDirectionSubmenuInclusionBehavior textDirectionSubmenuInclusionBehavior() const { return m_textDirectionSubmenuInclusionBehavior; } 155 156 #if ENABLE(DASHBOARD_SUPPORT) 157 void setUsesDashboardBackwardCompatibilityMode(bool); usesDashboardBackwardCompatibilityMode()158 bool usesDashboardBackwardCompatibilityMode() const { return m_usesDashboardBackwardCompatibilityMode; } 159 #endif 160 161 void setNeedsAdobeFrameReloadingQuirk(bool); needsAcrobatFrameReloadingQuirk()162 bool needsAcrobatFrameReloadingQuirk() const { return m_needsAdobeFrameReloadingQuirk; } 163 164 void setNeedsKeyboardEventDisambiguationQuirks(bool); needsKeyboardEventDisambiguationQuirks()165 bool needsKeyboardEventDisambiguationQuirks() const { return m_needsKeyboardEventDisambiguationQuirks; } 166 167 void setDOMPasteAllowed(bool); isDOMPasteAllowed()168 bool isDOMPasteAllowed() const { return m_isDOMPasteAllowed; } 169 170 void setUsesPageCache(bool); usesPageCache()171 bool usesPageCache() const { return m_usesPageCache; } 172 173 void setShrinksStandaloneImagesToFit(bool); shrinksStandaloneImagesToFit()174 bool shrinksStandaloneImagesToFit() const { return m_shrinksStandaloneImagesToFit; } 175 176 void setShowsURLsInToolTips(bool); showsURLsInToolTips()177 bool showsURLsInToolTips() const { return m_showsURLsInToolTips; } 178 179 void setFTPDirectoryTemplatePath(const String&); ftpDirectoryTemplatePath()180 const String& ftpDirectoryTemplatePath() const { return m_ftpDirectoryTemplatePath; } 181 182 void setForceFTPDirectoryListings(bool); forceFTPDirectoryListings()183 bool forceFTPDirectoryListings() const { return m_forceFTPDirectoryListings; } 184 185 void setDeveloperExtrasEnabled(bool); developerExtrasEnabled()186 bool developerExtrasEnabled() const { return m_developerExtrasEnabled; } 187 188 #ifdef ANDROID_META_SUPPORT 189 void resetMetadataSettings(); 190 void setMetadataSettings(const String& key, const String& value); 191 viewportWidth()192 int viewportWidth() const { return m_viewport_width; } viewportHeight()193 int viewportHeight() const { return m_viewport_height; } viewportInitialScale()194 int viewportInitialScale() const { return m_viewport_initial_scale; } viewportMinimumScale()195 int viewportMinimumScale() const { return m_viewport_minimum_scale; } viewportMaximumScale()196 int viewportMaximumScale() const { return m_viewport_maximum_scale; } viewportUserScalable()197 bool viewportUserScalable() const { return m_viewport_user_scalable; } formatDetectionAddress()198 bool formatDetectionAddress() const { return m_format_detection_address; } formatDetectionEmail()199 bool formatDetectionEmail() const { return m_format_detection_email; } formatDetectionTelephone()200 bool formatDetectionTelephone() const { return m_format_detection_telephone; } 201 #endif 202 #ifdef ANDROID_MULTIPLE_WINDOWS supportMultipleWindows()203 bool supportMultipleWindows() const { return m_supportMultipleWindows; } setSupportMultipleWindows(bool support)204 void setSupportMultipleWindows(bool support) { m_supportMultipleWindows = support; } 205 #endif 206 void setAuthorAndUserStylesEnabled(bool); authorAndUserStylesEnabled()207 bool authorAndUserStylesEnabled() const { return m_authorAndUserStylesEnabled; } 208 209 void setFontRenderingMode(FontRenderingMode mode); 210 FontRenderingMode fontRenderingMode() const; 211 212 void setNeedsSiteSpecificQuirks(bool); needsSiteSpecificQuirks()213 bool needsSiteSpecificQuirks() const { return m_needsSiteSpecificQuirks; } 214 215 void setWebArchiveDebugModeEnabled(bool); webArchiveDebugModeEnabled()216 bool webArchiveDebugModeEnabled() const { return m_webArchiveDebugModeEnabled; } 217 218 void setLocalStorageDatabasePath(const String&); localStorageDatabasePath()219 const String& localStorageDatabasePath() const { return m_localStorageDatabasePath; } 220 221 void disableRangeMutationForOldAppleMail(bool); rangeMutationDisabledForOldAppleMail()222 bool rangeMutationDisabledForOldAppleMail() const { return m_rangeMutationDisabledForOldAppleMail; } 223 224 void setApplicationChromeMode(bool); inApplicationChromeMode()225 bool inApplicationChromeMode() const { return m_inApplicationChromeMode; } 226 227 void setOfflineWebApplicationCacheEnabled(bool); offlineWebApplicationCacheEnabled()228 bool offlineWebApplicationCacheEnabled() const { return m_offlineWebApplicationCacheEnabled; } 229 230 void setShouldPaintCustomScrollbars(bool); shouldPaintCustomScrollbars()231 bool shouldPaintCustomScrollbars() const { return m_shouldPaintCustomScrollbars; } 232 233 void setZoomsTextOnly(bool); zoomsTextOnly()234 bool zoomsTextOnly() const { return m_zoomsTextOnly; } 235 236 void setEnforceCSSMIMETypeInStrictMode(bool); enforceCSSMIMETypeInStrictMode()237 bool enforceCSSMIMETypeInStrictMode() { return m_enforceCSSMIMETypeInStrictMode; } 238 setMaximumDecodedImageSize(size_t size)239 void setMaximumDecodedImageSize(size_t size) { m_maximumDecodedImageSize = size; } maximumDecodedImageSize()240 size_t maximumDecodedImageSize() const { return m_maximumDecodedImageSize; } 241 242 #if USE(SAFARI_THEME) 243 // Windows debugging pref (global) for switching between the Aqua look and a native windows look. 244 static void setShouldPaintNativeControls(bool); shouldPaintNativeControls()245 static bool shouldPaintNativeControls() { return gShouldPaintNativeControls; } 246 #endif 247 248 void setNeedsIChatMemoryCacheCallsQuirk(bool); needsIChatMemoryCacheCallsQuirk()249 bool needsIChatMemoryCacheCallsQuirk() const { return m_needsIChatMemoryCacheCallsQuirk; } 250 251 private: 252 Page* m_page; 253 254 String m_defaultTextEncodingName; 255 String m_ftpDirectoryTemplatePath; 256 #ifdef ANDROID_PLUGINS 257 String m_pluginsPath; 258 #endif 259 String m_localStorageDatabasePath; 260 KURL m_userStyleSheetLocation; 261 AtomicString m_standardFontFamily; 262 AtomicString m_fixedFontFamily; 263 AtomicString m_serifFontFamily; 264 AtomicString m_sansSerifFontFamily; 265 AtomicString m_cursiveFontFamily; 266 AtomicString m_fantasyFontFamily; 267 #ifdef ANDROID_LAYOUT 268 LayoutAlgorithm m_layoutAlgorithm; 269 #endif 270 EditableLinkBehavior m_editableLinkBehavior; 271 TextDirectionSubmenuInclusionBehavior m_textDirectionSubmenuInclusionBehavior; 272 int m_minimumFontSize; 273 int m_minimumLogicalFontSize; 274 int m_defaultFontSize; 275 int m_defaultFixedFontSize; 276 #ifdef ANDROID_META_SUPPORT 277 // range is from 200 to 10,000. 0 is a special value means device-width. 278 // default is -1, which means undefined. 279 int m_viewport_width; 280 // range is from 223 to 10,000. 0 is a special value means device-height 281 // default is -1, which means undefined. 282 int m_viewport_height; 283 // range is from 1 to 1000 in percent. default is 0, which means undefined. 284 int m_viewport_initial_scale; 285 // range is from 1 to 1000 in percent. default is 0, which means undefined. 286 int m_viewport_minimum_scale; 287 // range is from 1 to 1000 in percent. default is 0, which means undefined. 288 int m_viewport_maximum_scale; 289 // default is yes 290 bool m_viewport_user_scalable : 1; 291 // default is yes 292 bool m_format_detection_telephone : 1; 293 // default is yes 294 bool m_format_detection_address : 1; 295 // default is yes 296 bool m_format_detection_email : 1; 297 #endif 298 #ifdef ANDROID_LAYOUT 299 bool m_useWideViewport : 1; 300 #endif 301 #ifdef ANDROID_MULTIPLE_WINDOWS 302 bool m_supportMultipleWindows : 1; 303 #endif 304 #ifdef ANDROID_BLOCK_NETWORK_IMAGE 305 bool m_blockNetworkImage : 1; 306 #endif 307 bool m_isJavaEnabled : 1; 308 bool m_loadsImagesAutomatically : 1; 309 bool m_privateBrowsingEnabled : 1; 310 bool m_arePluginsEnabled : 1; 311 bool m_databasesEnabled : 1; 312 bool m_localStorageEnabled : 1; 313 bool m_isJavaScriptEnabled : 1; 314 bool m_javaScriptCanOpenWindowsAutomatically : 1; 315 bool m_shouldPrintBackgrounds : 1; 316 bool m_textAreasAreResizable : 1; 317 #if ENABLE(DASHBOARD_SUPPORT) 318 bool m_usesDashboardBackwardCompatibilityMode : 1; 319 #endif 320 bool m_needsAdobeFrameReloadingQuirk : 1; 321 bool m_needsKeyboardEventDisambiguationQuirks : 1; 322 bool m_isDOMPasteAllowed : 1; 323 bool m_shrinksStandaloneImagesToFit : 1; 324 bool m_usesPageCache: 1; 325 bool m_showsURLsInToolTips : 1; 326 bool m_forceFTPDirectoryListings : 1; 327 bool m_developerExtrasEnabled : 1; 328 bool m_authorAndUserStylesEnabled : 1; 329 bool m_needsSiteSpecificQuirks : 1; 330 unsigned m_fontRenderingMode : 1; 331 bool m_webArchiveDebugModeEnabled : 1; 332 bool m_inApplicationChromeMode : 1; 333 bool m_offlineWebApplicationCacheEnabled : 1; 334 bool m_rangeMutationDisabledForOldAppleMail : 1; 335 bool m_shouldPaintCustomScrollbars : 1; 336 bool m_zoomsTextOnly : 1; 337 bool m_enforceCSSMIMETypeInStrictMode : 1; 338 size_t m_maximumDecodedImageSize; 339 bool m_needsIChatMemoryCacheCallsQuirk : 1; 340 341 #if USE(SAFARI_THEME) 342 static bool gShouldPaintNativeControls; 343 #endif 344 }; 345 346 } // namespace WebCore 347 348 #endif // Settings_h 349