1 /* 2 * Copyright (C) 2009 Google 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 are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 #include "config.h" 32 #include "WebSettingsImpl.h" 33 34 #include "FontRenderingMode.h" 35 #include "Settings.h" 36 #include "WebString.h" 37 #include "WebURL.h" 38 #include <wtf/UnusedParam.h> 39 40 #if defined(OS_WIN) 41 #include "RenderThemeChromiumWin.h" 42 #endif 43 44 using namespace WebCore; 45 46 namespace WebKit { 47 48 WebSettingsImpl::WebSettingsImpl(Settings* settings) 49 : m_settings(settings) 50 , m_compositeToTextureEnabled(false) 51 , m_showFPSCounter(false) 52 , m_showPlatformLayerTree(false) 53 { 54 ASSERT(settings); 55 } 56 57 void WebSettingsImpl::setStandardFontFamily(const WebString& font) 58 { 59 m_settings->setStandardFontFamily(font); 60 } 61 62 void WebSettingsImpl::setFixedFontFamily(const WebString& font) 63 { 64 m_settings->setFixedFontFamily((String)font); 65 } 66 67 void WebSettingsImpl::setSerifFontFamily(const WebString& font) 68 { 69 m_settings->setSerifFontFamily((String)font); 70 } 71 72 void WebSettingsImpl::setSansSerifFontFamily(const WebString& font) 73 { 74 m_settings->setSansSerifFontFamily((String)font); 75 } 76 77 void WebSettingsImpl::setCursiveFontFamily(const WebString& font) 78 { 79 m_settings->setCursiveFontFamily((String)font); 80 } 81 82 void WebSettingsImpl::setFantasyFontFamily(const WebString& font) 83 { 84 m_settings->setFantasyFontFamily((String)font); 85 } 86 87 void WebSettingsImpl::setDefaultFontSize(int size) 88 { 89 m_settings->setDefaultFontSize(size); 90 #if defined(OS_WIN) 91 // RenderTheme is a singleton that needs to know the default font size to 92 // draw some form controls. We let it know each time the size changes. 93 WebCore::RenderThemeChromiumWin::setDefaultFontSize(size); 94 #endif 95 } 96 97 void WebSettingsImpl::setDefaultFixedFontSize(int size) 98 { 99 m_settings->setDefaultFixedFontSize(size); 100 } 101 102 void WebSettingsImpl::setMinimumFontSize(int size) 103 { 104 m_settings->setMinimumFontSize(size); 105 } 106 107 void WebSettingsImpl::setMinimumLogicalFontSize(int size) 108 { 109 m_settings->setMinimumLogicalFontSize(size); 110 } 111 112 void WebSettingsImpl::setDefaultTextEncodingName(const WebString& encoding) 113 { 114 m_settings->setDefaultTextEncodingName((String)encoding); 115 } 116 117 void WebSettingsImpl::setJavaScriptEnabled(bool enabled) 118 { 119 m_settings->setJavaScriptEnabled(enabled); 120 } 121 122 void WebSettingsImpl::setWebSecurityEnabled(bool enabled) 123 { 124 m_settings->setWebSecurityEnabled(enabled); 125 } 126 127 void WebSettingsImpl::setJavaScriptCanOpenWindowsAutomatically(bool canOpenWindows) 128 { 129 m_settings->setJavaScriptCanOpenWindowsAutomatically(canOpenWindows); 130 } 131 132 void WebSettingsImpl::setLoadsImagesAutomatically(bool loadsImagesAutomatically) 133 { 134 m_settings->setLoadsImagesAutomatically(loadsImagesAutomatically); 135 } 136 137 void WebSettingsImpl::setImagesEnabled(bool enabled) 138 { 139 m_settings->setImagesEnabled(enabled); 140 } 141 142 void WebSettingsImpl::setPluginsEnabled(bool enabled) 143 { 144 m_settings->setPluginsEnabled(enabled); 145 } 146 147 void WebSettingsImpl::setDOMPasteAllowed(bool enabled) 148 { 149 m_settings->setDOMPasteAllowed(enabled); 150 } 151 152 void WebSettingsImpl::setDeveloperExtrasEnabled(bool enabled) 153 { 154 m_settings->setDeveloperExtrasEnabled(enabled); 155 } 156 157 void WebSettingsImpl::setNeedsSiteSpecificQuirks(bool enabled) 158 { 159 m_settings->setNeedsSiteSpecificQuirks(enabled); 160 } 161 162 void WebSettingsImpl::setShrinksStandaloneImagesToFit(bool shrinkImages) 163 { 164 m_settings->setShrinksStandaloneImagesToFit(shrinkImages); 165 } 166 167 void WebSettingsImpl::setUsesEncodingDetector(bool usesDetector) 168 { 169 m_settings->setUsesEncodingDetector(usesDetector); 170 } 171 172 void WebSettingsImpl::setTextAreasAreResizable(bool areResizable) 173 { 174 m_settings->setTextAreasAreResizable(areResizable); 175 } 176 177 void WebSettingsImpl::setJavaEnabled(bool enabled) 178 { 179 m_settings->setJavaEnabled(enabled); 180 } 181 182 void WebSettingsImpl::setAllowScriptsToCloseWindows(bool allow) 183 { 184 m_settings->setAllowScriptsToCloseWindows(allow); 185 } 186 187 void WebSettingsImpl::setUserStyleSheetLocation(const WebURL& location) 188 { 189 m_settings->setUserStyleSheetLocation(location); 190 } 191 192 void WebSettingsImpl::setAuthorAndUserStylesEnabled(bool enabled) 193 { 194 m_settings->setAuthorAndUserStylesEnabled(enabled); 195 } 196 197 void WebSettingsImpl::setUsesPageCache(bool usesPageCache) 198 { 199 m_settings->setUsesPageCache(usesPageCache); 200 } 201 202 void WebSettingsImpl::setDownloadableBinaryFontsEnabled(bool enabled) 203 { 204 m_settings->setDownloadableBinaryFontsEnabled(enabled); 205 } 206 207 void WebSettingsImpl::setJavaScriptCanAccessClipboard(bool enabled) 208 { 209 m_settings->setJavaScriptCanAccessClipboard(enabled); 210 } 211 212 void WebSettingsImpl::setXSSAuditorEnabled(bool enabled) 213 { 214 m_settings->setXSSAuditorEnabled(enabled); 215 } 216 217 void WebSettingsImpl::setLocalStorageEnabled(bool enabled) 218 { 219 m_settings->setLocalStorageEnabled(enabled); 220 } 221 222 void WebSettingsImpl::setEditableLinkBehaviorNeverLive() 223 { 224 // FIXME: If you ever need more behaviors than this, then we should probably 225 // define an enum in WebSettings.h and have a switch statement that 226 // translates. Until then, this is probably fine, though. 227 m_settings->setEditableLinkBehavior(WebCore::EditableLinkNeverLive); 228 } 229 230 void WebSettingsImpl::setFrameFlatteningEnabled(bool enabled) 231 { 232 m_settings->setFrameFlatteningEnabled(enabled); 233 } 234 235 void WebSettingsImpl::setFontRenderingModeNormal() 236 { 237 // FIXME: If you ever need more behaviors than this, then we should probably 238 // define an enum in WebSettings.h and have a switch statement that 239 // translates. Until then, this is probably fine, though. 240 m_settings->setFontRenderingMode(WebCore::NormalRenderingMode); 241 } 242 243 void WebSettingsImpl::setShouldPaintCustomScrollbars(bool enabled) 244 { 245 m_settings->setShouldPaintCustomScrollbars(enabled); 246 } 247 248 void WebSettingsImpl::setAllowUniversalAccessFromFileURLs(bool allow) 249 { 250 m_settings->setAllowUniversalAccessFromFileURLs(allow); 251 } 252 253 void WebSettingsImpl::setAllowFileAccessFromFileURLs(bool allow) 254 { 255 m_settings->setAllowFileAccessFromFileURLs(allow); 256 } 257 258 void WebSettingsImpl::setTextDirectionSubmenuInclusionBehaviorNeverIncluded() 259 { 260 // FIXME: If you ever need more behaviors than this, then we should probably 261 // define an enum in WebSettings.h and have a switch statement that 262 // translates. Until then, this is probably fine, though. 263 m_settings->setTextDirectionSubmenuInclusionBehavior(WebCore::TextDirectionSubmenuNeverIncluded); 264 } 265 266 void WebSettingsImpl::setOfflineWebApplicationCacheEnabled(bool enabled) 267 { 268 m_settings->setOfflineWebApplicationCacheEnabled(enabled); 269 } 270 271 void WebSettingsImpl::setWebAudioEnabled(bool enabled) 272 { 273 m_settings->setWebAudioEnabled(enabled); 274 } 275 276 void WebSettingsImpl::setExperimentalWebGLEnabled(bool enabled) 277 { 278 m_settings->setWebGLEnabled(enabled); 279 } 280 281 void WebSettingsImpl::setOpenGLMultisamplingEnabled(bool enabled) 282 { 283 m_settings->setOpenGLMultisamplingEnabled(enabled); 284 } 285 286 void WebSettingsImpl::setShowDebugBorders(bool show) 287 { 288 m_settings->setShowDebugBorders(show); 289 } 290 291 void WebSettingsImpl::setShowFPSCounter(bool show) 292 { 293 m_showFPSCounter = show; 294 } 295 296 void WebSettingsImpl::setShowPlatformLayerTree(bool show) 297 { 298 m_showPlatformLayerTree = show; 299 } 300 301 void WebSettingsImpl::setEditingBehavior(EditingBehavior behavior) 302 { 303 m_settings->setEditingBehaviorType(static_cast<WebCore::EditingBehaviorType>(behavior)); 304 } 305 306 void WebSettingsImpl::setAcceleratedCompositingEnabled(bool enabled) 307 { 308 m_settings->setAcceleratedCompositingEnabled(enabled); 309 } 310 311 void WebSettingsImpl::setForceCompositingMode(bool enabled) 312 { 313 m_settings->setForceCompositingMode(enabled); 314 } 315 316 void WebSettingsImpl::setCompositeToTextureEnabled(bool enabled) 317 { 318 m_compositeToTextureEnabled = enabled; 319 } 320 321 void WebSettingsImpl::setAcceleratedCompositingFor3DTransformsEnabled(bool enabled) 322 { 323 m_settings->setAcceleratedCompositingFor3DTransformsEnabled(enabled); 324 } 325 326 void WebSettingsImpl::setAcceleratedCompositingForVideoEnabled(bool enabled) 327 { 328 m_settings->setAcceleratedCompositingForVideoEnabled(enabled); 329 } 330 331 void WebSettingsImpl::setAcceleratedCompositingForPluginsEnabled(bool enabled) 332 { 333 m_settings->setAcceleratedCompositingForPluginsEnabled(enabled); 334 } 335 336 void WebSettingsImpl::setAcceleratedCompositingForCanvasEnabled(bool enabled) 337 { 338 m_settings->setAcceleratedCompositingForCanvasEnabled(enabled); 339 } 340 341 void WebSettingsImpl::setAcceleratedCompositingForAnimationEnabled(bool enabled) 342 { 343 m_settings->setAcceleratedCompositingForAnimationEnabled(enabled); 344 } 345 346 void WebSettingsImpl::setAcceleratedDrawingEnabled(bool enabled) 347 { 348 m_settings->setAcceleratedDrawingEnabled(enabled); 349 } 350 351 void WebSettingsImpl::setAccelerated2dCanvasEnabled(bool enabled) 352 { 353 m_settings->setAccelerated2dCanvasEnabled(enabled); 354 } 355 356 void WebSettingsImpl::setMemoryInfoEnabled(bool enabled) 357 { 358 m_settings->setMemoryInfoEnabled(enabled); 359 } 360 361 void WebSettingsImpl::setHyperlinkAuditingEnabled(bool enabled) 362 { 363 m_settings->setHyperlinkAuditingEnabled(enabled); 364 } 365 366 void WebSettingsImpl::setAsynchronousSpellCheckingEnabled(bool enabled) 367 { 368 m_settings->setAsynchronousSpellCheckingEnabled(enabled); 369 } 370 371 void WebSettingsImpl::setCaretBrowsingEnabled(bool enabled) 372 { 373 m_settings->setCaretBrowsingEnabled(enabled); 374 } 375 376 void WebSettingsImpl::setInteractiveFormValidationEnabled(bool enabled) 377 { 378 m_settings->setInteractiveFormValidationEnabled(enabled); 379 } 380 381 void WebSettingsImpl::setValidationMessageTimerMagnification(int newValue) 382 { 383 m_settings->setValidationMessageTimerMagnification(newValue); 384 } 385 386 void WebSettingsImpl::setMinimumTimerInterval(double interval) 387 { 388 m_settings->setMinDOMTimerInterval(interval); 389 } 390 391 void WebSettingsImpl::setFullScreenEnabled(bool enabled) 392 { 393 #if ENABLE(FULLSCREEN_API) 394 m_settings->setFullScreenEnabled(enabled); 395 #else 396 UNUSED_PARAM(enabled); 397 #endif 398 } 399 400 } // namespace WebKit 401