2 * Copyright (C) 2009 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
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
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.
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.
32 #include "WebSettingsImpl.h"
34 #include "FontRenderingMode.h"
36 #include "WebString.h"
38 #include <wtf/UnusedParam.h>
41 #include "RenderThemeChromiumWin.h"
44 using namespace WebCore;
48 WebSettingsImpl::WebSettingsImpl(Settings* settings)
49 : m_settings(settings)
50 , m_compositeToTextureEnabled(false)
51 , m_showFPSCounter(false)
52 , m_showPlatformLayerTree(false)
57 void WebSettingsImpl::setStandardFontFamily(const WebString& font, UScriptCode script)
59 m_settings->setStandardFontFamily(font, script);
62 void WebSettingsImpl::setFixedFontFamily(const WebString& font, UScriptCode script)
64 m_settings->setFixedFontFamily(font, script);
67 void WebSettingsImpl::setSerifFontFamily(const WebString& font, UScriptCode script)
69 m_settings->setSerifFontFamily(font, script);
72 void WebSettingsImpl::setSansSerifFontFamily(const WebString& font, UScriptCode script)
74 m_settings->setSansSerifFontFamily(font, script);
77 void WebSettingsImpl::setCursiveFontFamily(const WebString& font, UScriptCode script)
79 m_settings->setCursiveFontFamily(font, script);
82 void WebSettingsImpl::setFantasyFontFamily(const WebString& font, UScriptCode script)
84 m_settings->setFantasyFontFamily(font, script);
87 void WebSettingsImpl::setDefaultFontSize(int size)
89 m_settings->setDefaultFontSize(size);
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);
97 void WebSettingsImpl::setDefaultFixedFontSize(int size)
99 m_settings->setDefaultFixedFontSize(size);
102 void WebSettingsImpl::setMinimumFontSize(int size)
104 m_settings->setMinimumFontSize(size);
107 void WebSettingsImpl::setMinimumLogicalFontSize(int size)
109 m_settings->setMinimumLogicalFontSize(size);
112 void WebSettingsImpl::setDefaultTextEncodingName(const WebString& encoding)
114 m_settings->setDefaultTextEncodingName((String)encoding);
117 void WebSettingsImpl::setJavaScriptEnabled(bool enabled)
119 m_settings->setJavaScriptEnabled(enabled);
122 void WebSettingsImpl::setWebSecurityEnabled(bool enabled)
124 m_settings->setWebSecurityEnabled(enabled);
127 void WebSettingsImpl::setJavaScriptCanOpenWindowsAutomatically(bool canOpenWindows)
129 m_settings->setJavaScriptCanOpenWindowsAutomatically(canOpenWindows);
132 void WebSettingsImpl::setLoadsImagesAutomatically(bool loadsImagesAutomatically)
134 m_settings->setLoadsImagesAutomatically(loadsImagesAutomatically);
137 void WebSettingsImpl::setImagesEnabled(bool enabled)
139 m_settings->setImagesEnabled(enabled);
142 void WebSettingsImpl::setPluginsEnabled(bool enabled)
144 m_settings->setPluginsEnabled(enabled);
147 void WebSettingsImpl::setDOMPasteAllowed(bool enabled)
149 m_settings->setDOMPasteAllowed(enabled);
152 void WebSettingsImpl::setDeveloperExtrasEnabled(bool enabled)
154 m_settings->setDeveloperExtrasEnabled(enabled);
157 void WebSettingsImpl::setNeedsSiteSpecificQuirks(bool enabled)
159 m_settings->setNeedsSiteSpecificQuirks(enabled);
162 void WebSettingsImpl::setShrinksStandaloneImagesToFit(bool shrinkImages)
164 m_settings->setShrinksStandaloneImagesToFit(shrinkImages);
167 void WebSettingsImpl::setUsesEncodingDetector(bool usesDetector)
169 m_settings->setUsesEncodingDetector(usesDetector);
172 void WebSettingsImpl::setTextAreasAreResizable(bool areResizable)
174 m_settings->setTextAreasAreResizable(areResizable);
177 void WebSettingsImpl::setJavaEnabled(bool enabled)
179 m_settings->setJavaEnabled(enabled);
182 void WebSettingsImpl::setAllowScriptsToCloseWindows(bool allow)
184 m_settings->setAllowScriptsToCloseWindows(allow);
187 void WebSettingsImpl::setUserStyleSheetLocation(const WebURL& location)
189 m_settings->setUserStyleSheetLocation(location);
192 void WebSettingsImpl::setAuthorAndUserStylesEnabled(bool enabled)
194 m_settings->setAuthorAndUserStylesEnabled(enabled);
197 void WebSettingsImpl::setUsesPageCache(bool usesPageCache)
199 m_settings->setUsesPageCache(usesPageCache);
202 void WebSettingsImpl::setDownloadableBinaryFontsEnabled(bool enabled)
204 m_settings->setDownloadableBinaryFontsEnabled(enabled);
207 void WebSettingsImpl::setJavaScriptCanAccessClipboard(bool enabled)
209 m_settings->setJavaScriptCanAccessClipboard(enabled);
212 void WebSettingsImpl::setXSSAuditorEnabled(bool enabled)
214 m_settings->setXSSAuditorEnabled(enabled);
217 void WebSettingsImpl::setDNSPrefetchingEnabled(bool enabled)
219 m_settings->setDNSPrefetchingEnabled(enabled);
222 void WebSettingsImpl::setLocalStorageEnabled(bool enabled)
224 m_settings->setLocalStorageEnabled(enabled);
227 void WebSettingsImpl::setEditableLinkBehaviorNeverLive()
229 // FIXME: If you ever need more behaviors than this, then we should probably
230 // define an enum in WebSettings.h and have a switch statement that
231 // translates. Until then, this is probably fine, though.
232 m_settings->setEditableLinkBehavior(WebCore::EditableLinkNeverLive);
235 void WebSettingsImpl::setFrameFlatteningEnabled(bool enabled)
237 m_settings->setFrameFlatteningEnabled(enabled);
240 void WebSettingsImpl::setFontRenderingModeNormal()
242 // FIXME: If you ever need more behaviors than this, then we should probably
243 // define an enum in WebSettings.h and have a switch statement that
244 // translates. Until then, this is probably fine, though.
245 m_settings->setFontRenderingMode(WebCore::NormalRenderingMode);
248 void WebSettingsImpl::setShouldPaintCustomScrollbars(bool enabled)
250 m_settings->setShouldPaintCustomScrollbars(enabled);
253 void WebSettingsImpl::setAllowUniversalAccessFromFileURLs(bool allow)
255 m_settings->setAllowUniversalAccessFromFileURLs(allow);
258 void WebSettingsImpl::setAllowFileAccessFromFileURLs(bool allow)
260 m_settings->setAllowFileAccessFromFileURLs(allow);
263 void WebSettingsImpl::setTextDirectionSubmenuInclusionBehaviorNeverIncluded()
265 // FIXME: If you ever need more behaviors than this, then we should probably
266 // define an enum in WebSettings.h and have a switch statement that
267 // translates. Until then, this is probably fine, though.
268 m_settings->setTextDirectionSubmenuInclusionBehavior(WebCore::TextDirectionSubmenuNeverIncluded);
271 void WebSettingsImpl::setOfflineWebApplicationCacheEnabled(bool enabled)
273 m_settings->setOfflineWebApplicationCacheEnabled(enabled);
276 void WebSettingsImpl::setWebAudioEnabled(bool enabled)
278 m_settings->setWebAudioEnabled(enabled);
281 void WebSettingsImpl::setExperimentalWebGLEnabled(bool enabled)
283 m_settings->setWebGLEnabled(enabled);
286 void WebSettingsImpl::setOpenGLMultisamplingEnabled(bool enabled)
288 m_settings->setOpenGLMultisamplingEnabled(enabled);
291 void WebSettingsImpl::setShowDebugBorders(bool show)
293 m_settings->setShowDebugBorders(show);
296 void WebSettingsImpl::setShowFPSCounter(bool show)
298 m_showFPSCounter = show;
301 void WebSettingsImpl::setShowPlatformLayerTree(bool show)
303 m_showPlatformLayerTree = show;
306 void WebSettingsImpl::setEditingBehavior(EditingBehavior behavior)
308 m_settings->setEditingBehaviorType(static_cast<WebCore::EditingBehaviorType>(behavior));
311 void WebSettingsImpl::setAcceleratedCompositingEnabled(bool enabled)
313 m_settings->setAcceleratedCompositingEnabled(enabled);
316 void WebSettingsImpl::setForceCompositingMode(bool enabled)
318 m_settings->setForceCompositingMode(enabled);
321 void WebSettingsImpl::setCompositeToTextureEnabled(bool enabled)
323 m_compositeToTextureEnabled = enabled;
326 void WebSettingsImpl::setAcceleratedCompositingFor3DTransformsEnabled(bool enabled)
328 m_settings->setAcceleratedCompositingFor3DTransformsEnabled(enabled);
331 void WebSettingsImpl::setAcceleratedCompositingForVideoEnabled(bool enabled)
333 m_settings->setAcceleratedCompositingForVideoEnabled(enabled);
336 void WebSettingsImpl::setAcceleratedCompositingForPluginsEnabled(bool enabled)
338 m_settings->setAcceleratedCompositingForPluginsEnabled(enabled);
341 void WebSettingsImpl::setAcceleratedCompositingForCanvasEnabled(bool enabled)
343 m_settings->setAcceleratedCompositingForCanvasEnabled(enabled);
346 void WebSettingsImpl::setAcceleratedCompositingForAnimationEnabled(bool enabled)
348 m_settings->setAcceleratedCompositingForAnimationEnabled(enabled);
351 void WebSettingsImpl::setAcceleratedDrawingEnabled(bool enabled)
353 m_settings->setAcceleratedDrawingEnabled(enabled);
356 void WebSettingsImpl::setAccelerated2dCanvasEnabled(bool enabled)
358 m_settings->setAccelerated2dCanvasEnabled(enabled);
361 void WebSettingsImpl::setLegacyAccelerated2dCanvasEnabled(bool enabled)
363 m_settings->setLegacyAccelerated2dCanvasEnabled(enabled);
366 void WebSettingsImpl::setMinimumAccelerated2dCanvasSize(int numPixels)
368 m_settings->setMinimumAccelerated2dCanvasSize(numPixels);
371 void WebSettingsImpl::setMemoryInfoEnabled(bool enabled)
373 m_settings->setMemoryInfoEnabled(enabled);
376 void WebSettingsImpl::setHyperlinkAuditingEnabled(bool enabled)
378 m_settings->setHyperlinkAuditingEnabled(enabled);
381 void WebSettingsImpl::setAsynchronousSpellCheckingEnabled(bool enabled)
383 m_settings->setAsynchronousSpellCheckingEnabled(enabled);
386 void WebSettingsImpl::setCaretBrowsingEnabled(bool enabled)
388 m_settings->setCaretBrowsingEnabled(enabled);
391 void WebSettingsImpl::setInteractiveFormValidationEnabled(bool enabled)
393 m_settings->setInteractiveFormValidationEnabled(enabled);
396 void WebSettingsImpl::setValidationMessageTimerMagnification(int newValue)
398 m_settings->setValidationMessageTimerMagnification(newValue);
401 void WebSettingsImpl::setMinimumTimerInterval(double interval)
403 m_settings->setMinDOMTimerInterval(interval);
406 void WebSettingsImpl::setFullScreenEnabled(bool enabled)
408 #if ENABLE(FULLSCREEN_API)
409 m_settings->setFullScreenEnabled(enabled);
411 UNUSED_PARAM(enabled);
415 void WebSettingsImpl::setAllowDisplayOfInsecureContent(bool enabled)
417 m_settings->setAllowDisplayOfInsecureContent(enabled);
420 void WebSettingsImpl::setAllowRunningOfInsecureContent(bool enabled)
422 m_settings->setAllowRunningOfInsecureContent(enabled);
425 void WebSettingsImpl::setShouldPrintBackgrounds(bool enabled)
427 m_settings->setShouldPrintBackgrounds(enabled);
430 void WebSettingsImpl::setEnableScrollAnimator(bool enabled)
432 #if ENABLE(SMOOTH_SCROLLING)
433 m_settings->setEnableScrollAnimator(enabled);
435 UNUSED_PARAM(enabled);
439 void WebSettingsImpl::setHixie76WebSocketProtocolEnabled(bool enabled)
441 #if ENABLE(WEB_SOCKETS)
442 m_settings->setUseHixie76WebSocketProtocol(enabled);
444 UNUSED_PARAM(enabled);
448 } // namespace WebKit