Changeset 47283 in webkit


Ignore:
Timestamp:
Aug 14, 2009 7:21:06 AM (15 years ago)
Author:
Simon Hausmann
Message:

WebKit/qt: [Qt] Public API to configure the storage path for HTML5 localStorage
https://bugs.webkit.org/show_bug.cgi?id=28036

Patch by Laszlo Gombos <Laszlo Gombos> on 2009-08-14
Reviewed by Simon Hausmann.

Disables LocalStorage for QtWebKit by default by setting
QWebSettings::LocalStorageEnabled to false.

Sets up a default for the LocalStorage path so that clients would only
need to enable the LocalStorageEnabled setting to turn on LocalStoragre
support.

Turn on LocalStorage support for QtLauncher and the relevant test
since LocalStorage is now disabled by default for QtWebkit.

  • Api/qwebpage.cpp:

(defaultCachePath):
(initializeApplicationCachePathIfNecessary):
(QWebPagePrivate::QWebPagePrivate):

  • Api/qwebsettings.cpp:

(QWebSettingsPrivate::apply):
(QWebSettings::QWebSettings):
(QWebSettings::setLocalStoragePath):
(QWebSettings::localStoragePath):

  • Api/qwebsettings.h:
  • QtLauncher/main.cpp:

(main):

  • tests/qwebpage/tst_qwebpage.cpp:

(tst_QWebPage::multiplePageGroupsAndLocalStorage):

WebKitTools: [Qt] Public API to configure the storage path for HTML5 localStorage
https://bugs.webkit.org/show_bug.cgi?id=28036

Patch by Laszlo Gombos <Laszlo Gombos> on 2009-08-14
Reviewed by Simon Hausmann.

Turn on LocalStorage support for Qt DumpRenderTree since
LocalStorage is now disabled by defult for QtWebkit.

  • DumpRenderTree/qt/DumpRenderTree.cpp:

(WebCore::WebPage::WebPage):

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/qt/Api/qwebpage.cpp

    r47101 r47283  
    266266}
    267267
     268static QString defaultCachePath()
     269{
     270    // Determine the default cache location
     271    QString cachePath;
     272   
     273#if QT_VERSION >= 0x040500
     274    cachePath = QDesktopServices::storageLocation(QDesktopServices::CacheLocation);
     275#else
     276    cachePath = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
     277#endif
     278                               
     279    if (cachePath.isEmpty())
     280        cachePath = QDir::homePath() + QLatin1String("/.") + QCoreApplication::applicationName();
     281       
     282   return cachePath;
     283}
     284
    268285static void initializeApplicationCachePathIfNecessary()
    269286{
    270 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
     287
    271288    static bool initialized = false;
    272        
     289   
    273290    if (initialized)
    274291        return;
    275292
    276     // Determine the path for HTML5 Application Cache DB
    277     QString appCachePath;
    278 #if QT_VERSION >= 0x040500
    279     appCachePath = QDesktopServices::storageLocation(QDesktopServices::CacheLocation);
    280 #else
    281     appCachePath = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
    282 #endif
    283 
    284     if (appCachePath.isEmpty())
    285         appCachePath = QDir::homePath() + QLatin1String("/.") + QCoreApplication::applicationName();
    286 
    287     WebCore::cacheStorage().setCacheDirectory(appCachePath);
     293    // Set HTML5 Application Cache default location
     294    QWebSettings::setOfflineWebApplicationCachePath(defaultCachePath());
     295   
    288296    initialized = true;
    289 #endif
    290297}                                               
    291298
     
    310317
    311318    settings = new QWebSettings(page->settings());
     319   
     320    // Set HTML5 localStorage default location
     321    settings->setLocalStoragePath(WebCore::pathByAppendingComponent(defaultCachePath(), "LocalStorage"));
    312322
    313323#ifndef QT_NO_UNDOSTACK
  • trunk/WebKit/qt/Api/qwebsettings.cpp

    r46975 r47283  
    5656    QUrl userStyleSheetLocation;
    5757    QString defaultTextEncoding;
    58     QString localStorageDatabasePath;
     58    QString localStoragePath;
    5959    QString offlineWebApplicationCachePath;
    6060    qint64 offlineStorageDefaultQuota;
     
    168168        settings->setDefaultTextEncodingName(encoding);
    169169
    170         QString localStoragePath = !localStorageDatabasePath.isEmpty() ? localStorageDatabasePath : global->localStorageDatabasePath;
    171         settings->setLocalStorageDatabasePath(localStoragePath);
     170        QString storagePath = !localStoragePath.isEmpty() ? localStoragePath : global->localStoragePath;
     171        settings->setLocalStorageDatabasePath(storagePath);
    172172
    173173        value = attributes.value(QWebSettings::ZoomTextOnly,
     
    187187        settings->setOfflineWebApplicationCacheEnabled(value);
    188188
    189         value = attributes.value(QWebSettings::LocalStorageDatabaseEnabled,
    190                                       global->attributes.value(QWebSettings::LocalStorageDatabaseEnabled));
     189        value = attributes.value(QWebSettings::LocalStorageEnabled,
     190                                      global->attributes.value(QWebSettings::LocalStorageEnabled));
     191                                                                                                                                 
    191192        settings->setLocalStorageEnabled(value);
    192193
     
    327328    \value OfflineWebApplicationCacheEnabled Specifies whether support for the HTML 5
    328329        web application cache feature is enabled or not.
    329     \value LocalStorageDatabaseEnabled Specifies whether support for the HTML 5
    330         local storage feature is enabled or not.
     330    \value LocalStorageEnabled Specifies whether support for the HTML 5
     331        local storage feature is enabled or not. Disabled by default.
    331332    \value LocalContentCanAccessRemoteUrls Specifies whether locally loaded documents are allowed to access remote urls.
    332333*/
     
    357358    d->attributes.insert(QWebSettings::OfflineStorageDatabaseEnabled, true);
    358359    d->attributes.insert(QWebSettings::OfflineWebApplicationCacheEnabled, true);
    359     d->attributes.insert(QWebSettings::LocalStorageDatabaseEnabled, true);
     360    d->attributes.insert(QWebSettings::LocalStorageEnabled, false);
    360361    d->attributes.insert(QWebSettings::LocalContentCanAccessRemoteUrls, true);
    361362    d->offlineStorageDefaultQuota = 5 * 1024 * 1024;
     
    868869}
    869870
    870 /*
    871     \since 4.5
     871/*!
     872    \since 4.6
    872873    \relates QWebSettings
    873874
    874     Sets the path for HTML5 local storage databases to \a path.
    875 
    876     \a path must point to an existing directory where the cache is stored.
    877 
    878     Setting an empty path disables the feature.
    879 
    880     \sa localStorageDatabasePath()
    881 */
    882 void QWEBKIT_EXPORT qt_websettings_setLocalStorageDatabasePath(QWebSettings* settings, const QString& path)
    883 {
    884     QWebSettingsPrivate* d = settings->handle();
    885     d->localStorageDatabasePath = path;
     875    Sets the path for HTML5 local storage to \a path.
     876   
     877    For more information on HTML5 local storage see the
     878    \l{http://www.w3.org/TR/webstorage/#the-localstorage-attribute}{Web Storage standard}.
     879   
     880    Support for local storage can enabled by setting the
     881    \l{QWebSettings::LocalStorageEnabled}{LocalStorageEnabled} attribute.     
     882
     883    \sa localStoragePath()
     884*/
     885void QWebSettings::setLocalStoragePath(const QString& path)
     886{
     887    d->localStoragePath = path;
    886888    d->apply();
    887889}
    888890
    889 /*
    890     \since 4.5
     891/*!
     892    \since 4.6
    891893    \relates QWebSettings
    892894
    893     Returns the path for HTML5 local storage databases
    894     or an empty string if the feature is disabled.
    895 
    896     \sa setLocalStorageDatabasePath()
    897 */
    898 QString QWEBKIT_EXPORT qt_websettings_localStorageDatabasePath(QWebSettings* settings)
    899 {
    900     return settings->handle()->localStorageDatabasePath;
     895    Returns the path for HTML5 local storage.
     896   
     897    The path is initialized to a directory called LocalStorage under
     898    the user-specific cache data location specified by
     899    \l{QDesktopServices::CacheLocation}{CacheLocation}.
     900   
     901    \sa setLocalStoragePath()
     902*/
     903QString QWebSettings::localStoragePath() const
     904{
     905    return d->localStoragePath;
    901906}
    902907
  • trunk/WebKit/qt/Api/qwebsettings.h

    r46762 r47283  
    6363        OfflineStorageDatabaseEnabled,
    6464        OfflineWebApplicationCacheEnabled,
    65         LocalStorageDatabaseEnabled,
     65        LocalStorageEnabled,
     66#ifdef QT_DEPRECATED
     67        LocalStorageDatabaseEnabled = LocalStorageEnabled,
     68#endif
    6669        LocalContentCanAccessRemoteUrls
    6770    };
     
    122125    static void setOfflineWebApplicationCacheQuota(qint64 maximumSize);
    123126    static qint64 offlineWebApplicationCacheQuota();
     127   
     128    void setLocalStoragePath(const QString& path);
     129    QString localStoragePath() const;
    124130
    125131    static void clearMemoryCaches();
  • trunk/WebKit/qt/ChangeLog

    r47282 r47283  
     12009-08-14  Laszlo Gombos  <laszlo.1.gombos@nokia.com>
     2
     3        Reviewed by Simon Hausmann.
     4
     5        [Qt] Public API to configure the storage path for HTML5 localStorage
     6        https://bugs.webkit.org/show_bug.cgi?id=28036
     7
     8        Disables LocalStorage for QtWebKit by default by setting
     9        QWebSettings::LocalStorageEnabled to false.
     10
     11        Sets up a default for the LocalStorage path so that clients would only
     12        need to enable the LocalStorageEnabled setting to turn on LocalStoragre
     13        support.
     14
     15        Turn on LocalStorage support for QtLauncher and the relevant test
     16        since LocalStorage is now disabled by default for QtWebkit.
     17
     18        * Api/qwebpage.cpp:
     19        (defaultCachePath):
     20        (initializeApplicationCachePathIfNecessary):
     21        (QWebPagePrivate::QWebPagePrivate):
     22        * Api/qwebsettings.cpp:
     23        (QWebSettingsPrivate::apply):
     24        (QWebSettings::QWebSettings):
     25        (QWebSettings::setLocalStoragePath):
     26        (QWebSettings::localStoragePath):
     27        * Api/qwebsettings.h:
     28        * QtLauncher/main.cpp:
     29        (main):
     30        * tests/qwebpage/tst_qwebpage.cpp:
     31        (tst_QWebPage::multiplePageGroupsAndLocalStorage):
     32
    1332009-08-14  Yael Aharon  <yael.aharon@nokia.com>
    234
  • trunk/WebKit/qt/QtLauncher/main.cpp

    r47156 r47283  
    444444    QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled, true);
    445445    QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
     446    QWebSettings::globalSettings()->setAttribute(QWebSettings::LocalStorageEnabled, true);
    446447
    447448    const QStringList args = app.arguments();
  • trunk/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp

    r47282 r47283  
    629629void QWEBKIT_EXPORT qt_webpage_setGroupName(QWebPage* page, const QString& groupName);
    630630QString QWEBKIT_EXPORT qt_webpage_groupName(QWebPage* page);
    631 void QWEBKIT_EXPORT qt_websettings_setLocalStorageDatabasePath(QWebSettings* settings, const QString& path);
    632631
    633632void tst_QWebPage::multiplePageGroupsAndLocalStorage()
     
    640639    QWebView view2;
    641640
    642     qt_websettings_setLocalStorageDatabasePath(view1.page()->settings(), QDir::toNativeSeparators(QDir::currentPath() + "/path1"));
     641    view1.page()->settings()->setAttribute(QWebSettings::LocalStorageEnabled, true);
     642    view1.page()->settings()->setLocalStoragePath(QDir::toNativeSeparators(QDir::currentPath() + "/path1"));
    643643    qt_webpage_setGroupName(view1.page(), "group1");
    644     qt_websettings_setLocalStorageDatabasePath(view2.page()->settings(), QDir::toNativeSeparators(QDir::currentPath() + "/path2"));
     644    view2.page()->settings()->setAttribute(QWebSettings::LocalStorageEnabled, true);   
     645    view2.page()->settings()->setLocalStoragePath(QDir::toNativeSeparators(QDir::currentPath() + "/path2"));
    645646    qt_webpage_setGroupName(view2.page(), "group2");
    646647    QCOMPARE(qt_webpage_groupName(view1.page()), QString("group1"));
  • trunk/WebKitTools/ChangeLog

    r47280 r47283  
     12009-08-14  Laszlo Gombos  <laszlo.1.gombos@nokia.com>
     2
     3        Reviewed by Simon Hausmann.
     4
     5        [Qt] Public API to configure the storage path for HTML5 localStorage
     6        https://bugs.webkit.org/show_bug.cgi?id=28036
     7
     8        Turn on LocalStorage support for Qt DumpRenderTree since
     9        LocalStorage is now disabled by defult for QtWebkit.
     10
     11        * DumpRenderTree/qt/DumpRenderTree.cpp:
     12        (WebCore::WebPage::WebPage):
     13
    1142009-08-14  Xan Lopez  <xlopez@igalia.com>
    215
  • trunk/WebKitTools/DumpRenderTree/qt/DumpRenderTree.cpp

    r46905 r47283  
    110110    settings()->setAttribute(QWebSettings::LinksIncludedInFocusChain, false);
    111111    settings()->setAttribute(QWebSettings::PluginsEnabled, true);
     112    settings()->setAttribute(QWebSettings::LocalStorageEnabled, true);
    112113    connect(this, SIGNAL(geometryChangeRequested(const QRect &)),
    113114            this, SLOT(setViewGeometry(const QRect & )));
Note: See TracChangeset for help on using the changeset viewer.