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 43 using namespace WebCore; 44 45 namespace WebKit { 46 47 WebSettingsImpl::WebSettingsImpl(Settings* settings) 48 : m_settings(settings) 49 { 50 ASSERT(settings); 51 } 52 53 void WebSettingsImpl::setStandardFontFamily(const WebString& font) 54 { 55 m_settings->setStandardFontFamily(font); 56 } 57 58 void WebSettingsImpl::setFixedFontFamily(const WebString& font) 59 { 60 m_settings->setFixedFontFamily((String)font); 61 } 62 63 void WebSettingsImpl::setSerifFontFamily(const WebString& font) 64 { 65 m_settings->setSerifFontFamily((String)font); 66 } 67 68 void WebSettingsImpl::setSansSerifFontFamily(const WebString& font) 69 { 70 m_settings->setSansSerifFontFamily((String)font); 71 } 72 73 void WebSettingsImpl::setCursiveFontFamily(const WebString& font) 74 { 75 m_settings->setCursiveFontFamily((String)font); 76 } 77 78 void WebSettingsImpl::setFantasyFontFamily(const WebString& font) 79 { 80 m_settings->setFantasyFontFamily((String)font); 81 } 82 83 void 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 93 void WebSettingsImpl::setDefaultFixedFontSize(int size) 94 { 95 m_settings->setDefaultFixedFontSize(size); 96 } 97 98 void WebSettingsImpl::setMinimumFontSize(int size) 99 { 100 m_settings->setMinimumFontSize(size); 101 } 102 103 void WebSettingsImpl::setMinimumLogicalFontSize(int size) 104 { 105 m_settings->setMinimumLogicalFontSize(size); 106 } 107 108 void WebSettingsImpl::setDefaultTextEncodingName(const WebString& encoding) 109 { 110 m_settings->setDefaultTextEncodingName((String)encoding); 111 } 112 113 void WebSettingsImpl::setJavaScriptEnabled(bool enabled) 114 { 115 m_settings->setJavaScriptEnabled(enabled); 116 } 117 118 void WebSettingsImpl::setWebSecurityEnabled(bool enabled) 119 { 120 m_settings->setWebSecurityEnabled(enabled); 121 } 122 123 void WebSettingsImpl::setJavaScriptCanOpenWindowsAutomatically(bool canOpenWindows) 124 { 125 m_settings->setJavaScriptCanOpenWindowsAutomatically(canOpenWindows); 126 } 127 128 void WebSettingsImpl::setLoadsImagesAutomatically(bool loadsImagesAutomatically) 129 { 130 m_settings->setLoadsImagesAutomatically(loadsImagesAutomatically); 131 } 132 133 void WebSettingsImpl::setImagesEnabled(bool enabled) 134 { 135 m_settings->setImagesEnabled(enabled); 136 } 137 138 void WebSettingsImpl::setPluginsEnabled(bool enabled) 139 { 140 m_settings->setPluginsEnabled(enabled); 141 } 142 143 void WebSettingsImpl::setDOMPasteAllowed(bool enabled) 144 { 145 m_settings->setDOMPasteAllowed(enabled); 146 } 147 148 void WebSettingsImpl::setDeveloperExtrasEnabled(bool enabled) 149 { 150 m_settings->setDeveloperExtrasEnabled(enabled); 151 } 152 153 void WebSettingsImpl::setNeedsSiteSpecificQuirks(bool enabled) 154 { 155 m_settings->setNeedsSiteSpecificQuirks(enabled); 156 } 157 158 void WebSettingsImpl::setShrinksStandaloneImagesToFit(bool shrinkImages) 159 { 160 m_settings->setShrinksStandaloneImagesToFit(shrinkImages); 161 } 162 163 void WebSettingsImpl::setUsesEncodingDetector(bool usesDetector) 164 { 165 m_settings->setUsesEncodingDetector(usesDetector); 166 } 167 168 void WebSettingsImpl::setTextAreasAreResizable(bool areResizable) 169 { 170 m_settings->setTextAreasAreResizable(areResizable); 171 } 172 173 void WebSettingsImpl::setJavaEnabled(bool enabled) 174 { 175 m_settings->setJavaEnabled(enabled); 176 } 177 178 void WebSettingsImpl::setAllowScriptsToCloseWindows(bool allow) 179 { 180 m_settings->setAllowScriptsToCloseWindows(allow); 181 } 182 183 void WebSettingsImpl::setUserStyleSheetLocation(const WebURL& location) 184 { 185 m_settings->setUserStyleSheetLocation(location); 186 } 187 188 void WebSettingsImpl::setUsesPageCache(bool usesPageCache) 189 { 190 m_settings->setUsesPageCache(usesPageCache); 191 } 192 193 void WebSettingsImpl::setDownloadableBinaryFontsEnabled(bool enabled) 194 { 195 m_settings->setDownloadableBinaryFontsEnabled(enabled); 196 } 197 198 void WebSettingsImpl::setXSSAuditorEnabled(bool enabled) 199 { 200 m_settings->setXSSAuditorEnabled(enabled); 201 } 202 203 void WebSettingsImpl::setLocalStorageEnabled(bool enabled) 204 { 205 m_settings->setLocalStorageEnabled(enabled); 206 } 207 208 void 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 216 void 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 224 void WebSettingsImpl::setShouldPaintCustomScrollbars(bool enabled) 225 { 226 m_settings->setShouldPaintCustomScrollbars(enabled); 227 } 228 229 void WebSettingsImpl::setDatabasesEnabled(bool enabled) 230 { 231 m_settings->setDatabasesEnabled(enabled); 232 } 233 234 void WebSettingsImpl::setAllowUniversalAccessFromFileURLs(bool allow) 235 { 236 m_settings->setAllowUniversalAccessFromFileURLs(allow); 237 } 238 239 void 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 247 void WebSettingsImpl::setOfflineWebApplicationCacheEnabled(bool enabled) 248 { 249 m_settings->setOfflineWebApplicationCacheEnabled(enabled); 250 } 251 252 void WebSettingsImpl::setExperimentalWebGLEnabled(bool enabled) 253 { 254 m_settings->setWebGLEnabled(enabled); 255 } 256 257 void WebSettingsImpl::setGeolocationEnabled(bool enabled) 258 { 259 m_settings->setGeolocationEnabled(enabled); 260 } 261 262 } // namespace WebKit 263