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 39#if defined(OS_WIN) 40#include "RenderThemeChromiumWin.h" 41#endif 42 43using namespace WebCore; 44 45namespace WebKit { 46 47WebSettingsImpl::WebSettingsImpl(Settings* settings) 48 : m_settings(settings) 49{ 50 ASSERT(settings); 51} 52 53void WebSettingsImpl::setStandardFontFamily(const WebString& font) 54{ 55 m_settings->setStandardFontFamily(font); 56} 57 58void WebSettingsImpl::setFixedFontFamily(const WebString& font) 59{ 60 m_settings->setFixedFontFamily((String)font); 61} 62 63void WebSettingsImpl::setSerifFontFamily(const WebString& font) 64{ 65 m_settings->setSerifFontFamily((String)font); 66} 67 68void WebSettingsImpl::setSansSerifFontFamily(const WebString& font) 69{ 70 m_settings->setSansSerifFontFamily((String)font); 71} 72 73void WebSettingsImpl::setCursiveFontFamily(const WebString& font) 74{ 75 m_settings->setCursiveFontFamily((String)font); 76} 77 78void WebSettingsImpl::setFantasyFontFamily(const WebString& font) 79{ 80 m_settings->setFantasyFontFamily((String)font); 81} 82 83void WebSettingsImpl::setDefaultFontSize(int size) 84{ 85 m_settings->setDefaultFontSize(size); 86#if defined(OS_WIN) 87 // RenderTheme is a singleton that needs to know the default font size to 88 // draw some form controls. We let it know each time the size changes. 89 WebCore::RenderThemeChromiumWin::setDefaultFontSize(size); 90#endif 91} 92 93void WebSettingsImpl::setDefaultFixedFontSize(int size) 94{ 95 m_settings->setDefaultFixedFontSize(size); 96} 97 98void WebSettingsImpl::setMinimumFontSize(int size) 99{ 100 m_settings->setMinimumFontSize(size); 101} 102 103void WebSettingsImpl::setMinimumLogicalFontSize(int size) 104{ 105 m_settings->setMinimumLogicalFontSize(size); 106} 107 108void WebSettingsImpl::setDefaultTextEncodingName(const WebString& encoding) 109{ 110 m_settings->setDefaultTextEncodingName((String)encoding); 111} 112 113void WebSettingsImpl::setJavaScriptEnabled(bool enabled) 114{ 115 m_settings->setJavaScriptEnabled(enabled); 116} 117 118void WebSettingsImpl::setWebSecurityEnabled(bool enabled) 119{ 120 m_settings->setWebSecurityEnabled(enabled); 121} 122 123void WebSettingsImpl::setJavaScriptCanOpenWindowsAutomatically(bool canOpenWindows) 124{ 125 m_settings->setJavaScriptCanOpenWindowsAutomatically(canOpenWindows); 126} 127 128void WebSettingsImpl::setLoadsImagesAutomatically(bool loadsImagesAutomatically) 129{ 130 m_settings->setLoadsImagesAutomatically(loadsImagesAutomatically); 131} 132 133void WebSettingsImpl::setImagesEnabled(bool enabled) 134{ 135 m_settings->setImagesEnabled(enabled); 136} 137 138void WebSettingsImpl::setPluginsEnabled(bool enabled) 139{ 140 m_settings->setPluginsEnabled(enabled); 141} 142 143void WebSettingsImpl::setDOMPasteAllowed(bool enabled) 144{ 145 m_settings->setDOMPasteAllowed(enabled); 146} 147 148void WebSettingsImpl::setDeveloperExtrasEnabled(bool enabled) 149{ 150 m_settings->setDeveloperExtrasEnabled(enabled); 151} 152 153void WebSettingsImpl::setNeedsSiteSpecificQuirks(bool enabled) 154{ 155 m_settings->setNeedsSiteSpecificQuirks(enabled); 156} 157 158void WebSettingsImpl::setShrinksStandaloneImagesToFit(bool shrinkImages) 159{ 160 m_settings->setShrinksStandaloneImagesToFit(shrinkImages); 161} 162 163void WebSettingsImpl::setUsesEncodingDetector(bool usesDetector) 164{ 165 m_settings->setUsesEncodingDetector(usesDetector); 166} 167 168void WebSettingsImpl::setTextAreasAreResizable(bool areResizable) 169{ 170 m_settings->setTextAreasAreResizable(areResizable); 171} 172 173void WebSettingsImpl::setJavaEnabled(bool enabled) 174{ 175 m_settings->setJavaEnabled(enabled); 176} 177 178void WebSettingsImpl::setAllowScriptsToCloseWindows(bool allow) 179{ 180 m_settings->setAllowScriptsToCloseWindows(allow); 181} 182 183void WebSettingsImpl::setUserStyleSheetLocation(const WebURL& location) 184{ 185 m_settings->setUserStyleSheetLocation(location); 186} 187 188void WebSettingsImpl::setUsesPageCache(bool usesPageCache) 189{ 190 m_settings->setUsesPageCache(usesPageCache); 191} 192 193void WebSettingsImpl::setDownloadableBinaryFontsEnabled(bool enabled) 194{ 195 m_settings->setDownloadableBinaryFontsEnabled(enabled); 196} 197 198void WebSettingsImpl::setXSSAuditorEnabled(bool enabled) 199{ 200 m_settings->setXSSAuditorEnabled(enabled); 201} 202 203void WebSettingsImpl::setLocalStorageEnabled(bool enabled) 204{ 205 m_settings->setLocalStorageEnabled(enabled); 206} 207 208void WebSettingsImpl::setEditableLinkBehaviorNeverLive() 209{ 210 // FIXME: If you ever need more behaviors than this, then we should probably 211 // define an enum in WebSettings.h and have a switch statement that 212 // translates. Until then, this is probably fine, though. 213 m_settings->setEditableLinkBehavior(WebCore::EditableLinkNeverLive); 214} 215 216void WebSettingsImpl::setFontRenderingModeNormal() 217{ 218 // FIXME: If you ever need more behaviors than this, then we should probably 219 // define an enum in WebSettings.h and have a switch statement that 220 // translates. Until then, this is probably fine, though. 221 m_settings->setFontRenderingMode(WebCore::NormalRenderingMode); 222} 223 224void WebSettingsImpl::setShouldPaintCustomScrollbars(bool enabled) 225{ 226 m_settings->setShouldPaintCustomScrollbars(enabled); 227} 228 229void WebSettingsImpl::setDatabasesEnabled(bool enabled) 230{ 231 m_settings->setDatabasesEnabled(enabled); 232} 233 234void WebSettingsImpl::setAllowUniversalAccessFromFileURLs(bool allow) 235{ 236 m_settings->setAllowUniversalAccessFromFileURLs(allow); 237} 238 239void WebSettingsImpl::setTextDirectionSubmenuInclusionBehaviorNeverIncluded() 240{ 241 // FIXME: If you ever need more behaviors than this, then we should probably 242 // define an enum in WebSettings.h and have a switch statement that 243 // translates. Until then, this is probably fine, though. 244 m_settings->setTextDirectionSubmenuInclusionBehavior(WebCore::TextDirectionSubmenuNeverIncluded); 245} 246 247void WebSettingsImpl::setOfflineWebApplicationCacheEnabled(bool enabled) 248{ 249 m_settings->setOfflineWebApplicationCacheEnabled(enabled); 250} 251 252void WebSettingsImpl::setExperimentalWebGLEnabled(bool enabled) 253{ 254 m_settings->setWebGLEnabled(enabled); 255} 256 257void WebSettingsImpl::setGeolocationEnabled(bool enabled) 258{ 259 m_settings->setGeolocationEnabled(enabled); 260} 261 262} // namespace WebKit 263