initial import
[vuplus_webkit] / Source / WebKit / chromium / src / WebSettingsImpl.cpp
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, UScriptCode script)
58 {
59     m_settings->setStandardFontFamily(font, script);
60 }
61
62 void WebSettingsImpl::setFixedFontFamily(const WebString& font, UScriptCode script)
63 {
64     m_settings->setFixedFontFamily(font, script);
65 }
66
67 void WebSettingsImpl::setSerifFontFamily(const WebString& font, UScriptCode script)
68 {
69     m_settings->setSerifFontFamily(font, script);
70 }
71
72 void WebSettingsImpl::setSansSerifFontFamily(const WebString& font, UScriptCode script)
73 {
74     m_settings->setSansSerifFontFamily(font, script);
75 }
76
77 void WebSettingsImpl::setCursiveFontFamily(const WebString& font, UScriptCode script)
78 {
79     m_settings->setCursiveFontFamily(font, script);
80 }
81
82 void WebSettingsImpl::setFantasyFontFamily(const WebString& font, UScriptCode script)
83 {
84     m_settings->setFantasyFontFamily(font, script);
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::setDNSPrefetchingEnabled(bool enabled)
218 {
219     m_settings->setDNSPrefetchingEnabled(enabled);
220 }
221
222 void WebSettingsImpl::setLocalStorageEnabled(bool enabled)
223 {
224     m_settings->setLocalStorageEnabled(enabled);
225 }
226
227 void WebSettingsImpl::setEditableLinkBehaviorNeverLive()
228 {
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);
233 }
234
235 void WebSettingsImpl::setFrameFlatteningEnabled(bool enabled)
236 {
237     m_settings->setFrameFlatteningEnabled(enabled);
238 }
239
240 void WebSettingsImpl::setFontRenderingModeNormal()
241 {
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);
246 }
247
248 void WebSettingsImpl::setShouldPaintCustomScrollbars(bool enabled)
249 {
250     m_settings->setShouldPaintCustomScrollbars(enabled);
251 }
252
253 void WebSettingsImpl::setAllowUniversalAccessFromFileURLs(bool allow)
254 {
255     m_settings->setAllowUniversalAccessFromFileURLs(allow);
256 }
257
258 void WebSettingsImpl::setAllowFileAccessFromFileURLs(bool allow)
259 {
260     m_settings->setAllowFileAccessFromFileURLs(allow);
261 }
262
263 void WebSettingsImpl::setTextDirectionSubmenuInclusionBehaviorNeverIncluded()
264 {
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);
269 }
270
271 void WebSettingsImpl::setOfflineWebApplicationCacheEnabled(bool enabled)
272 {
273     m_settings->setOfflineWebApplicationCacheEnabled(enabled);
274 }
275
276 void WebSettingsImpl::setWebAudioEnabled(bool enabled)
277 {
278     m_settings->setWebAudioEnabled(enabled);
279 }
280
281 void WebSettingsImpl::setExperimentalWebGLEnabled(bool enabled)
282 {
283     m_settings->setWebGLEnabled(enabled);
284 }
285
286 void WebSettingsImpl::setOpenGLMultisamplingEnabled(bool enabled)
287 {
288     m_settings->setOpenGLMultisamplingEnabled(enabled);
289 }
290
291 void WebSettingsImpl::setShowDebugBorders(bool show)
292 {
293     m_settings->setShowDebugBorders(show);
294 }
295
296 void WebSettingsImpl::setShowFPSCounter(bool show)
297 {
298     m_showFPSCounter = show;
299 }
300
301 void WebSettingsImpl::setShowPlatformLayerTree(bool show)
302 {
303     m_showPlatformLayerTree = show;
304 }
305
306 void WebSettingsImpl::setEditingBehavior(EditingBehavior behavior)
307 {
308     m_settings->setEditingBehaviorType(static_cast<WebCore::EditingBehaviorType>(behavior));
309 }
310
311 void WebSettingsImpl::setAcceleratedCompositingEnabled(bool enabled)
312 {
313     m_settings->setAcceleratedCompositingEnabled(enabled);
314 }
315
316 void WebSettingsImpl::setForceCompositingMode(bool enabled)
317 {
318     m_settings->setForceCompositingMode(enabled);
319 }
320
321 void WebSettingsImpl::setCompositeToTextureEnabled(bool enabled)
322 {
323     m_compositeToTextureEnabled = enabled;
324 }
325
326 void WebSettingsImpl::setAcceleratedCompositingFor3DTransformsEnabled(bool enabled)
327 {
328     m_settings->setAcceleratedCompositingFor3DTransformsEnabled(enabled);
329 }
330
331 void WebSettingsImpl::setAcceleratedCompositingForVideoEnabled(bool enabled)
332 {
333     m_settings->setAcceleratedCompositingForVideoEnabled(enabled);
334 }
335
336 void WebSettingsImpl::setAcceleratedCompositingForPluginsEnabled(bool enabled)
337 {
338     m_settings->setAcceleratedCompositingForPluginsEnabled(enabled);
339 }
340
341 void WebSettingsImpl::setAcceleratedCompositingForCanvasEnabled(bool enabled)
342 {
343     m_settings->setAcceleratedCompositingForCanvasEnabled(enabled);
344 }
345
346 void WebSettingsImpl::setAcceleratedCompositingForAnimationEnabled(bool enabled)
347 {
348     m_settings->setAcceleratedCompositingForAnimationEnabled(enabled);
349 }
350
351 void WebSettingsImpl::setAcceleratedDrawingEnabled(bool enabled)
352 {
353     m_settings->setAcceleratedDrawingEnabled(enabled);
354 }
355
356 void WebSettingsImpl::setAccelerated2dCanvasEnabled(bool enabled)
357 {
358     m_settings->setAccelerated2dCanvasEnabled(enabled);
359 }
360
361 void WebSettingsImpl::setLegacyAccelerated2dCanvasEnabled(bool enabled)
362 {
363     m_settings->setLegacyAccelerated2dCanvasEnabled(enabled);
364 }
365
366 void WebSettingsImpl::setMinimumAccelerated2dCanvasSize(int numPixels)
367 {
368     m_settings->setMinimumAccelerated2dCanvasSize(numPixels);
369 }
370
371 void WebSettingsImpl::setMemoryInfoEnabled(bool enabled)
372 {
373     m_settings->setMemoryInfoEnabled(enabled);
374 }
375
376 void WebSettingsImpl::setHyperlinkAuditingEnabled(bool enabled)
377 {
378     m_settings->setHyperlinkAuditingEnabled(enabled);
379 }
380
381 void WebSettingsImpl::setAsynchronousSpellCheckingEnabled(bool enabled)
382 {
383     m_settings->setAsynchronousSpellCheckingEnabled(enabled);
384 }
385
386 void WebSettingsImpl::setCaretBrowsingEnabled(bool enabled)
387 {
388     m_settings->setCaretBrowsingEnabled(enabled);
389 }
390
391 void WebSettingsImpl::setInteractiveFormValidationEnabled(bool enabled)
392 {
393     m_settings->setInteractiveFormValidationEnabled(enabled);
394 }
395
396 void WebSettingsImpl::setValidationMessageTimerMagnification(int newValue)
397 {
398     m_settings->setValidationMessageTimerMagnification(newValue);
399 }
400
401 void WebSettingsImpl::setMinimumTimerInterval(double interval)
402 {
403     m_settings->setMinDOMTimerInterval(interval);
404 }
405
406 void WebSettingsImpl::setFullScreenEnabled(bool enabled)
407 {
408 #if ENABLE(FULLSCREEN_API)
409     m_settings->setFullScreenEnabled(enabled);
410 #else
411     UNUSED_PARAM(enabled);
412 #endif
413 }
414
415 void WebSettingsImpl::setAllowDisplayOfInsecureContent(bool enabled)
416 {
417     m_settings->setAllowDisplayOfInsecureContent(enabled);
418 }
419
420 void WebSettingsImpl::setAllowRunningOfInsecureContent(bool enabled)
421 {
422     m_settings->setAllowRunningOfInsecureContent(enabled);
423 }
424
425 void WebSettingsImpl::setShouldPrintBackgrounds(bool enabled)
426 {
427     m_settings->setShouldPrintBackgrounds(enabled);
428 }
429
430 void WebSettingsImpl::setEnableScrollAnimator(bool enabled)
431 {
432 #if ENABLE(SMOOTH_SCROLLING)
433     m_settings->setEnableScrollAnimator(enabled);
434 #else
435     UNUSED_PARAM(enabled);
436 #endif
437 }
438
439 void WebSettingsImpl::setHixie76WebSocketProtocolEnabled(bool enabled)
440 {
441 #if ENABLE(WEB_SOCKETS)
442     m_settings->setUseHixie76WebSocketProtocol(enabled);
443 #else
444     UNUSED_PARAM(enabled);
445 #endif
446 }
447
448 } // namespace WebKit