WebKit/qt/Api/qwebsettings.cpp
changeset 0 4f2f89ce4247
child 2 303757a437d3
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     1 /*
       
     2     Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
       
     3 
       
     4     This library is free software; you can redistribute it and/or
       
     5     modify it under the terms of the GNU Library 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     Library General Public License for more details.
       
    13 
       
    14     You should have received a copy of the GNU Library General Public License
       
    15     along with this library; see the file COPYING.LIB.  If not, write to
       
    16     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
       
    17     Boston, MA 02110-1301, USA.
       
    18 */
       
    19 
       
    20 #include "config.h"
       
    21 #include "qwebsettings.h"
       
    22 
       
    23 #include "qwebpage.h"
       
    24 #include "qwebpage_p.h"
       
    25 #include "qwebplugindatabase_p.h"
       
    26 
       
    27 #include "AbstractDatabase.h"
       
    28 #include "Cache.h"
       
    29 #include "CrossOriginPreflightResultCache.h"
       
    30 #include "FontCache.h"
       
    31 #include "Page.h"
       
    32 #include "PageCache.h"
       
    33 #include "Settings.h"
       
    34 #include "KURL.h"
       
    35 #include "PlatformString.h"
       
    36 #include "IconDatabase.h"
       
    37 #include "Image.h"
       
    38 #include "IntSize.h"
       
    39 #include "ApplicationCacheStorage.h"
       
    40 #include "DatabaseTracker.h"
       
    41 #include "FileSystem.h"
       
    42 
       
    43 #include <QApplication>
       
    44 #include <QDesktopServices>
       
    45 #include <QDir>
       
    46 #include <QHash>
       
    47 #include <QSharedData>
       
    48 #include <QUrl>
       
    49 #include <QFileInfo>
       
    50 
       
    51 #include "NetworkStateNotifier.h"
       
    52 
       
    53 void QWEBKIT_EXPORT qt_networkAccessAllowed(bool isAllowed)
       
    54 {
       
    55 #if ENABLE(QT_BEARER)
       
    56     WebCore::networkStateNotifier().setNetworkAccessAllowed(isAllowed);
       
    57 #endif
       
    58 }
       
    59 
       
    60 class QWebSettingsPrivate {
       
    61 public:
       
    62     QWebSettingsPrivate(WebCore::Settings* wcSettings = 0)
       
    63         : settings(wcSettings)
       
    64     {
       
    65     }
       
    66 
       
    67     QHash<int, QString> fontFamilies;
       
    68     QHash<int, int> fontSizes;
       
    69     QHash<int, bool> attributes;
       
    70     QUrl userStyleSheetLocation;
       
    71     QString defaultTextEncoding;
       
    72     QString localStoragePath;
       
    73     QString offlineWebApplicationCachePath;
       
    74     qint64 offlineStorageDefaultQuota;
       
    75 
       
    76     void apply();
       
    77     WebCore::Settings* settings;
       
    78 };
       
    79 
       
    80 typedef QHash<int, QPixmap> WebGraphicHash;
       
    81 Q_GLOBAL_STATIC(WebGraphicHash, _graphics)
       
    82 
       
    83 static void earlyClearGraphics()
       
    84 {
       
    85     _graphics()->clear();
       
    86 }
       
    87 
       
    88 static WebGraphicHash* graphics()
       
    89 {
       
    90     WebGraphicHash* hash = _graphics();
       
    91 
       
    92     if (hash->isEmpty()) {
       
    93 
       
    94         // prevent ~QPixmap running after ~QApplication (leaks native pixmaps)
       
    95         qAddPostRoutine(earlyClearGraphics);
       
    96 
       
    97         hash->insert(QWebSettings::MissingImageGraphic, QPixmap(QLatin1String(":webkit/resources/missingImage.png")));
       
    98         hash->insert(QWebSettings::MissingPluginGraphic, QPixmap(QLatin1String(":webkit/resources/nullPlugin.png")));
       
    99         hash->insert(QWebSettings::DefaultFrameIconGraphic, QPixmap(QLatin1String(":webkit/resources/urlIcon.png")));
       
   100         hash->insert(QWebSettings::TextAreaSizeGripCornerGraphic, QPixmap(QLatin1String(":webkit/resources/textAreaResizeCorner.png")));
       
   101         hash->insert(QWebSettings::DeleteButtonGraphic, QPixmap(QLatin1String(":webkit/resources/deleteButton.png")));
       
   102         hash->insert(QWebSettings::InputSpeechButtonGraphic, QPixmap(QLatin1String(":webkit/resources/inputSpeech.png")));
       
   103     }
       
   104 
       
   105     return hash;
       
   106 }
       
   107 
       
   108 Q_GLOBAL_STATIC(QList<QWebSettingsPrivate*>, allSettings);
       
   109 
       
   110 void QWebSettingsPrivate::apply()
       
   111 {
       
   112     if (settings) {
       
   113         settings->setTextAreasAreResizable(true);
       
   114 
       
   115         QWebSettingsPrivate* global = QWebSettings::globalSettings()->d;
       
   116 
       
   117         QString family = fontFamilies.value(QWebSettings::StandardFont,
       
   118                                             global->fontFamilies.value(QWebSettings::StandardFont));
       
   119         settings->setStandardFontFamily(family);
       
   120 
       
   121         family = fontFamilies.value(QWebSettings::FixedFont,
       
   122                                     global->fontFamilies.value(QWebSettings::FixedFont));
       
   123         settings->setFixedFontFamily(family);
       
   124 
       
   125         family = fontFamilies.value(QWebSettings::SerifFont,
       
   126                                     global->fontFamilies.value(QWebSettings::SerifFont));
       
   127         settings->setSerifFontFamily(family);
       
   128 
       
   129         family = fontFamilies.value(QWebSettings::SansSerifFont,
       
   130                                     global->fontFamilies.value(QWebSettings::SansSerifFont));
       
   131         settings->setSansSerifFontFamily(family);
       
   132 
       
   133         family = fontFamilies.value(QWebSettings::CursiveFont,
       
   134                                     global->fontFamilies.value(QWebSettings::CursiveFont));
       
   135         settings->setCursiveFontFamily(family);
       
   136 
       
   137         family = fontFamilies.value(QWebSettings::FantasyFont,
       
   138                                     global->fontFamilies.value(QWebSettings::FantasyFont));
       
   139         settings->setFantasyFontFamily(family);
       
   140 
       
   141         int size = fontSizes.value(QWebSettings::MinimumFontSize,
       
   142                                    global->fontSizes.value(QWebSettings::MinimumFontSize));
       
   143         settings->setMinimumFontSize(size);
       
   144 
       
   145         size = fontSizes.value(QWebSettings::MinimumLogicalFontSize,
       
   146                                    global->fontSizes.value(QWebSettings::MinimumLogicalFontSize));
       
   147         settings->setMinimumLogicalFontSize(size);
       
   148 
       
   149         size = fontSizes.value(QWebSettings::DefaultFontSize,
       
   150                                    global->fontSizes.value(QWebSettings::DefaultFontSize));
       
   151         settings->setDefaultFontSize(size);
       
   152 
       
   153         size = fontSizes.value(QWebSettings::DefaultFixedFontSize,
       
   154                                    global->fontSizes.value(QWebSettings::DefaultFixedFontSize));
       
   155         settings->setDefaultFixedFontSize(size);
       
   156 
       
   157         bool value = attributes.value(QWebSettings::AutoLoadImages,
       
   158                                       global->attributes.value(QWebSettings::AutoLoadImages));
       
   159         settings->setLoadsImagesAutomatically(value);
       
   160 
       
   161         value = attributes.value(QWebSettings::JavascriptEnabled,
       
   162                                       global->attributes.value(QWebSettings::JavascriptEnabled));
       
   163         settings->setJavaScriptEnabled(value);
       
   164 #if USE(ACCELERATED_COMPOSITING)
       
   165         value = attributes.value(QWebSettings::AcceleratedCompositingEnabled,
       
   166                                       global->attributes.value(QWebSettings::AcceleratedCompositingEnabled));
       
   167 
       
   168         settings->setAcceleratedCompositingEnabled(value);
       
   169 #endif
       
   170 #if ENABLE(3D_CANVAS)
       
   171         value = attributes.value(QWebSettings::WebGLEnabled,
       
   172                                  global->attributes.value(QWebSettings::WebGLEnabled));
       
   173 
       
   174         settings->setWebGLEnabled(value);
       
   175 #endif
       
   176  
       
   177         value = attributes.value(QWebSettings::JavascriptCanOpenWindows,
       
   178                                       global->attributes.value(QWebSettings::JavascriptCanOpenWindows));
       
   179         settings->setJavaScriptCanOpenWindowsAutomatically(value);
       
   180 
       
   181         value = attributes.value(QWebSettings::JavaEnabled,
       
   182                                       global->attributes.value(QWebSettings::JavaEnabled));
       
   183         settings->setJavaEnabled(value);
       
   184 
       
   185         value = attributes.value(QWebSettings::PluginsEnabled,
       
   186                                       global->attributes.value(QWebSettings::PluginsEnabled));
       
   187         settings->setPluginsEnabled(value);
       
   188 
       
   189         value = attributes.value(QWebSettings::PrivateBrowsingEnabled,
       
   190                                       global->attributes.value(QWebSettings::PrivateBrowsingEnabled));
       
   191         settings->setPrivateBrowsingEnabled(value);
       
   192 
       
   193         value = attributes.value(QWebSettings::SpatialNavigationEnabled,
       
   194                                       global->attributes.value(QWebSettings::SpatialNavigationEnabled));
       
   195         settings->setSpatialNavigationEnabled(value);
       
   196 
       
   197         value = attributes.value(QWebSettings::JavascriptCanAccessClipboard,
       
   198                                       global->attributes.value(QWebSettings::JavascriptCanAccessClipboard));
       
   199         settings->setDOMPasteAllowed(value);
       
   200         settings->setJavaScriptCanAccessClipboard(value);
       
   201 
       
   202         value = attributes.value(QWebSettings::DeveloperExtrasEnabled,
       
   203                                       global->attributes.value(QWebSettings::DeveloperExtrasEnabled));
       
   204         settings->setDeveloperExtrasEnabled(value);
       
   205 
       
   206         value = attributes.value(QWebSettings::FrameFlatteningEnabled,
       
   207                                       global->attributes.value(QWebSettings::FrameFlatteningEnabled));
       
   208         settings->setFrameFlatteningEnabled(value);
       
   209 
       
   210         QUrl location = !userStyleSheetLocation.isEmpty() ? userStyleSheetLocation : global->userStyleSheetLocation;
       
   211         settings->setUserStyleSheetLocation(WebCore::KURL(location));
       
   212 
       
   213         QString encoding = !defaultTextEncoding.isEmpty() ? defaultTextEncoding: global->defaultTextEncoding;
       
   214         settings->setDefaultTextEncodingName(encoding);
       
   215 
       
   216         QString storagePath = !localStoragePath.isEmpty() ? localStoragePath : global->localStoragePath;
       
   217         settings->setLocalStorageDatabasePath(storagePath);
       
   218 
       
   219         value = attributes.value(QWebSettings::ZoomTextOnly,
       
   220                                  global->attributes.value(QWebSettings::ZoomTextOnly));
       
   221         settings->setZoomMode(value ? WebCore::ZoomTextOnly : WebCore::ZoomPage);
       
   222 
       
   223         value = attributes.value(QWebSettings::PrintElementBackgrounds,
       
   224                                       global->attributes.value(QWebSettings::PrintElementBackgrounds));
       
   225         settings->setShouldPrintBackgrounds(value);
       
   226 
       
   227 #if ENABLE(DATABASE)
       
   228         value = attributes.value(QWebSettings::OfflineStorageDatabaseEnabled,
       
   229                                       global->attributes.value(QWebSettings::OfflineStorageDatabaseEnabled));
       
   230         WebCore::AbstractDatabase::setIsAvailable(value);
       
   231 #endif
       
   232 
       
   233         value = attributes.value(QWebSettings::OfflineWebApplicationCacheEnabled,
       
   234                                       global->attributes.value(QWebSettings::OfflineWebApplicationCacheEnabled));
       
   235         settings->setOfflineWebApplicationCacheEnabled(value);
       
   236 
       
   237         value = attributes.value(QWebSettings::LocalStorageEnabled,
       
   238                                       global->attributes.value(QWebSettings::LocalStorageEnabled));
       
   239         settings->setLocalStorageEnabled(value);
       
   240 
       
   241         value = attributes.value(QWebSettings::LocalContentCanAccessRemoteUrls,
       
   242                                       global->attributes.value(QWebSettings::LocalContentCanAccessRemoteUrls));
       
   243         settings->setAllowUniversalAccessFromFileURLs(value);
       
   244 
       
   245         value = attributes.value(QWebSettings::LocalContentCanAccessFileUrls,
       
   246                                       global->attributes.value(QWebSettings::LocalContentCanAccessFileUrls));
       
   247         settings->setAllowFileAccessFromFileURLs(value);
       
   248 
       
   249         value = attributes.value(QWebSettings::XSSAuditingEnabled,
       
   250                                       global->attributes.value(QWebSettings::XSSAuditingEnabled));
       
   251         settings->setXSSAuditorEnabled(value);
       
   252 
       
   253 #if ENABLE(TILED_BACKING_STORE)
       
   254         value = attributes.value(QWebSettings::TiledBackingStoreEnabled,
       
   255                                       global->attributes.value(QWebSettings::TiledBackingStoreEnabled));
       
   256         settings->setTiledBackingStoreEnabled(value);
       
   257 #endif
       
   258 
       
   259         value = attributes.value(QWebSettings::SiteSpecificQuirksEnabled,
       
   260                                       global->attributes.value(QWebSettings::SiteSpecificQuirksEnabled));
       
   261         settings->setNeedsSiteSpecificQuirks(value);
       
   262 
       
   263         settings->setUsesPageCache(WebCore::pageCache()->capacity());
       
   264     } else {
       
   265         QList<QWebSettingsPrivate*> settings = *::allSettings();
       
   266         for (int i = 0; i < settings.count(); ++i)
       
   267             settings[i]->apply();
       
   268     }
       
   269 }
       
   270 
       
   271 /*!
       
   272     Returns the global settings object.
       
   273 
       
   274     Any setting changed on the default object is automatically applied to all
       
   275     QWebPage instances where the particular setting is not overriden already.
       
   276 */
       
   277 QWebSettings* QWebSettings::globalSettings()
       
   278 {
       
   279     static QWebSettings* global = 0;
       
   280     if (!global)
       
   281         global = new QWebSettings;
       
   282     return global;
       
   283 }
       
   284 
       
   285 /*!
       
   286     \class QWebSettings
       
   287     \since 4.4
       
   288     \brief The QWebSettings class provides an object to store the settings used
       
   289     by QWebPage and QWebFrame.
       
   290 
       
   291     \inmodule QtWebKit
       
   292 
       
   293     Each QWebPage object has its own QWebSettings object, which configures the
       
   294     settings for that page. If a setting is not configured, then it is looked
       
   295     up in the global settings object, which can be accessed using
       
   296     globalSettings().
       
   297 
       
   298     QWebSettings allows configuration of browser properties, such as font sizes and
       
   299     families, the location of a custom style sheet, and generic attributes like
       
   300     JavaScript and plugins. Individual attributes are set using the setAttribute()
       
   301     function. The \l{QWebSettings::WebAttribute}{WebAttribute} enum further describes
       
   302     each attribute.
       
   303 
       
   304     QWebSettings also configures global properties such as the web page memory
       
   305     cache, icon database, local database storage and offline
       
   306     applications storage.
       
   307 
       
   308     \section1 Enabling Plugins
       
   309 
       
   310     Support for browser plugins can enabled by setting the
       
   311     \l{QWebSettings::PluginsEnabled}{PluginsEnabled} attribute. For many applications,
       
   312     this attribute is enabled for all pages by setting it on the
       
   313     \l{globalSettings()}{global settings object}. QtWebKit will always ignore this setting
       
   314     when processing Qt plugins. The decision to allow a Qt plugin is made by the client
       
   315     in its reimplementation of QWebPage::createPlugin().
       
   316 
       
   317     \section1 Web Application Support
       
   318 
       
   319     WebKit provides support for features specified in \l{HTML 5} that improve the
       
   320     performance and capabilities of Web applications. These include client-side
       
   321     (offline) storage and the use of a Web application cache.
       
   322 
       
   323     Client-side (offline) storage is an improvement over the use of cookies to
       
   324     store persistent data in Web applications. Applications can configure and
       
   325     enable the use of an offline storage database by calling the
       
   326     setOfflineStoragePath() with an appropriate file path, and can limit the quota
       
   327     for each application by calling setOfflineStorageDefaultQuota().
       
   328 
       
   329     \sa QWebPage::settings(), QWebView::settings(), {Web Browser}
       
   330 */
       
   331 
       
   332 /*!
       
   333     \enum QWebSettings::FontFamily
       
   334 
       
   335     This enum describes the generic font families defined by CSS 2.
       
   336     For more information see the
       
   337     \l{http://www.w3.org/TR/REC-CSS2/fonts.html#generic-font-families}{CSS standard}.
       
   338 
       
   339     \value StandardFont
       
   340     \value FixedFont
       
   341     \value SerifFont
       
   342     \value SansSerifFont
       
   343     \value CursiveFont
       
   344     \value FantasyFont
       
   345 */
       
   346 
       
   347 /*!
       
   348     \enum QWebSettings::FontSize
       
   349 
       
   350     This enum describes the font sizes configurable through QWebSettings.
       
   351 
       
   352     \value MinimumFontSize The hard minimum font size.
       
   353     \value MinimumLogicalFontSize The minimum logical font size that is applied
       
   354         when zooming out with QWebFrame::setTextSizeMultiplier().
       
   355     \value DefaultFontSize The default font size for regular text.
       
   356     \value DefaultFixedFontSize The default font size for fixed-pitch text.
       
   357 */
       
   358 
       
   359 /*!
       
   360     \enum QWebSettings::WebGraphic
       
   361 
       
   362     This enums describes the standard graphical elements used in webpages.
       
   363 
       
   364     \value MissingImageGraphic The replacement graphic shown when an image could not be loaded.
       
   365     \value MissingPluginGraphic The replacement graphic shown when a plugin could not be loaded.
       
   366     \value DefaultFrameIconGraphic The default icon for QWebFrame::icon().
       
   367     \value TextAreaSizeGripCornerGraphic The graphic shown for the size grip of text areas.
       
   368     \value DeleteButtonGraphic The graphic shown for the WebKit-Editing-Delete-Button in Deletion UI.
       
   369 */
       
   370 
       
   371 /*!
       
   372     \enum QWebSettings::WebAttribute
       
   373 
       
   374     This enum describes various attributes that are configurable through QWebSettings.
       
   375 
       
   376     \value AutoLoadImages Specifies whether images are automatically loaded in
       
   377         web pages. This is enabled by default.
       
   378     \value DnsPrefetchEnabled Specifies whether QtWebkit will try to pre-fetch DNS entries to
       
   379         speed up browsing. This only works as a global attribute. Only for Qt 4.6 and later. This is disabled by default.
       
   380     \value JavascriptEnabled Enables or disables the running of JavaScript
       
   381         programs. This is enabled by default
       
   382     \value JavaEnabled Enables or disables Java applets.
       
   383         Currently Java applets are not supported.
       
   384     \value PluginsEnabled Enables or disables plugins in Web pages (e.g. using NPAPI). Qt plugins
       
   385         with a mimetype such as "application/x-qt-plugin" are not affected by this setting. This is disabled by default.
       
   386     \value PrivateBrowsingEnabled Private browsing prevents WebKit from
       
   387         recording visited pages in the history and storing web page icons. This is disabled by default.
       
   388     \value JavascriptCanOpenWindows Specifies whether JavaScript programs
       
   389         can open new windows. This is disabled by default.
       
   390     \value JavascriptCanAccessClipboard Specifies whether JavaScript programs
       
   391         can read or write to the clipboard. This is disabled by default.
       
   392     \value DeveloperExtrasEnabled Enables extra tools for Web developers.
       
   393         Currently this enables the "Inspect" element in the context menu as
       
   394         well as the use of QWebInspector which controls the web inspector
       
   395         for web site debugging. This is disabled by default.
       
   396     \value SpatialNavigationEnabled Enables or disables the Spatial Navigation
       
   397         feature, which consists in the ability to navigate between focusable
       
   398         elements in a Web page, such as hyperlinks and form controls, by using
       
   399         Left, Right, Up and Down arrow keys. For example, if a user presses the
       
   400         Right key, heuristics determine whether there is an element he might be
       
   401         trying to reach towards the right and which element he probably wants.
       
   402         This is disabled by default.
       
   403     \value LinksIncludedInFocusChain Specifies whether hyperlinks should be
       
   404         included in the keyboard focus chain. This is enabled by default.
       
   405     \value ZoomTextOnly Specifies whether the zoom factor on a frame applies
       
   406         only to the text or to all content. This is disabled by default.
       
   407     \value PrintElementBackgrounds Specifies whether the background color and images
       
   408         are also drawn when the page is printed. This is enabled by default.
       
   409     \value OfflineStorageDatabaseEnabled Specifies whether support for the HTML 5
       
   410         offline storage feature is enabled or not. This is disabled by default.
       
   411     \value OfflineWebApplicationCacheEnabled Specifies whether support for the HTML 5
       
   412         web application cache feature is enabled or not. This is disabled by default.
       
   413     \value LocalStorageEnabled Specifies whether support for the HTML 5
       
   414         local storage feature is enabled or not. This is disabled by default.
       
   415     \value LocalStorageDatabaseEnabled \e{This enum value is deprecated.} Use
       
   416         QWebSettings::LocalStorageEnabled instead.
       
   417     \value LocalContentCanAccessRemoteUrls Specifies whether locally loaded documents are
       
   418         allowed to access remote urls. This is disabled by default. For more information
       
   419         about security origins and local vs. remote content see QWebSecurityOrigin.
       
   420     \value LocalContentCanAccessFileUrls Specifies whether locally loaded documents are
       
   421         allowed to access other local urls. This is enabled by default. For more information
       
   422         about security origins and local vs. remote content see QWebSecurityOrigin.
       
   423     \value XSSAuditingEnabled Specifies whether load requests should be monitored for cross-site
       
   424         scripting attempts. Suspicious scripts will be blocked and reported in the inspector's
       
   425         JavaScript console. Enabling this feature might have an impact on performance
       
   426         and it is disabled by default.
       
   427     \value AcceleratedCompositingEnabled This feature, when used in conjunction with
       
   428         QGraphicsWebView, accelerates animations of web content. CSS animations of the transform and
       
   429         opacity properties will be rendered by composing the cached content of the animated elements.
       
   430         This is enabled by default.
       
   431     \value TiledBackingStoreEnabled This setting enables the tiled backing store feature
       
   432         for a QGraphicsWebView. With the tiled backing store enabled, the web page contents in and around
       
   433         the current visible area is speculatively cached to bitmap tiles. The tiles are automatically kept
       
   434         in sync with the web page as it changes. Enabling tiling can significantly speed up painting heavy 
       
   435         operations like scrolling. Enabling the feature increases memory consumption. It does not work well 
       
   436         with contents using CSS fixed positioning (see also \l{QGraphicsWebView::}{resizesToContents} property).
       
   437         \l{QGraphicsWebView::}{tiledBackingStoreFrozen} property allows application to temporarily
       
   438         freeze the contents of the backing store. This is disabled by default.
       
   439     \value FrameFlatteningEnabled With this setting each subframe is expanded to its contents.
       
   440         On touch devices, it is desired to not have any scrollable sub parts of the page
       
   441         as it results in a confusing user experience, with scrolling sometimes scrolling sub parts
       
   442         and at other times scrolling the page itself. For this reason iframes and framesets are
       
   443         barely usable on touch devices. This will flatten all the frames to become one scrollable page.
       
   444         This is disabled by default.
       
   445     \value SiteSpecificQuirksEnabled This setting enables WebKit's workaround for broken sites. It is
       
   446         enabled by default.
       
   447 */
       
   448 
       
   449 /*!
       
   450     \internal
       
   451 */
       
   452 QWebSettings::QWebSettings()
       
   453     : d(new QWebSettingsPrivate)
       
   454 {
       
   455     // Initialize our global defaults
       
   456     d->fontSizes.insert(QWebSettings::MinimumFontSize, 0);
       
   457     d->fontSizes.insert(QWebSettings::MinimumLogicalFontSize, 0);
       
   458     d->fontSizes.insert(QWebSettings::DefaultFontSize, 16);
       
   459     d->fontSizes.insert(QWebSettings::DefaultFixedFontSize, 13);
       
   460     d->fontFamilies.insert(QWebSettings::StandardFont, QLatin1String("Arial"));
       
   461     d->fontFamilies.insert(QWebSettings::FixedFont, QLatin1String("Courier New"));
       
   462     d->fontFamilies.insert(QWebSettings::SerifFont, QLatin1String("Times New Roman"));
       
   463     d->fontFamilies.insert(QWebSettings::SansSerifFont, QLatin1String("Arial"));
       
   464     d->fontFamilies.insert(QWebSettings::CursiveFont, QLatin1String("Arial"));
       
   465     d->fontFamilies.insert(QWebSettings::FantasyFont, QLatin1String("Arial"));
       
   466 
       
   467     d->attributes.insert(QWebSettings::AutoLoadImages, true);
       
   468     d->attributes.insert(QWebSettings::DnsPrefetchEnabled, false);
       
   469     d->attributes.insert(QWebSettings::JavascriptEnabled, true);
       
   470     d->attributes.insert(QWebSettings::SpatialNavigationEnabled, false);
       
   471     d->attributes.insert(QWebSettings::LinksIncludedInFocusChain, true);
       
   472     d->attributes.insert(QWebSettings::ZoomTextOnly, false);
       
   473     d->attributes.insert(QWebSettings::PrintElementBackgrounds, true);
       
   474     d->attributes.insert(QWebSettings::OfflineStorageDatabaseEnabled, false);
       
   475     d->attributes.insert(QWebSettings::OfflineWebApplicationCacheEnabled, false);
       
   476     d->attributes.insert(QWebSettings::LocalStorageEnabled, false);
       
   477     d->attributes.insert(QWebSettings::LocalContentCanAccessRemoteUrls, false);
       
   478     d->attributes.insert(QWebSettings::LocalContentCanAccessFileUrls, true);
       
   479     d->attributes.insert(QWebSettings::AcceleratedCompositingEnabled, true);
       
   480     d->attributes.insert(QWebSettings::WebGLEnabled, false);
       
   481     d->attributes.insert(QWebSettings::TiledBackingStoreEnabled, false);
       
   482     d->attributes.insert(QWebSettings::FrameFlatteningEnabled, false);
       
   483     d->attributes.insert(QWebSettings::SiteSpecificQuirksEnabled, true);
       
   484     d->offlineStorageDefaultQuota = 5 * 1024 * 1024;
       
   485     d->defaultTextEncoding = QLatin1String("iso-8859-1");
       
   486 }
       
   487 
       
   488 /*!
       
   489     \internal
       
   490 */
       
   491 QWebSettings::QWebSettings(WebCore::Settings* settings)
       
   492     : d(new QWebSettingsPrivate(settings))
       
   493 {
       
   494     d->settings = settings;
       
   495     d->apply();
       
   496     allSettings()->append(d);
       
   497 }
       
   498 
       
   499 /*!
       
   500     \internal
       
   501 */
       
   502 QWebSettings::~QWebSettings()
       
   503 {
       
   504     if (d->settings)
       
   505         allSettings()->removeAll(d);
       
   506 
       
   507     delete d;
       
   508 }
       
   509 
       
   510 /*!
       
   511     Sets the font size for \a type to \a size.
       
   512 */
       
   513 void QWebSettings::setFontSize(FontSize type, int size)
       
   514 {
       
   515     d->fontSizes.insert(type, size);
       
   516     d->apply();
       
   517 }
       
   518 
       
   519 /*!
       
   520     Returns the default font size for \a type.
       
   521 */
       
   522 int QWebSettings::fontSize(FontSize type) const
       
   523 {
       
   524     int defaultValue = 0;
       
   525     if (d->settings) {
       
   526         QWebSettingsPrivate* global = QWebSettings::globalSettings()->d;
       
   527         defaultValue = global->fontSizes.value(type);
       
   528     }
       
   529     return d->fontSizes.value(type, defaultValue);
       
   530 }
       
   531 
       
   532 /*!
       
   533     Resets the font size for \a type to the size specified in the global
       
   534     settings object.
       
   535 
       
   536     This function has no effect on the global QWebSettings instance.
       
   537 */
       
   538 void QWebSettings::resetFontSize(FontSize type)
       
   539 {
       
   540     if (d->settings) {
       
   541         d->fontSizes.remove(type);
       
   542         d->apply();
       
   543     }
       
   544 }
       
   545 
       
   546 /*!
       
   547     Specifies the location of a user stylesheet to load with every web page.
       
   548 
       
   549     The \a location must be either a path on the local filesystem, or a data URL
       
   550     with UTF-8 and Base64 encoded data, such as:
       
   551 
       
   552     "data:text/css;charset=utf-8;base64,cCB7IGJhY2tncm91bmQtY29sb3I6IHJlZCB9Ow=="
       
   553 
       
   554     \note If the base64 data is not valid, the style will not be applied.
       
   555 
       
   556     \sa userStyleSheetUrl()
       
   557 */
       
   558 void QWebSettings::setUserStyleSheetUrl(const QUrl& location)
       
   559 {
       
   560     d->userStyleSheetLocation = location;
       
   561     d->apply();
       
   562 }
       
   563 
       
   564 /*!
       
   565     Returns the location of the user stylesheet.
       
   566 
       
   567     \sa setUserStyleSheetUrl()
       
   568 */
       
   569 QUrl QWebSettings::userStyleSheetUrl() const
       
   570 {
       
   571     return d->userStyleSheetLocation;
       
   572 }
       
   573 
       
   574 /*!
       
   575     \since 4.6
       
   576     Specifies the default text encoding system.
       
   577 
       
   578     The \a encoding, must be a string describing an encoding such as "utf-8",
       
   579     "iso-8859-1", etc. If left empty a default value will be used. For a more
       
   580     extensive list of encoding names see \l{QTextCodec}
       
   581 
       
   582     \sa defaultTextEncoding()
       
   583 */
       
   584 void QWebSettings::setDefaultTextEncoding(const QString& encoding)
       
   585 {
       
   586     d->defaultTextEncoding = encoding;
       
   587     d->apply();
       
   588 }
       
   589 
       
   590 /*!
       
   591     \since 4.6
       
   592     Returns the default text encoding.
       
   593 
       
   594     \sa setDefaultTextEncoding()
       
   595 */
       
   596 QString QWebSettings::defaultTextEncoding() const
       
   597 {
       
   598     return d->defaultTextEncoding;
       
   599 }
       
   600 
       
   601 /*!
       
   602     Sets the path of the icon database to \a path. The icon database is used
       
   603     to store "favicons" associated with web sites.
       
   604 
       
   605     \a path must point to an existing directory.
       
   606 
       
   607     Setting an empty path disables the icon database.
       
   608 
       
   609     \sa iconDatabasePath(), clearIconDatabase()
       
   610 */
       
   611 void QWebSettings::setIconDatabasePath(const QString& path)
       
   612 {
       
   613     WebCore::iconDatabase()->delayDatabaseCleanup();
       
   614 
       
   615     if (!path.isEmpty()) {
       
   616         WebCore::iconDatabase()->setEnabled(true);
       
   617         QFileInfo info(path);
       
   618         if (info.isDir() && info.isWritable())
       
   619             WebCore::iconDatabase()->open(path);
       
   620     } else {
       
   621         WebCore::iconDatabase()->setEnabled(false);
       
   622         WebCore::iconDatabase()->close();
       
   623     }
       
   624 }
       
   625 
       
   626 /*!
       
   627     Returns the path of the icon database or an empty string if the icon
       
   628     database is disabled.
       
   629 
       
   630     \sa setIconDatabasePath(), clearIconDatabase()
       
   631 */
       
   632 QString QWebSettings::iconDatabasePath()
       
   633 {
       
   634     if (WebCore::iconDatabase()->isEnabled() && WebCore::iconDatabase()->isOpen())
       
   635         return WebCore::iconDatabase()->databasePath();
       
   636     else
       
   637         return QString();
       
   638 }
       
   639 
       
   640 /*!
       
   641     Clears the icon database.
       
   642 */
       
   643 void QWebSettings::clearIconDatabase()
       
   644 {
       
   645     if (WebCore::iconDatabase()->isEnabled() && WebCore::iconDatabase()->isOpen())
       
   646         WebCore::iconDatabase()->removeAllIcons();
       
   647 }
       
   648 
       
   649 /*!
       
   650     Returns the web site's icon for \a url.
       
   651 
       
   652     If the web site does not specify an icon \bold OR if the icon is not in the
       
   653     database, a null QIcon is returned.
       
   654 
       
   655     \note The returned icon's size is arbitrary.
       
   656 
       
   657     \sa setIconDatabasePath()
       
   658 */
       
   659 QIcon QWebSettings::iconForUrl(const QUrl& url)
       
   660 {
       
   661     WebCore::Image* image = WebCore::iconDatabase()->iconForPageURL(WebCore::KURL(url).string(),
       
   662                                 WebCore::IntSize(16, 16));
       
   663     if (!image)
       
   664         return QPixmap();
       
   665 
       
   666     QPixmap* icon = image->nativeImageForCurrentFrame();
       
   667     if (!icon)
       
   668         return QPixmap();
       
   669 
       
   670     return* icon;
       
   671 }
       
   672 
       
   673 /*
       
   674     Returns the plugin database object.
       
   675 
       
   676 QWebPluginDatabase *QWebSettings::pluginDatabase()
       
   677 {
       
   678     static QWebPluginDatabase* database = 0;
       
   679     if (!database)
       
   680         database = new QWebPluginDatabase();
       
   681     return database;
       
   682 }
       
   683 */
       
   684 
       
   685 /*!
       
   686     Sets \a graphic to be drawn when QtWebKit needs to draw an image of the
       
   687     given \a type.
       
   688 
       
   689     For example, when an image cannot be loaded, the pixmap specified by
       
   690     \l{QWebSettings::WebGraphic}{MissingImageGraphic} is drawn instead.
       
   691 
       
   692     \sa webGraphic()
       
   693 */
       
   694 void QWebSettings::setWebGraphic(WebGraphic type, const QPixmap& graphic)
       
   695 {
       
   696     WebGraphicHash* h = graphics();
       
   697     if (graphic.isNull())
       
   698         h->remove(type);
       
   699     else
       
   700         h->insert(type, graphic);
       
   701 }
       
   702 
       
   703 /*!
       
   704     Returns a previously set pixmap used to draw replacement graphics of the
       
   705     specified \a type.
       
   706 
       
   707     \sa setWebGraphic()
       
   708 */
       
   709 QPixmap QWebSettings::webGraphic(WebGraphic type)
       
   710 {
       
   711     return graphics()->value(type);
       
   712 }
       
   713 
       
   714 /*!
       
   715     Frees up as much memory as possible by cleaning all memory caches such
       
   716     as page, object and font cache.
       
   717 
       
   718     \since 4.6
       
   719  */
       
   720 void QWebSettings::clearMemoryCaches()
       
   721 {
       
   722     // Turn the cache on and off.  Disabling the object cache will remove all
       
   723     // resources from the cache.  They may still live on if they are referenced
       
   724     // by some Web page though.
       
   725     if (!WebCore::cache()->disabled()) {
       
   726         WebCore::cache()->setDisabled(true);
       
   727         WebCore::cache()->setDisabled(false);
       
   728     }
       
   729 
       
   730     int pageCapacity = WebCore::pageCache()->capacity();
       
   731     // Setting size to 0, makes all pages be released.
       
   732     WebCore::pageCache()->setCapacity(0);
       
   733     WebCore::pageCache()->releaseAutoreleasedPagesNow();
       
   734     WebCore::pageCache()->setCapacity(pageCapacity);
       
   735 
       
   736     // Invalidating the font cache and freeing all inactive font data.
       
   737     WebCore::fontCache()->invalidate();
       
   738 
       
   739     // Empty the Cross-Origin Preflight cache
       
   740     WebCore::CrossOriginPreflightResultCache::shared().empty();
       
   741 }
       
   742 
       
   743 /*!
       
   744     Sets the maximum number of pages to hold in the memory page cache to \a pages.
       
   745 
       
   746     The Page Cache allows for a nicer user experience when navigating forth or back
       
   747     to pages in the forward/back history, by pausing and resuming up to \a pages.
       
   748 
       
   749     For more information about the feature, please refer to:
       
   750 
       
   751     http://webkit.org/blog/427/webkit-page-cache-i-the-basics/
       
   752 */
       
   753 void QWebSettings::setMaximumPagesInCache(int pages)
       
   754 {
       
   755     QWebSettingsPrivate* global = QWebSettings::globalSettings()->d;
       
   756     WebCore::pageCache()->setCapacity(qMax(0, pages));
       
   757     global->apply();
       
   758 }
       
   759 
       
   760 /*!
       
   761     Returns the maximum number of web pages that are kept in the memory cache.
       
   762 */
       
   763 int QWebSettings::maximumPagesInCache()
       
   764 {
       
   765     return WebCore::pageCache()->capacity();
       
   766 }
       
   767 
       
   768 /*!
       
   769    Specifies the capacities for the memory cache for dead objects such as
       
   770    stylesheets or scripts.
       
   771 
       
   772    The \a cacheMinDeadCapacity specifies the \e minimum number of bytes that
       
   773    dead objects should consume when the cache is under pressure.
       
   774 
       
   775    \a cacheMaxDead is the \e maximum number of bytes that dead objects should
       
   776    consume when the cache is \bold not under pressure.
       
   777 
       
   778    \a totalCapacity specifies the \e maximum number of bytes that the cache
       
   779    should consume \bold overall.
       
   780 
       
   781    The cache is enabled by default. Calling setObjectCacheCapacities(0, 0, 0)
       
   782    will disable the cache. Calling it with one non-zero enables it again.
       
   783 */
       
   784 void QWebSettings::setObjectCacheCapacities(int cacheMinDeadCapacity, int cacheMaxDead, int totalCapacity)
       
   785 {
       
   786     bool disableCache = !cacheMinDeadCapacity && !cacheMaxDead && !totalCapacity;
       
   787     WebCore::cache()->setDisabled(disableCache);
       
   788 
       
   789     WebCore::cache()->setCapacities(qMax(0, cacheMinDeadCapacity),
       
   790                                     qMax(0, cacheMaxDead),
       
   791                                     qMax(0, totalCapacity));
       
   792 }
       
   793 
       
   794 /*!
       
   795     Sets the actual font family to \a family for the specified generic family,
       
   796     \a which.
       
   797 */
       
   798 void QWebSettings::setFontFamily(FontFamily which, const QString& family)
       
   799 {
       
   800     d->fontFamilies.insert(which, family);
       
   801     d->apply();
       
   802 }
       
   803 
       
   804 /*!
       
   805     Returns the actual font family for the specified generic font family,
       
   806     \a which.
       
   807 */
       
   808 QString QWebSettings::fontFamily(FontFamily which) const
       
   809 {
       
   810     QString defaultValue;
       
   811     if (d->settings) {
       
   812         QWebSettingsPrivate* global = QWebSettings::globalSettings()->d;
       
   813         defaultValue = global->fontFamilies.value(which);
       
   814     }
       
   815     return d->fontFamilies.value(which, defaultValue);
       
   816 }
       
   817 
       
   818 /*!
       
   819     Resets the actual font family specified by \a which to the one set
       
   820     in the global QWebSettings instance.
       
   821 
       
   822     This function has no effect on the global QWebSettings instance.
       
   823 */
       
   824 void QWebSettings::resetFontFamily(FontFamily which)
       
   825 {
       
   826     if (d->settings) {
       
   827         d->fontFamilies.remove(which);
       
   828         d->apply();
       
   829     }
       
   830 }
       
   831 
       
   832 /*!
       
   833     \fn void QWebSettings::setAttribute(WebAttribute attribute, bool on)
       
   834 
       
   835     Enables or disables the specified \a attribute feature depending on the
       
   836     value of \a on.
       
   837 */
       
   838 void QWebSettings::setAttribute(WebAttribute attr, bool on)
       
   839 {
       
   840     d->attributes.insert(attr, on);
       
   841     d->apply();
       
   842 }
       
   843 
       
   844 /*!
       
   845     \fn bool QWebSettings::testAttribute(WebAttribute attribute) const
       
   846 
       
   847     Returns true if \a attribute is enabled; otherwise returns false.
       
   848 */
       
   849 bool QWebSettings::testAttribute(WebAttribute attr) const
       
   850 {
       
   851     bool defaultValue = false;
       
   852     if (d->settings) {
       
   853         QWebSettingsPrivate* global = QWebSettings::globalSettings()->d;
       
   854         defaultValue = global->attributes.value(attr);
       
   855     }
       
   856     return d->attributes.value(attr, defaultValue);
       
   857 }
       
   858 
       
   859 /*!
       
   860     \fn void QWebSettings::resetAttribute(WebAttribute attribute)
       
   861 
       
   862     Resets the setting of \a attribute to the value specified in the
       
   863     global QWebSettings instance.
       
   864 
       
   865     This function has no effect on the global QWebSettings instance.
       
   866 
       
   867     \sa globalSettings()
       
   868 */
       
   869 void QWebSettings::resetAttribute(WebAttribute attr)
       
   870 {
       
   871     if (d->settings) {
       
   872         d->attributes.remove(attr);
       
   873         d->apply();
       
   874     }
       
   875 }
       
   876 
       
   877 /*!
       
   878     \since 4.5
       
   879 
       
   880     Sets \a path as the save location for HTML5 client-side database storage data.
       
   881 
       
   882     \a path must point to an existing directory.
       
   883 
       
   884     Setting an empty path disables the feature.
       
   885 
       
   886     Support for client-side databases can enabled by setting the
       
   887     \l{QWebSettings::OfflineStorageDatabaseEnabled}{OfflineStorageDatabaseEnabled} attribute.
       
   888 
       
   889     \sa offlineStoragePath()
       
   890 */
       
   891 void QWebSettings::setOfflineStoragePath(const QString& path)
       
   892 {
       
   893 #if ENABLE(DATABASE)
       
   894     WebCore::DatabaseTracker::tracker().setDatabaseDirectoryPath(path);
       
   895 #endif
       
   896 }
       
   897 
       
   898 /*!
       
   899     \since 4.5
       
   900 
       
   901     Returns the path of the HTML5 client-side database storage or an empty string if the
       
   902     feature is disabled.
       
   903 
       
   904     \sa setOfflineStoragePath()
       
   905 */
       
   906 QString QWebSettings::offlineStoragePath()
       
   907 {
       
   908 #if ENABLE(DATABASE)
       
   909     return WebCore::DatabaseTracker::tracker().databaseDirectoryPath();
       
   910 #else
       
   911     return QString();
       
   912 #endif
       
   913 }
       
   914 
       
   915 /*!
       
   916     \since 4.5
       
   917 
       
   918     Sets the value of the default quota for new offline storage databases
       
   919     to \a maximumSize.
       
   920 */
       
   921 void QWebSettings::setOfflineStorageDefaultQuota(qint64 maximumSize)
       
   922 {
       
   923     QWebSettings::globalSettings()->d->offlineStorageDefaultQuota = maximumSize;
       
   924 }
       
   925 
       
   926 /*!
       
   927     \since 4.5
       
   928 
       
   929     Returns the value of the default quota for new offline storage databases.
       
   930 */
       
   931 qint64 QWebSettings::offlineStorageDefaultQuota()
       
   932 {
       
   933     return QWebSettings::globalSettings()->d->offlineStorageDefaultQuota;
       
   934 }
       
   935 
       
   936 /*!
       
   937     \since 4.6
       
   938 
       
   939     Sets the path for HTML5 offline web application cache storage to \a path.
       
   940 
       
   941     An application cache acts like an HTTP cache in some sense. For documents
       
   942     that use the application cache via JavaScript, the loader engine will
       
   943     first ask the application cache for the contents, before hitting the
       
   944     network.
       
   945 
       
   946     The feature is described in details at:
       
   947     http://dev.w3.org/html5/spec/Overview.html#appcache
       
   948 
       
   949     \a path must point to an existing directory.
       
   950 
       
   951     Setting an empty path disables the feature.
       
   952 
       
   953     Support for offline web application cache storage can enabled by setting the
       
   954     \l{QWebSettings::OfflineWebApplicationCacheEnabled}{OfflineWebApplicationCacheEnabled} attribute.
       
   955 
       
   956     \sa offlineWebApplicationCachePath()
       
   957 */
       
   958 void QWebSettings::setOfflineWebApplicationCachePath(const QString& path)
       
   959 {
       
   960 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
       
   961     WebCore::cacheStorage().setCacheDirectory(path);
       
   962 #endif
       
   963 }
       
   964 
       
   965 /*!
       
   966     \since 4.6
       
   967 
       
   968     Returns the path of the HTML5 offline web application cache storage
       
   969     or an empty string if the feature is disabled.
       
   970 
       
   971     \sa setOfflineWebApplicationCachePath()
       
   972 */
       
   973 QString QWebSettings::offlineWebApplicationCachePath()
       
   974 {
       
   975 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
       
   976     return WebCore::cacheStorage().cacheDirectory();
       
   977 #else
       
   978     return QString();
       
   979 #endif
       
   980 }
       
   981 
       
   982 /*!
       
   983     \since 4.6
       
   984 
       
   985     Sets the value of the quota for the offline web application cache
       
   986     to \a maximumSize.
       
   987 */
       
   988 void QWebSettings::setOfflineWebApplicationCacheQuota(qint64 maximumSize)
       
   989 {
       
   990 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
       
   991     WebCore::cacheStorage().empty();
       
   992     WebCore::cacheStorage().vacuumDatabaseFile();
       
   993     WebCore::cacheStorage().setMaximumSize(maximumSize);
       
   994 #endif
       
   995 }
       
   996 
       
   997 /*!
       
   998     \since 4.6
       
   999 
       
  1000     Returns the value of the quota for the offline web application cache.
       
  1001 */
       
  1002 qint64 QWebSettings::offlineWebApplicationCacheQuota()
       
  1003 {
       
  1004 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
       
  1005     return WebCore::cacheStorage().maximumSize();
       
  1006 #else
       
  1007     return 0;
       
  1008 #endif
       
  1009 }
       
  1010 
       
  1011 /*!
       
  1012     \since 4.6
       
  1013 
       
  1014     Sets the path for HTML5 local storage to \a path.
       
  1015     
       
  1016     For more information on HTML5 local storage see the
       
  1017     \l{http://www.w3.org/TR/webstorage/#the-localstorage-attribute}{Web Storage standard}.
       
  1018     
       
  1019     Support for local storage can enabled by setting the
       
  1020     \l{QWebSettings::LocalStorageEnabled}{LocalStorageEnabled} attribute.     
       
  1021 
       
  1022     \sa localStoragePath()
       
  1023 */
       
  1024 void QWebSettings::setLocalStoragePath(const QString& path)
       
  1025 {
       
  1026     d->localStoragePath = path;
       
  1027     d->apply();
       
  1028 }
       
  1029 
       
  1030 /*!
       
  1031     \since 4.6
       
  1032 
       
  1033     Returns the path for HTML5 local storage.
       
  1034     
       
  1035     \sa setLocalStoragePath()
       
  1036 */
       
  1037 QString QWebSettings::localStoragePath() const
       
  1038 {
       
  1039     return d->localStoragePath;
       
  1040 }
       
  1041 
       
  1042 /*!
       
  1043     \since 4.6
       
  1044 
       
  1045     Enables WebKit data persistence and sets the path to \a path.
       
  1046     If \a path is empty, the user-specific data location specified by
       
  1047     \l{QDesktopServices::DataLocation}{DataLocation} will be used instead.
       
  1048 
       
  1049     This method will simultaneously set and enable the iconDatabasePath(),
       
  1050     localStoragePath(), offlineStoragePath() and offlineWebApplicationCachePath().
       
  1051 
       
  1052     \sa localStoragePath()
       
  1053 */
       
  1054 void QWebSettings::enablePersistentStorage(const QString& path)
       
  1055 {
       
  1056     QString storagePath;
       
  1057 
       
  1058     if (path.isEmpty()) {
       
  1059 #ifndef QT_NO_DESKTOPSERVICES
       
  1060         storagePath = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
       
  1061 #endif
       
  1062         if (storagePath.isEmpty())
       
  1063             storagePath = WebCore::pathByAppendingComponent(QDir::homePath(), QCoreApplication::applicationName());
       
  1064     } else
       
  1065         storagePath = path;
       
  1066 
       
  1067     WebCore::makeAllDirectories(storagePath);
       
  1068 
       
  1069     QWebSettings::setIconDatabasePath(storagePath);
       
  1070     QWebSettings::setOfflineWebApplicationCachePath(storagePath);
       
  1071     QWebSettings::setOfflineStoragePath(WebCore::pathByAppendingComponent(storagePath, "Databases"));
       
  1072     QWebSettings::globalSettings()->setLocalStoragePath(WebCore::pathByAppendingComponent(storagePath, "LocalStorage"));
       
  1073     QWebSettings::globalSettings()->setAttribute(QWebSettings::LocalStorageEnabled, true);
       
  1074     QWebSettings::globalSettings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true);
       
  1075     QWebSettings::globalSettings()->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, true);
       
  1076 }
       
  1077 
       
  1078 /*!
       
  1079     \fn QWebSettingsPrivate* QWebSettings::handle() const
       
  1080     \internal
       
  1081 */