1/*
2 * Copyright (C) 2009, 2010, 2011, 2012 Research In Motion Limited. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
17 */
18
19#include "config.h"
20#include "WebSettings.h"
21
22#include "MIMETypeRegistry.h"
23#include "WebSettings_p.h"
24
25#include <BlackBerryPlatformDeviceInfo.h>
26#include <BlackBerryPlatformFontInfo.h>
27#include <BlackBerryPlatformScreen.h>
28#include <BlackBerryPlatformString.h>
29#include <Color.h>
30#include <FloatSize.h>
31#include <PageCache.h>
32#include <ViewportArguments.h>
33#include <wtf/HashSet.h>
34
35namespace BlackBerry {
36namespace WebKit {
37
38DEFINE_STATIC_LOCAL(String, BlackBerryAllowCrossSiteRequests, (ASCIILiteral("BlackBerryAllowCrossSiteRequests")));
39DEFINE_STATIC_LOCAL(String, BlackBerryApplyDeviceScaleFactorInCompositor, (ASCIILiteral("BlackBerryApplyDeviceScaleFactorInCompositor")));
40DEFINE_STATIC_LOCAL(String, BlackBerryAsynchronousSpellChecking, (ASCIILiteral("BlackBerryAsynchronousSpellChecking")));
41DEFINE_STATIC_LOCAL(String, BlackBerryBackgroundColor, (ASCIILiteral("BlackBerryBackgroundColor")));
42DEFINE_STATIC_LOCAL(String, BlackBerryCookiesEnabled, (ASCIILiteral("BlackBerryCookiesEnabled")));
43DEFINE_STATIC_LOCAL(String, BlackBerryDrawBorderWhileLoadingImages, (ASCIILiteral("BlackBerryDrawBorderWhileLoadingImages")));
44DEFINE_STATIC_LOCAL(String, BlackBerryEmailModeEnabled, (ASCIIliteral("BlackBerryEmailModeEnabled")));
45DEFINE_STATIC_LOCAL(String, BlackBerryGetFocusNodeContextEnabled, (ASCIILiteral("BlackBerryGetFocusNodeContextEnabled")));
46DEFINE_STATIC_LOCAL(String, BlackBerryHandlePatternURLs, (ASCIILiteral("BlackBerryHandlePatternURLs")));
47DEFINE_STATIC_LOCAL(String, BlackBerryInitialScale, (ASCIILiteral("BlackBerryInitialScale")));
48DEFINE_STATIC_LOCAL(String, BlackBerryLinksHandledExternallyEnabled, (ASCIILiteral("BlackBerryLinksHandledExternallyEnabled")));
49DEFINE_STATIC_LOCAL(String, BlackBerryMaxPluginInstances, (ASCIILiteral("BlackBerryMaxPluginInstances")));
50DEFINE_STATIC_LOCAL(String, BlackBerryOverScrollColor, (ASCIILiteral("BlackBerryOverScrollColor")));
51DEFINE_STATIC_LOCAL(String, BlackBerryEnableDefaultOverScrollBackground, (ASCIILiteral("BlackBerryEnableDefaultOverScrollBackground")));
52DEFINE_STATIC_LOCAL(String, BlackBerryRenderAnimationsOnScrollOrZoomEnabled, (ASCIILiteral("BlackBerryRenderAnimationsOnScrollOrZoomEnabled")));
53DEFINE_STATIC_LOCAL(String, BlackBerryScrollbarsEnabled, (ASCIILiteral("BlackBerryScrollbarsEnabled")));
54DEFINE_STATIC_LOCAL(String, BlackBerryTextReflowMode, (ASCIILiteral("BlackBerryTextReflowMode")));
55DEFINE_STATIC_LOCAL(String, BlackBerryUseRTLWritingDirection, (ASCIILiteral("BlackBerryUseRTLWritingDirection")));
56DEFINE_STATIC_LOCAL(String, BlackBerryUseWebKitCache, (ASCIILiteral("BlackBerryUseWebKitCache")));
57DEFINE_STATIC_LOCAL(String, BlackBerryUserAgentString, (ASCIILiteral("BlackBerryUserAgentString")));
58DEFINE_STATIC_LOCAL(String, BlackBerryUserScalableEnabled, (ASCIILiteral("BlackBerryUserScalableEnabled")));
59DEFINE_STATIC_LOCAL(String, BlackBerryViewportWidth, (ASCIILiteral("BlackBerryViewportWidth")));
60DEFINE_STATIC_LOCAL(String, BlackBerryZoomToFitOnLoadEnabled, (ASCIILiteral("BlackBerryZoomToFitOnLoadEnabled")));
61DEFINE_STATIC_LOCAL(String, BlackBerryFullScreenVideoCapable, (ASCIILiteral("BlackBerryFullScreenVideoCapable")));
62DEFINE_STATIC_LOCAL(String, BlackBerryCredentialAutofillEnabled, (ASCIILiteral("BlackBerryCredentialAutofillEnabled")));
63DEFINE_STATIC_LOCAL(String, BlackBerryFormAutofillEnabled, (ASCIILiteral("BlackBerryFormAutofillEnabled")));
64DEFINE_STATIC_LOCAL(String, BlackBerryDevicePixelRatio, (ASCIILiteral("BlackBerryDevicePixelRatio")));
65DEFINE_STATIC_LOCAL(String, BlackBerryBackingStoreEnabled, (ASCIILiteral("BlackBerryBackingStoreEnabled")));
66DEFINE_STATIC_LOCAL(String, SpatialNavigationEnabled, (ASCIILiteral("SpatialNavigationEnabled")));
67DEFINE_STATIC_LOCAL(String, WebKitDatabasePath, (ASCIILiteral("WebKitDatabasePath")));
68DEFINE_STATIC_LOCAL(String, WebKitDatabasesEnabled, (ASCIILiteral("WebKitDatabasesEnabled")));
69DEFINE_STATIC_LOCAL(String, WebKitDefaultFixedFontSize, (ASCIILiteral("WebKitDefaultFixedFontSize")));
70DEFINE_STATIC_LOCAL(String, WebKitDefaultFontSize, (ASCIILiteral("WebKitDefaultFontSize")));
71DEFINE_STATIC_LOCAL(String, WebKitDefaultTextEncodingName, (ASCIILiteral("WebKitDefaultTextEncodingName")));
72DEFINE_STATIC_LOCAL(String, WebKitDownloadableBinaryFontsEnabled, (ASCIILiteral("WebKitDownloadableBinaryFontsEnabled")));
73DEFINE_STATIC_LOCAL(String, WebKitFirstScheduledLayoutDelay, (ASCIILiteral("WebKitFirstScheduledLayoutDelay")));
74DEFINE_STATIC_LOCAL(String, WebKitFixedFontFamily, (ASCIILiteral("WebKitFixedFontFamily")));
75DEFINE_STATIC_LOCAL(String, WebKitFrameFlatteningEnabled, (ASCIILiteral("WebKitFrameFlatteningEnabled")));
76DEFINE_STATIC_LOCAL(String, WebKitGeolocationEnabled, (ASCIILiteral("WebKitGeolocationEnabled")));
77DEFINE_STATIC_LOCAL(String, WebKitIndexedDataBasePath, (ASCIILiteral("WebKitIndexedDataBasePath")));
78DEFINE_STATIC_LOCAL(String, WebKitJavaScriptCanOpenWindowsAutomaticallyEnabled, (ASCIILiteral("WebKitJavaScriptCanOpenWindowsAutomaticallyEnabled")));
79DEFINE_STATIC_LOCAL(String, WebKitJavaScriptEnabled, (ASCIILiteral("WebKitJavaScriptEnabled")));
80DEFINE_STATIC_LOCAL(String, WebKitLoadsImagesAutomatically, (ASCIILiteral("WebKitLoadsImagesAutomatically")));
81DEFINE_STATIC_LOCAL(String, WebKitLocalStorageEnabled, (ASCIILiteral("WebKitLocalStorageEnabled")));
82DEFINE_STATIC_LOCAL(String, WebKitLocalStoragePath, (ASCIILiteral("WebKitLocalStoragePath")));
83DEFINE_STATIC_LOCAL(String, WebKitLocalStorageQuota, (ASCIILiteral("WebKitLocalStorageQuota")));
84DEFINE_STATIC_LOCAL(String, WebKitSessionStorageQuota, (ASCIILiteral("WebKitSessionStorageQuota")));
85DEFINE_STATIC_LOCAL(String, WebKitMaximumPagesInCache, (ASCIILiteral("WebKitMaximumPagesInCache")));
86DEFINE_STATIC_LOCAL(String, WebKitMinimumFontSize, (ASCIILiteral("WebKitMinimumFontSize")));
87DEFINE_STATIC_LOCAL(String, WebKitOfflineWebApplicationCacheEnabled, (ASCIILiteral("WebKitOfflineWebApplicationCacheEnabled")));
88DEFINE_STATIC_LOCAL(String, WebKitOfflineWebApplicationCachePath, (ASCIILiteral("WebKitOfflineWebApplicationCachePath")));
89DEFINE_STATIC_LOCAL(String, WebKitPageGroupName, (ASCIILiteral("WebKitPageGroupName")));
90DEFINE_STATIC_LOCAL(String, WebKitPluginsEnabled, (ASCIILiteral("WebKitPluginsEnabled")));
91DEFINE_STATIC_LOCAL(String, WebKitPrivateBrowsingEnabled, (ASCIILiteral("WebKitPrivateBrowsingEnabled")));
92DEFINE_STATIC_LOCAL(String, WebKitDeviceSupportsMouse, (ASCIILiteral("WebKitDeviceSupportsMouse")));
93DEFINE_STATIC_LOCAL(String, WebKitSansSeriffFontFamily, (ASCIILiteral("WebKitSansSeriffFontFamily")));
94DEFINE_STATIC_LOCAL(String, WebKitSeriffFontFamily, (ASCIILiteral("WebKitSeriffFontFamily")));
95DEFINE_STATIC_LOCAL(String, WebKitStandardFontFamily, (ASCIILiteral("WebKitStandardFontFamily")));
96DEFINE_STATIC_LOCAL(String, WebKitUserStyleSheetLocation, (ASCIILiteral("WebKitUserStyleSheetLocation")));
97DEFINE_STATIC_LOCAL(String, WebKitWebSocketsEnabled, (ASCIILiteral("WebKitWebSocketsEnabled")));
98DEFINE_STATIC_LOCAL(String, WebKitXSSAuditorEnabled, (ASCIILiteral("WebKitXSSAuditorEnabled")));
99DEFINE_STATIC_LOCAL(String, WebKitTextAutosizingEnabled, (ASCIILiteral("WebKitTextAutosizingEnabled")));
100
101static HashSet<String>* s_supportedObjectMIMETypes;
102
103WebSettingsPrivate::WebSettingsPrivate()
104    : impl(0)
105    , delegate(0)
106    , sender(0)
107    , copyOnWrite(true)
108{
109}
110
111WebSettings::WebSettings()
112{
113    m_private = new WebSettingsPrivate();
114}
115
116WebSettings::WebSettings(const WebSettings& otherSettings)
117{
118    m_private->impl = otherSettings.m_private->impl;
119}
120
121WebSettings::~WebSettings()
122{
123    if (!m_private->copyOnWrite) {
124        delete m_private->impl;
125        m_private->impl = 0;
126    }
127    delete m_private;
128    m_private = 0;
129}
130
131void WebSettings::setDelegate(WebSettingsDelegate* delegate)
132{
133    m_private->delegate = delegate;
134    m_private->sender = this;
135}
136
137WebSettingsDelegate* WebSettings::delegate()
138{
139    return m_private->delegate;
140}
141
142WebSettings* WebSettings::createFromStandardSettings(WebSettingsDelegate* delegate)
143{
144    WebSettings* settings = new WebSettings();
145    settings->m_private->impl = standardSettings()->m_private->impl;
146    settings->m_private->delegate = delegate;
147    settings->m_private->sender = settings;
148    if (delegate)
149        delegate->didChangeSettings(settings);
150
151    return settings;
152}
153
154WebSettings* WebSettings::standardSettings()
155{
156    static WebSettings *settings = 0;
157    if (settings)
158        return settings;
159
160    settings = new WebSettings;
161    settings->m_private->impl = new WebSettingsPrivate::WebSettingsPrivateImpl();
162    settings->m_private->copyOnWrite = false;
163    settings->m_private->setBoolean(BlackBerryAllowCrossSiteRequests, false);
164    settings->m_private->setUnsigned(BlackBerryBackgroundColor, WebCore::Color::white);
165    settings->m_private->setBoolean(BlackBerryCookiesEnabled, true);
166    settings->m_private->setBoolean(BlackBerryBackingStoreEnabled, true);
167    settings->m_private->setDouble(BlackBerryInitialScale, -1);
168    settings->m_private->setUnsigned(BlackBerryMaxPluginInstances, 1);
169    settings->m_private->setUnsigned(BlackBerryOverScrollColor, WebCore::Color::white);
170    settings->m_private->setBoolean(BlackBerryEnableDefaultOverScrollBackground, true);
171    settings->m_private->setBoolean(BlackBerryScrollbarsEnabled, true);
172
173    // FIXME: We should detect whether we are embedded in a browser or an email client and default to TextReflowEnabledOnlyForBlockZoom and TextReflowEnabled, respectively.
174    settings->m_private->setTextReflowMode(BlackBerryTextReflowMode, TextReflowDisabled);
175
176    settings->m_private->setBoolean(BlackBerryUseWebKitCache, true);
177    settings->m_private->setBoolean(BlackBerryUserScalableEnabled, true);
178    settings->m_private->setBoolean(BlackBerryZoomToFitOnLoadEnabled, true);
179    settings->m_private->setBoolean(BlackBerryFullScreenVideoCapable, false);
180    settings->m_private->setBoolean(BlackBerryCredentialAutofillEnabled, false);
181    settings->m_private->setBoolean(BlackBerryFormAutofillEnabled, false);
182    settings->m_private->setBoolean(BlackBerryAsynchronousSpellChecking, true);
183    settings->m_private->setBoolean(BlackBerryApplyDeviceScaleFactorInCompositor, false);
184
185    if (BlackBerry::Platform::DeviceInfo::instance()->isMobile()) {
186        WebCore::FloatSize currentPPI = Platform::Graphics::Screen::primaryScreen()->pixelsPerInch(-1);
187        int deviceDPI = int(roundf((currentPPI.width() + currentPPI.height()) / 2));
188        settings->m_private->setDouble(BlackBerryDevicePixelRatio, deviceDPI / WebCore::ViewportArguments::deprecatedTargetDPI);
189    } else
190        settings->m_private->setDouble(BlackBerryDevicePixelRatio, 1);
191
192    settings->m_private->setInteger(WebKitDefaultFontSize, 16);
193    settings->m_private->setInteger(WebKitDefaultFixedFontSize, 13);
194    settings->m_private->setString(WebKitDefaultTextEncodingName, "iso-8859-1");
195    settings->m_private->setBoolean(WebKitDownloadableBinaryFontsEnabled, true);
196    settings->m_private->setInteger(WebKitFirstScheduledLayoutDelay, 250); // Match Document::cLayoutScheduleThreshold.
197    settings->m_private->setBoolean(WebKitJavaScriptEnabled, true);
198    settings->m_private->setBoolean(WebKitLoadsImagesAutomatically, true);
199    settings->m_private->setUnsignedLongLong(WebKitLocalStorageQuota, 5 * 1024 * 1024);
200    settings->m_private->setUnsignedLongLong(WebKitSessionStorageQuota, 5 * 1024 * 1024);
201    settings->m_private->setInteger(WebKitMaximumPagesInCache, 0);
202    settings->m_private->setInteger(WebKitMinimumFontSize, 8);
203    settings->m_private->setBoolean(WebKitWebSocketsEnabled, true);
204    settings->m_private->setBoolean(WebKitTextAutosizingEnabled, false);
205
206    settings->m_private->setString(WebKitFixedFontFamily, BlackBerry::Platform::FontInfo::instance()->fontFamily(BlackBerry::Platform::String::fromAscii("-webkit-monospace"), BlackBerry::Platform::String::emptyString()));
207    settings->m_private->setString(WebKitSansSeriffFontFamily, BlackBerry::Platform::FontInfo::instance()->fontFamily(BlackBerry::Platform::String::fromAscii("-webkit-sans-serif"), BlackBerry::Platform::String::emptyString()));
208    settings->m_private->setString(WebKitSeriffFontFamily, BlackBerry::Platform::FontInfo::instance()->fontFamily(BlackBerry::Platform::String::fromAscii("-webkit-serif"), BlackBerry::Platform::String::emptyString()));
209    settings->m_private->setString(WebKitStandardFontFamily, BlackBerry::Platform::FontInfo::instance()->fontFamily(BlackBerry::Platform::String::fromAscii("-webkit-standard"), BlackBerry::Platform::String::emptyString()));
210
211    return settings;
212}
213
214void WebSettings::addSupportedObjectPluginMIMEType(const BlackBerry::Platform::String& type)
215{
216    if (!s_supportedObjectMIMETypes)
217        s_supportedObjectMIMETypes = new HashSet<String>;
218
219    s_supportedObjectMIMETypes->add(type);
220}
221
222bool WebSettings::isSupportedObjectMIMEType(const BlackBerry::Platform::String& mimeType)
223{
224    if (mimeType.empty())
225        return false;
226
227    if (!s_supportedObjectMIMETypes)
228        return false;
229
230    return s_supportedObjectMIMETypes->contains(MIMETypeRegistry::getNormalizedMIMEType(mimeType));
231}
232
233bool WebSettings::xssAuditorEnabled() const
234{
235    return m_private->getBoolean(WebKitXSSAuditorEnabled);
236}
237
238void WebSettings::setXSSAuditorEnabled(bool enabled)
239{
240    return m_private->setBoolean(WebKitXSSAuditorEnabled, enabled);
241}
242
243bool WebSettings::loadsImagesAutomatically() const
244{
245    return m_private->getBoolean(WebKitLoadsImagesAutomatically);
246}
247
248void WebSettings::setLoadsImagesAutomatically(bool enabled)
249{
250    m_private->setBoolean(WebKitLoadsImagesAutomatically, enabled);
251}
252
253bool WebSettings::downloadableBinaryFontsEnabled() const
254{
255    return m_private->getBoolean(WebKitDownloadableBinaryFontsEnabled);
256}
257
258void WebSettings::setDownloadableBinaryFontsEnabled(bool enabled)
259{
260    return m_private->setBoolean(WebKitDownloadableBinaryFontsEnabled, enabled);
261}
262
263bool WebSettings::shouldDrawBorderWhileLoadingImages() const
264{
265    return m_private->getBoolean(BlackBerryDrawBorderWhileLoadingImages);
266}
267
268void WebSettings::setShouldDrawBorderWhileLoadingImages(bool enabled)
269{
270    m_private->setBoolean(BlackBerryDrawBorderWhileLoadingImages, enabled);
271}
272
273bool WebSettings::isJavaScriptEnabled() const
274{
275    return m_private->getBoolean(WebKitJavaScriptEnabled);
276}
277
278void WebSettings::setJavaScriptEnabled(bool enabled)
279{
280    m_private->setBoolean(WebKitJavaScriptEnabled, enabled);
281}
282
283bool WebSettings::isPrivateBrowsingEnabled() const
284{
285    return m_private->getBoolean(WebKitPrivateBrowsingEnabled);
286}
287
288void WebSettings::setPrivateBrowsingEnabled(bool enabled)
289{
290    m_private->setBoolean(WebKitPrivateBrowsingEnabled, enabled);
291}
292
293bool WebSettings::deviceSupportsMouse() const
294{
295    return m_private->getBoolean(WebKitDeviceSupportsMouse);
296}
297
298void WebSettings::setDeviceSupportsMouse(bool enabled)
299{
300    m_private->setBoolean(WebKitDeviceSupportsMouse, enabled);
301}
302
303int WebSettings::defaultFixedFontSize() const
304{
305    return m_private->getInteger(WebKitDefaultFixedFontSize);
306}
307
308void WebSettings::setDefaultFixedFontSize(int defaultFixedFontSize)
309{
310    m_private->setInteger(WebKitDefaultFixedFontSize, defaultFixedFontSize);
311}
312
313int WebSettings::defaultFontSize() const
314{
315    return m_private->getInteger(WebKitDefaultFontSize);
316}
317
318void WebSettings::setDefaultFontSize(int defaultFontSize)
319{
320    m_private->setInteger(WebKitDefaultFontSize, defaultFontSize);
321}
322
323int WebSettings::minimumFontSize() const
324{
325    return m_private->getInteger(WebKitMinimumFontSize);
326}
327
328void WebSettings::setMinimumFontSize(int minimumFontSize)
329{
330    m_private->setInteger(WebKitMinimumFontSize, minimumFontSize);
331}
332
333BlackBerry::Platform::String WebSettings::serifFontFamily() const
334{
335    return m_private->getString(WebKitSeriffFontFamily);
336}
337
338void WebSettings::setSerifFontFamily(const BlackBerry::Platform::String& seriffFontFamily)
339{
340    m_private->setString(WebKitSeriffFontFamily, seriffFontFamily);
341}
342
343BlackBerry::Platform::String WebSettings::fixedFontFamily() const
344{
345    return m_private->getString(WebKitFixedFontFamily);
346}
347
348void WebSettings::setFixedFontFamily(const BlackBerry::Platform::String& fixedFontFamily)
349{
350    m_private->setString(WebKitFixedFontFamily, fixedFontFamily);
351}
352
353BlackBerry::Platform::String WebSettings::sansSerifFontFamily() const
354{
355    return m_private->getString(WebKitSansSeriffFontFamily);
356}
357
358void WebSettings::setSansSerifFontFamily(const BlackBerry::Platform::String& sansSeriffFontFamily)
359{
360    m_private->setString(WebKitSansSeriffFontFamily, sansSeriffFontFamily);
361}
362
363BlackBerry::Platform::String WebSettings::standardFontFamily() const
364{
365    return m_private->getString(WebKitStandardFontFamily);
366}
367
368void WebSettings::setStandardFontFamily(const BlackBerry::Platform::String& standardFontFamily)
369{
370    m_private->setString(WebKitStandardFontFamily, standardFontFamily);
371}
372
373BlackBerry::Platform::String WebSettings::userAgentString() const
374{
375    return m_private->getString(BlackBerryUserAgentString);
376}
377
378void WebSettings::setUserAgentString(const BlackBerry::Platform::String& userAgentString)
379{
380    m_private->setString(BlackBerryUserAgentString, userAgentString);
381}
382
383BlackBerry::Platform::String WebSettings::defaultTextEncodingName() const
384{
385    return m_private->getString(WebKitDefaultTextEncodingName);
386}
387
388void WebSettings::setDefaultTextEncodingName(const BlackBerry::Platform::String& defaultTextEncodingName)
389{
390    m_private->setString(WebKitDefaultTextEncodingName, defaultTextEncodingName);
391}
392
393bool WebSettings::isZoomToFitOnLoad() const
394{
395    return m_private->getBoolean(BlackBerryZoomToFitOnLoadEnabled);
396}
397
398void WebSettings::setZoomToFitOnLoad(bool enabled)
399{
400    m_private->setBoolean(BlackBerryZoomToFitOnLoadEnabled, enabled);
401}
402
403WebSettings::TextReflowMode WebSettings::textReflowMode() const
404{
405    return m_private->getTextReflowMode(BlackBerryTextReflowMode);
406}
407
408void WebSettings::setTextReflowMode(TextReflowMode textReflowMode)
409{
410    m_private->setTextReflowMode(BlackBerryTextReflowMode, textReflowMode);
411}
412
413bool WebSettings::isScrollbarsEnabled() const
414{
415    return m_private->getBoolean(BlackBerryScrollbarsEnabled);
416}
417
418void WebSettings::setScrollbarsEnabled(bool enabled)
419{
420    m_private->setBoolean(BlackBerryScrollbarsEnabled, enabled);
421}
422
423bool WebSettings::canJavaScriptOpenWindowsAutomatically() const
424{
425    return m_private->getBoolean(WebKitJavaScriptCanOpenWindowsAutomaticallyEnabled);
426}
427
428void WebSettings::setJavaScriptOpenWindowsAutomatically(bool enabled)
429{
430    m_private->setBoolean(WebKitJavaScriptCanOpenWindowsAutomaticallyEnabled, enabled);
431}
432
433bool WebSettings::arePluginsEnabled() const
434{
435    return m_private->getBoolean(WebKitPluginsEnabled);
436}
437
438void WebSettings::setPluginsEnabled(bool enabled)
439{
440    m_private->setBoolean(WebKitPluginsEnabled, enabled);
441}
442
443bool WebSettings::isGeolocationEnabled() const
444{
445    return m_private->getBoolean(WebKitGeolocationEnabled);
446}
447
448void WebSettings::setGeolocationEnabled(bool enabled)
449{
450    m_private->setBoolean(WebKitGeolocationEnabled, enabled);
451}
452
453bool WebSettings::doesGetFocusNodeContext() const
454{
455    return m_private->getBoolean(BlackBerryGetFocusNodeContextEnabled);
456}
457
458void WebSettings::setGetFocusNodeContext(bool enabled)
459{
460    m_private->setBoolean(BlackBerryGetFocusNodeContextEnabled, enabled);
461}
462
463BlackBerry::Platform::String WebSettings::userStyleSheetLocation()
464{
465    return m_private->getString(WebKitUserStyleSheetLocation);
466}
467
468void WebSettings::setUserStyleSheetLocation(const BlackBerry::Platform::String& userStyleSheetLocation)
469{
470    m_private->setString(WebKitUserStyleSheetLocation, userStyleSheetLocation);
471}
472
473bool WebSettings::areLinksHandledExternally() const
474{
475    return m_private->getBoolean(BlackBerryLinksHandledExternallyEnabled);
476}
477
478void WebSettings::setAreLinksHandledExternally(bool enabled)
479{
480    m_private->setBoolean(BlackBerryLinksHandledExternallyEnabled, enabled);
481}
482
483void WebSettings::setAllowCrossSiteRequests(bool allow)
484{
485    m_private->setBoolean(BlackBerryAllowCrossSiteRequests, allow);
486}
487
488bool WebSettings::allowCrossSiteRequests() const
489{
490    return m_private->getBoolean(BlackBerryAllowCrossSiteRequests);
491}
492
493bool WebSettings::isUserScalable() const
494{
495    return m_private->getBoolean(BlackBerryUserScalableEnabled);
496}
497
498void WebSettings::setUserScalable(bool enabled)
499{
500    m_private->setBoolean(BlackBerryUserScalableEnabled, enabled);
501}
502
503int WebSettings::viewportWidth() const
504{
505    return m_private->getInteger(BlackBerryViewportWidth);
506}
507
508void WebSettings::setViewportWidth(int width)
509{
510    m_private->setInteger(BlackBerryViewportWidth, width);
511}
512
513double WebSettings::initialScale() const
514{
515    return m_private->getDouble(BlackBerryInitialScale);
516}
517
518void WebSettings::setInitialScale(double initialScale)
519{
520    m_private->setDouble(BlackBerryInitialScale, initialScale);
521}
522
523int WebSettings::firstScheduledLayoutDelay() const
524{
525    return m_private->getInteger(WebKitFirstScheduledLayoutDelay);
526}
527
528void WebSettings::setFirstScheduledLayoutDelay(int delay)
529{
530    m_private->setInteger(WebKitFirstScheduledLayoutDelay, delay);
531}
532
533// Whether to include pattern: in the list of string patterns.
534bool WebSettings::shouldHandlePatternUrls() const
535{
536    return m_private->getBoolean(BlackBerryHandlePatternURLs);
537}
538
539void WebSettings::setShouldHandlePatternUrls(bool handlePatternURLs)
540{
541    m_private->setBoolean(BlackBerryHandlePatternURLs, handlePatternURLs);
542}
543
544bool WebSettings::areCookiesEnabled() const
545{
546    return m_private->getBoolean(BlackBerryCookiesEnabled);
547}
548
549void WebSettings::setAreCookiesEnabled(bool enable)
550{
551    m_private->setBoolean(BlackBerryCookiesEnabled, enable);
552}
553
554bool WebSettings::isLocalStorageEnabled() const
555{
556    return m_private->getBoolean(WebKitLocalStorageEnabled);
557}
558
559void WebSettings::setIsLocalStorageEnabled(bool enable)
560{
561    m_private->setBoolean(WebKitLocalStorageEnabled, enable);
562}
563
564bool WebSettings::isDatabasesEnabled() const
565{
566    return m_private->getBoolean(WebKitDatabasesEnabled);
567}
568
569void WebSettings::setIsDatabasesEnabled(bool enable)
570{
571    m_private->setBoolean(WebKitDatabasesEnabled, enable);
572}
573
574bool WebSettings::isAppCacheEnabled() const
575{
576    return m_private->getBoolean(WebKitOfflineWebApplicationCacheEnabled);
577}
578
579void WebSettings::setIsAppCacheEnabled(bool enable)
580{
581    m_private->setBoolean(WebKitOfflineWebApplicationCacheEnabled, enable);
582}
583
584unsigned long long WebSettings::localStorageQuota() const
585{
586    return m_private->getUnsignedLongLong(WebKitLocalStorageQuota);
587}
588
589void WebSettings::setLocalStorageQuota(unsigned long long quota)
590{
591    m_private->setUnsignedLongLong(WebKitLocalStorageQuota, quota);
592}
593
594unsigned long long WebSettings::sessionStorageQuota() const
595{
596    return m_private->getUnsignedLongLong(WebKitSessionStorageQuota);
597}
598
599void WebSettings::setSessionStorageQuota(unsigned long long quota)
600{
601    m_private->setUnsignedLongLong(WebKitSessionStorageQuota, quota);
602}
603
604int WebSettings::maximumPagesInCache() const
605{
606    // FIXME: We shouldn't be calling into WebCore from here. This class should just be a state store.
607    return WebCore::pageCache()->capacity();
608}
609
610void WebSettings::setMaximumPagesInCache(int pages)
611{
612    // FIXME: We shouldn't be calling into WebCore from here. This class should just be a state store.
613    unsigned realPages = std::max(0, pages);
614    WebCore::pageCache()->setCapacity(realPages);
615    m_private->setUnsigned(WebKitMaximumPagesInCache, realPages);
616}
617
618BlackBerry::Platform::String WebSettings::localStoragePath() const
619{
620    return m_private->getString(WebKitLocalStoragePath);
621}
622
623void WebSettings::setLocalStoragePath(const BlackBerry::Platform::String& path)
624{
625    m_private->setString(WebKitLocalStoragePath, path);
626}
627
628BlackBerry::Platform::String WebSettings::indexedDataBasePath() const
629{
630    return m_private->getString(WebKitIndexedDataBasePath);
631}
632
633void WebSettings::setIndexedDataBasePath(const BlackBerry::Platform::String& path)
634{
635    m_private->setString(WebKitIndexedDataBasePath, path);
636}
637
638BlackBerry::Platform::String WebSettings::databasePath() const
639{
640    return m_private->getString(WebKitDatabasePath);
641}
642
643void WebSettings::setDatabasePath(const BlackBerry::Platform::String& path)
644{
645    m_private->setString(WebKitDatabasePath, path);
646}
647
648BlackBerry::Platform::String WebSettings::appCachePath() const
649{
650    return m_private->getString(WebKitOfflineWebApplicationCachePath);
651}
652
653void WebSettings::setAppCachePath(const BlackBerry::Platform::String& path)
654{
655    m_private->setString(WebKitOfflineWebApplicationCachePath, path);
656}
657
658BlackBerry::Platform::String WebSettings::pageGroupName() const
659{
660    return m_private->getString(WebKitPageGroupName);
661}
662
663void WebSettings::setPageGroupName(const BlackBerry::Platform::String& pageGroupName)
664{
665    m_private->setString(WebKitPageGroupName, pageGroupName);
666}
667
668bool WebSettings::isEmailMode() const
669{
670    return m_private->getBoolean(BlackBerryEmailModeEnabled);
671}
672
673void WebSettings::setEmailMode(bool enable)
674{
675    m_private->setBoolean(BlackBerryEmailModeEnabled, enable);
676}
677
678bool WebSettings::shouldRenderAnimationsOnScrollOrZoom() const
679{
680    return m_private->getBoolean(BlackBerryRenderAnimationsOnScrollOrZoomEnabled);
681}
682
683void WebSettings::setShouldRenderAnimationsOnScrollOrZoom(bool enable)
684{
685    m_private->setBoolean(BlackBerryRenderAnimationsOnScrollOrZoomEnabled, enable);
686}
687
688unsigned WebSettings::overScrollColor() const
689{
690    return m_private->getUnsigned(BlackBerryOverScrollColor);
691}
692
693void WebSettings::setOverScrollColor(unsigned color)
694{
695    m_private->setUnsigned(BlackBerryOverScrollColor, color);
696}
697
698bool WebSettings::isEnableDefaultOverScrollBackground() const
699{
700    return m_private->getBoolean(BlackBerryEnableDefaultOverScrollBackground);
701}
702
703void WebSettings::setEnableDefaultOverScrollBackground(bool enabled)
704{
705    m_private->setBoolean(BlackBerryEnableDefaultOverScrollBackground, enabled);
706}
707
708unsigned WebSettings::backgroundColor() const
709{
710    return m_private->getUnsigned(BlackBerryBackgroundColor);
711}
712
713void WebSettings::setBackgroundColor(unsigned color)
714{
715    m_private->setUnsigned(BlackBerryBackgroundColor, color);
716}
717
718bool WebSettings::isWritingDirectionRTL() const
719{
720    return m_private->getBoolean(BlackBerryUseRTLWritingDirection);
721}
722
723void WebSettings::setWritingDirectionRTL(bool useRTLWritingDirection)
724{
725    m_private->setBoolean(BlackBerryUseRTLWritingDirection, useRTLWritingDirection);
726}
727
728bool WebSettings::useWebKitCache() const
729{
730    return m_private->getBoolean(BlackBerryUseWebKitCache);
731}
732
733void WebSettings::setUseWebKitCache(bool useWebKitCache)
734{
735    m_private->setBoolean(BlackBerryUseWebKitCache, useWebKitCache);
736}
737
738bool WebSettings::isFrameFlatteningEnabled() const
739{
740    return m_private->getBoolean(WebKitFrameFlatteningEnabled);
741}
742
743void WebSettings::setFrameFlatteningEnabled(bool enable)
744{
745    m_private->setBoolean(WebKitFrameFlatteningEnabled, enable);
746}
747
748bool WebSettings::isBackingStoreEnabled() const
749{
750    return m_private->getBoolean(BlackBerryBackingStoreEnabled);
751}
752
753void WebSettings::setBackingStoreEnabled(bool enable)
754{
755    m_private->setBoolean(BlackBerryBackingStoreEnabled, enable);
756}
757
758unsigned WebSettings::maxPluginInstances() const
759{
760    return m_private->getUnsigned(BlackBerryMaxPluginInstances);
761}
762
763void WebSettings::setMaxPluginInstances(unsigned maxPluginInstances)
764{
765    m_private->setUnsigned(BlackBerryMaxPluginInstances, maxPluginInstances);
766}
767
768bool WebSettings::areWebSocketsEnabled() const
769{
770    return m_private->getBoolean(WebKitWebSocketsEnabled);
771}
772
773void WebSettings::setWebSocketsEnabled(bool enable)
774{
775    m_private->setBoolean(WebKitWebSocketsEnabled, enable);
776}
777
778bool WebSettings::isSpatialNavigationEnabled() const
779{
780    return m_private->getBoolean(SpatialNavigationEnabled);
781}
782
783void WebSettings::setSpatialNavigationEnabled(bool enable)
784{
785    m_private->setBoolean(SpatialNavigationEnabled, enable);
786}
787
788bool WebSettings::isAsynchronousSpellCheckingEnabled() const
789{
790    return m_private->getBoolean(BlackBerryAsynchronousSpellChecking);
791}
792
793void WebSettings::setAsynchronousSpellCheckingEnabled(bool enable) const
794{
795    return m_private->setBoolean(BlackBerryAsynchronousSpellChecking, enable);
796}
797
798bool WebSettings::fullScreenVideoCapable() const
799{
800    return m_private->getBoolean(BlackBerryFullScreenVideoCapable);
801}
802
803void WebSettings::setFullScreenVideoCapable(bool enable)
804{
805    m_private->setBoolean(BlackBerryFullScreenVideoCapable, enable);
806}
807
808bool WebSettings::isCredentialAutofillEnabled() const
809{
810    return m_private->getBoolean(BlackBerryCredentialAutofillEnabled);
811}
812
813void WebSettings::setCredentialAutofillEnabled(bool enable)
814{
815    return m_private->setBoolean(BlackBerryCredentialAutofillEnabled, enable);
816}
817
818bool WebSettings::isFormAutofillEnabled() const
819{
820    return m_private->getBoolean(BlackBerryFormAutofillEnabled);
821}
822
823void WebSettings::setFormAutofillEnabled(bool enable)
824{
825    return m_private->setBoolean(BlackBerryFormAutofillEnabled, enable);
826}
827
828double WebSettings::devicePixelRatio() const
829{
830    return m_private->getDouble(BlackBerryDevicePixelRatio);
831}
832
833void WebSettings::setDevicePixelRatio(double ratio)
834{
835    m_private->setDouble(BlackBerryDevicePixelRatio, ratio);
836}
837
838bool WebSettings::applyDeviceScaleFactorInCompositor() const
839{
840    return m_private->getBoolean(BlackBerryApplyDeviceScaleFactorInCompositor);
841}
842
843void WebSettings::setApplyDeviceScaleFactorInCompositor(bool applyDeviceScaleFactorInCompositor)
844{
845    m_private->setBoolean(BlackBerryApplyDeviceScaleFactorInCompositor, applyDeviceScaleFactorInCompositor);
846}
847
848bool WebSettings::isTextAutosizingEnabled() const
849{
850    return m_private->getBoolean(WebKitTextAutosizingEnabled);
851}
852
853void WebSettings::setTextAutosizingEnabled(bool textAutosizingEnabled)
854{
855    m_private->setBoolean(WebKitTextAutosizingEnabled, textAutosizingEnabled);
856}
857
858} // namespace WebKit
859} // namespace BlackBerry
860