[Qt][WK2] Default directories and paths are missing for LocalStorage, Database and...
authoralexis.menard@openbossa.org <alexis.menard@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Oct 2011 14:20:22 +0000 (14:20 +0000)
committeralexis.menard@openbossa.org <alexis.menard@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Oct 2011 14:20:22 +0000 (14:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=69111

Reviewed by Kenneth Rohde Christiansen.

Provide default path for LocalStorage, Database and IconDatabase using QDesktopServices.

Source/WebCore:

No new tests : existing ones should cover.

* platform/qt/CookieJarQt.cpp:
(WebCore::SharedCookieJarQt::SharedCookieJarQt):

Source/WebKit2:

* UIProcess/qt/WebContextQt.cpp:
(WebKit::defaultDataLocation):
(WebKit::WebContext::platformInitializeWebProcess):
(WebKit::WebContext::platformDefaultDatabaseDirectory):
(WebKit::WebContext::platformDefaultIconDatabasePath):
(WebKit::WebContext::platformDefaultLocalStorageDirectory):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96702 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/qt/CookieJarQt.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/qt/WebContextQt.cpp

index ded2bc7..cdbb800 100644 (file)
@@ -1,3 +1,17 @@
+2011-10-05  Alexis Menard  <alexis.menard@openbossa.org>
+
+        [Qt][WK2] Default directories and paths are missing for LocalStorage, Database and IconDatabase.
+        https://bugs.webkit.org/show_bug.cgi?id=69111
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Provide default path for LocalStorage, Database and IconDatabase using QDesktopServices.
+
+        No new tests : existing ones should cover.
+
+        * platform/qt/CookieJarQt.cpp:
+        (WebCore::SharedCookieJarQt::SharedCookieJarQt):
+
 2011-10-05  Patrick Gansterer  <paroga@webkit.org>
 
         Unreviewed build fix for !ENABLE(FILTERS) after r96203.
index 42258f6..f295cf2 100644 (file)
@@ -42,7 +42,6 @@
 #include "qwebpage.h"
 #include "qwebsettings.h"
 #include <QDateTime>
-#include <QDir>
 #include <QNetworkAccessManager>
 #include <QNetworkCookie>
 #include <QSqlQuery>
@@ -227,8 +226,7 @@ SharedCookieJarQt::SharedCookieJarQt(const String& cookieStorageDirectory)
 {
     m_database = QSqlDatabase::addDatabase(QLatin1String("QSQLITE"));
     const QString cookieStoragePath = cookieStorageDirectory;
-    QDir().mkpath(cookieStoragePath + QLatin1String(".QtWebKit/"));
-    const QString dataBaseName = cookieStoragePath + QLatin1String(".QtWebKit/cookies.db");
+    const QString dataBaseName = cookieStoragePath + QLatin1String("cookies.db");
     m_database.setDatabaseName(dataBaseName);
     ensureDatabaseTable();
     loadCookies();
index 8daaffa..96f1747 100644 (file)
@@ -1,3 +1,19 @@
+2011-10-05  Alexis Menard  <alexis.menard@openbossa.org>
+
+        [Qt][WK2] Default directories and paths are missing for LocalStorage, Database and IconDatabase.
+        https://bugs.webkit.org/show_bug.cgi?id=69111
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Provide default path for LocalStorage, Database and IconDatabase using QDesktopServices.
+
+        * UIProcess/qt/WebContextQt.cpp:
+        (WebKit::defaultDataLocation):
+        (WebKit::WebContext::platformInitializeWebProcess):
+        (WebKit::WebContext::platformDefaultDatabaseDirectory):
+        (WebKit::WebContext::platformDefaultIconDatabasePath):
+        (WebKit::WebContext::platformDefaultLocalStorageDirectory):
+
 2011-10-05  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] Use WKRetainPtr for WK types in WebKit2 GTK+
index de8bc4a..d755f3f 100644 (file)
 #include "WebContext.h"
 
 #include "ApplicationCacheStorage.h"
+#include "FileSystem.h"
 #include "WebProcessCreationParameters.h"
+#include <QCoreApplication>
 #include <QDesktopServices>
+#include <QDir>
 #include <QProcess>
 
 namespace WebKit {
 
+static QString defaultDataLocation()
+{
+    static QString s_dataLocation;
+
+    if (!s_dataLocation.isEmpty())
+        return s_dataLocation;
+
+    QString dataLocation = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
+    if (dataLocation.isEmpty())
+        dataLocation = WebCore::pathByAppendingComponent(QDir::homePath(), QCoreApplication::applicationName());
+    s_dataLocation = WebCore::pathByAppendingComponent(dataLocation, ".QtWebKit/");
+    WebCore::makeAllDirectories(s_dataLocation);
+    return s_dataLocation;
+}
+
+static QString s_defaultDatabaseDirectory;
+static QString s_defaultLocalStorageDirectory;
+
 String WebContext::applicationCacheDirectory()
 {
     return WebCore::cacheStorage().cacheDirectory();
@@ -42,7 +63,7 @@ String WebContext::applicationCacheDirectory()
 void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& parameters)
 {
     qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus");
-    parameters.cookieStorageDirectory = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
+    parameters.cookieStorageDirectory = defaultDataLocation();
 }
 
 void WebContext::platformInvalidateContext()
@@ -51,20 +72,27 @@ void WebContext::platformInvalidateContext()
 
 String WebContext::platformDefaultDatabaseDirectory() const
 {
-    // FIXME: Implement.
-    return "";
+    if (!s_defaultDatabaseDirectory.isEmpty())
+        return s_defaultDatabaseDirectory;
+
+    s_defaultDatabaseDirectory = defaultDataLocation() + QLatin1String("Databases");
+    QDir().mkpath(s_defaultDatabaseDirectory);
+    return s_defaultDatabaseDirectory;
 }
 
 String WebContext::platformDefaultIconDatabasePath() const
 {
-    // FIXME: Implement.
-    return "";
+    return defaultDataLocation();
 }
 
 String WebContext::platformDefaultLocalStorageDirectory() const
 {
-    // FIXME: Implement.
-    return "";
+    if (!s_defaultLocalStorageDirectory.isEmpty())
+        return s_defaultLocalStorageDirectory;
+
+    s_defaultLocalStorageDirectory = defaultDataLocation() + QLatin1String("LocalStorage");
+    QDir().mkpath(s_defaultLocalStorageDirectory);
+    return s_defaultLocalStorageDirectory;
 }
 
 } // namespace WebKit