Diff
Modified: trunk/Source/WebKit2/ChangeLog (145516 => 145517)
--- trunk/Source/WebKit2/ChangeLog 2013-03-12 11:14:42 UTC (rev 145516)
+++ trunk/Source/WebKit2/ChangeLog 2013-03-12 11:16:01 UTC (rev 145517)
@@ -1,3 +1,49 @@
+2013-03-11 Jocelyn Turcotte <jocelyn.turco...@digia.com>
+
+ [Qt][WK2] Specify storage paths through the C API
+ https://bugs.webkit.org/show_bug.cgi?id=111435
+
+ Reviewed by Simon Hausmann.
+ Signed off for WebKit2 by Benjamin Poulain.
+
+ The WKIconDatabase should be opened through a call to
+ WKContextSetIconDatabasePath. To avoid having some paths
+ returned through WebContext::platformDefault* and some others
+ through the C API, make sure that all those paths are set
+ through the C API.
+
+ * Shared/qt/QtDefaultDataLocation.cpp: Removed.
+ * Shared/qt/QtDefaultDataLocation.h: Removed.
+ * Target.pri:
+ * UIProcess/Plugins/qt/PluginProcessProxyQt.cpp:
+ (WebKit::cacheFile):
+ - This part is left alone behind the C API.
+ Since PluginProcessProxy have no knowledge of the WebContext
+ it is rather difficult to fetch a configured directory that
+ could be used for this purpose (like the disk cache storage).
+ Hard-code a compatible logic to keep the current behavior.
+ (WebKit::removeCacheFile):
+ (WebKit):
+ (WebKit::readMetaDataFromCacheFile):
+ (WebKit::writeToCacheFile):
+ (WebKit::tryReadPluginMetaDataFromCacheFile):
+ - Update the code to better handle an empty cache file path.
+ * UIProcess/qt/QtWebContext.cpp:
+ (WebKit::QtWebContext::defaultContext):
+ (WebKit::defaultLocation):
+ (WebKit):
+ (WebKit::QtWebContext::preparedStoragePath):
+ * UIProcess/qt/QtWebContext.h:
+ * UIProcess/qt/QtWebIconDatabaseClient.cpp:
+ (WebKit::QtWebIconDatabaseClient::QtWebIconDatabaseClient):
+ * UIProcess/qt/WebContextQt.cpp:
+ (WebKit::WebContext::applicationCacheDirectory):
+ (WebKit::WebContext::platformDefaultDatabaseDirectory):
+ (WebKit::WebContext::platformDefaultIconDatabasePath):
+ (WebKit::WebContext::platformDefaultLocalStorageDirectory):
+ (WebKit::WebContext::platformDefaultDiskCacheDirectory):
+ (WebKit::WebContext::platformDefaultCookieStorageDirectory):
+
2013-02-14 Jocelyn Turcotte <jocelyn.turco...@digia.com>
[Qt] Properly layer QtWebContext on top of the C API
Deleted: trunk/Source/WebKit2/Shared/qt/QtDefaultDataLocation.cpp (145516 => 145517)
--- trunk/Source/WebKit2/Shared/qt/QtDefaultDataLocation.cpp 2013-03-12 11:14:42 UTC (rev 145516)
+++ trunk/Source/WebKit2/Shared/qt/QtDefaultDataLocation.cpp 2013-03-12 11:16:01 UTC (rev 145517)
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
- * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
- * Copyright (C) 2012 University of Szeged. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "QtDefaultDataLocation.h"
-
-#include <QCoreApplication>
-#include <QDir>
-#include <QStandardPaths>
-#include <QStringBuilder>
-#include <WebCore/FileSystem.h>
-
-namespace WebKit {
-
-QString defaultDataLocation()
-{
- static QString s_dataLocation;
-
- if (!s_dataLocation.isEmpty())
- return s_dataLocation;
-
- QString dataLocation = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
- if (dataLocation.isEmpty())
- dataLocation = QDir::homePath() % QDir::separator() % QCoreApplication::applicationName();
- s_dataLocation = dataLocation % QDir::separator() % QStringLiteral(".QtWebKit") % QDir::separator();
- QDir::root().mkpath(s_dataLocation);
-
- return s_dataLocation;
-}
-
-}
Deleted: trunk/Source/WebKit2/Shared/qt/QtDefaultDataLocation.h (145516 => 145517)
--- trunk/Source/WebKit2/Shared/qt/QtDefaultDataLocation.h 2013-03-12 11:14:42 UTC (rev 145516)
+++ trunk/Source/WebKit2/Shared/qt/QtDefaultDataLocation.h 2013-03-12 11:16:01 UTC (rev 145517)
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
- * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
- * Copyright (C) 2012 University of Szeged. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef QtDefaultDataLocation_h
-#define QtDefaultDataLocation_h
-
-#include <QString>
-
-namespace WebKit {
-
-QString defaultDataLocation();
-
-}
-
-#endif
Modified: trunk/Source/WebKit2/Target.pri (145516 => 145517)
--- trunk/Source/WebKit2/Target.pri 2013-03-12 11:14:42 UTC (rev 145516)
+++ trunk/Source/WebKit2/Target.pri 2013-03-12 11:16:01 UTC (rev 145517)
@@ -148,7 +148,6 @@
Shared/qt/ArgumentCodersQt.h \
Shared/qt/PlatformCertificateInfo.h \
Shared/qt/WebEventFactoryQt.h \
- Shared/qt/QtDefaultDataLocation.h \
Shared/qt/QtNetworkReplyData.h \
Shared/qt/QtNetworkRequestData.h \
UIProcess/API/C/WKAPICast.h \
@@ -505,7 +504,6 @@
Shared/qt/ProcessExecutablePathQt.cpp \
Shared/qt/WebCoreArgumentCodersQt.cpp \
Shared/qt/WebEventFactoryQt.cpp \
- Shared/qt/QtDefaultDataLocation.cpp \
Shared/qt/QtNetworkReplyData.cpp \
Shared/qt/QtNetworkRequestData.cpp \
Shared/qt/WebURLRequestQt.cpp \
Modified: trunk/Source/WebKit2/UIProcess/Plugins/qt/PluginProcessProxyQt.cpp (145516 => 145517)
--- trunk/Source/WebKit2/UIProcess/Plugins/qt/PluginProcessProxyQt.cpp 2013-03-12 11:14:42 UTC (rev 145516)
+++ trunk/Source/WebKit2/UIProcess/Plugins/qt/PluginProcessProxyQt.cpp 2013-03-12 11:16:01 UTC (rev 145517)
@@ -29,7 +29,6 @@
#if ENABLE(PLUGIN_PROCESS)
#include "ProcessExecutablePath.h"
-#include "QtDefaultDataLocation.h"
#include <QByteArray>
#include <QCoreApplication>
#include <QDateTime>
@@ -41,6 +40,7 @@
#include <QJsonObject>
#include <QMap>
#include <QProcess>
+#include <QStandardPaths>
#include <QStringBuilder>
#include <QVariant>
#include <WebCore/FileSystem.h>
@@ -62,10 +62,24 @@
static PassOwnPtr<QFile> cacheFile()
{
- static QString cacheFilePath = defaultDataLocation() % QStringLiteral("plugin_meta_data.json");
+ QString cachePath = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
+ if (cachePath.isEmpty())
+ return PassOwnPtr<QFile>();
+
+ // This should match the path set through WKContextSetDiskCacheDirectory.
+ cachePath.append(QDir::separator()).append(QStringLiteral(".QtWebKit")).append(QDir::separator());
+ QString cacheFilePath = cachePath % QStringLiteral("plugin_meta_data.json");
+
+ QDir::root().mkpath(cachePath);
return adoptPtr(new QFile(cacheFilePath));
}
+static void removeCacheFile()
+{
+ if (OwnPtr<QFile> file = cacheFile())
+ file->remove();
+}
+
struct ReadResult {
enum Tag {
Empty,
@@ -77,7 +91,7 @@
static ReadResult::Tag readMetaDataFromCacheFile(QJsonDocument& result)
{
OwnPtr<QFile> file = cacheFile();
- if (!file->open(QFile::ReadOnly))
+ if (!file || !file->open(QFile::ReadOnly))
return ReadResult::Empty;
QByteArray data = ""
if (data.isEmpty())
@@ -97,14 +111,9 @@
static void writeToCacheFile(const QJsonArray& array)
{
OwnPtr<QFile> file = cacheFile();
- if (!file->open(QFile::WriteOnly | QFile::Truncate)) {
- // It should never but let's be pessimistic, it is the file system after all.
- qWarning("Cannot write into plugin meta data cache file: %s\n", qPrintable(file->fileName()));
- return;
- }
-
- // Don't care about write error here. We will detect it later.
- file->write(QJsonDocument(array).toJson());
+ if (file && file->open(QFile::WriteOnly | QFile::Truncate))
+ // Don't care about write error here. We will detect it later.
+ file->write(QJsonDocument(array).toJson());
}
static void appendToCacheFile(const QJsonObject& object)
@@ -140,7 +149,7 @@
for (QJsonArray::const_iterator i = array.constBegin(); i != array.constEnd(); ++i) {
QJsonValue item = *i;
if (!item.isObject()) {
- cacheFile()->remove();
+ removeCacheFile();
return MetaDataResult::NotAvailable;
}
@@ -148,7 +157,7 @@
if (object.value(QStringLiteral("path")).toString() == canonicalPluginPath) {
QString timestampString = object.value(QStringLiteral("timestamp")).toString();
if (timestampString.isEmpty()) {
- cacheFile()->remove();
+ removeCacheFile();
return MetaDataResult::NotAvailable;
}
QDateTime timestamp = QDateTime::fromString(timestampString);
@@ -169,7 +178,7 @@
if (result.mimeDescription.isEmpty()) {
// Only the mime description is mandatory.
// Don't trust in the cache file if it is empty.
- cacheFile()->remove();
+ removeCacheFile();
return MetaDataResult::NotAvailable;
}
Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebContext.cpp (145516 => 145517)
--- trunk/Source/WebKit2/UIProcess/qt/QtWebContext.cpp 2013-03-12 11:14:42 UTC (rev 145516)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebContext.cpp 2013-03-12 11:16:01 UTC (rev 145517)
@@ -25,10 +25,15 @@
#include "QtWebIconDatabaseClient.h"
#include "WebInspectorServer.h"
#include "qquickwebview_p_p.h"
+#include <QDir>
+#include <QStandardPaths>
+#include <QStringBuilder>
#include <WKAPICast.h>
#include <WKArray.h>
+#include <WKContextPrivate.h>
#include <WKPage.h>
#include <WKString.h>
+#include <WKStringQt.h>
#include <WKType.h>
namespace WebKit {
@@ -138,11 +143,56 @@
// A good all-around default.
WKContextSetCacheModel(wkContext.get(), kWKCacheModelDocumentBrowser);
+ // Those paths have to be set before the first web process is spawned.
+ WKContextSetDatabaseDirectory(wkContext.get(), adoptWK(WKStringCreateWithQString(preparedStoragePath(DatabaseStorage))).get());
+ WKContextSetLocalStorageDirectory(wkContext.get(), adoptWK(WKStringCreateWithQString(preparedStoragePath(LocalStorage))).get());
+ WKContextSetCookieStorageDirectory(wkContext.get(), adoptWK(WKStringCreateWithQString(preparedStoragePath(CookieStorage))).get());
+ WKContextSetDiskCacheDirectory(wkContext.get(), adoptWK(WKStringCreateWithQString(preparedStoragePath(DiskCacheStorage))).get());
+
s_defaultQtWebContext = QtWebContext::create(wkContext.get());
}
return s_defaultQtWebContext;
}
+static QString defaultLocation(QStandardPaths::StandardLocation type)
+{
+ QString path = QStandardPaths::writableLocation(type);
+ Q_ASSERT(!path.isEmpty());
+ return path % QDir::separator() % QStringLiteral(".QtWebKit") % QDir::separator();
+}
+
+QString QtWebContext::preparedStoragePath(StorageType type)
+{
+ QString path;
+ switch (type) {
+ case DatabaseStorage:
+ path = defaultLocation(QStandardPaths::DataLocation) % QStringLiteral("Databases");
+ QDir::root().mkpath(path);
+ break;
+ case LocalStorage:
+ path = defaultLocation(QStandardPaths::DataLocation) % QStringLiteral("LocalStorage");
+ QDir::root().mkpath(path);
+ break;
+ case CookieStorage:
+ path = defaultLocation(QStandardPaths::DataLocation);
+ QDir::root().mkpath(path);
+ break;
+ case DiskCacheStorage:
+ path = defaultLocation(QStandardPaths::CacheLocation) % QStringLiteral("DiskCache");
+ QDir::root().mkpath(path);
+ break;
+ case IconDatabaseStorage:
+ path = defaultLocation(QStandardPaths::DataLocation);
+ QDir::root().mkpath(path);
+ path += QStringLiteral("WebpageIcons.db");
+ break;
+ default:
+ Q_ASSERT(false);
+ }
+
+ return path;
+}
+
} // namespace WebKit
Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebContext.h (145516 => 145517)
--- trunk/Source/WebKit2/UIProcess/qt/QtWebContext.h 2013-03-12 11:14:42 UTC (rev 145516)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebContext.h 2013-03-12 11:16:01 UTC (rev 145517)
@@ -35,9 +35,19 @@
public:
~QtWebContext();
+ enum StorageType {
+ DatabaseStorage,
+ LocalStorage,
+ CookieStorage,
+ DiskCacheStorage,
+ IconDatabaseStorage
+ };
+
static QtWebContext* create(WKContextRef);
static QtWebContext* defaultContext();
+ static QString preparedStoragePath(StorageType);
+
WKContextRef context() { return m_context.get(); }
QtDownloadManager* downloadManager() { return m_downloadManager.data(); }
Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.cpp (145516 => 145517)
--- trunk/Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.cpp 2013-03-12 11:14:42 UTC (rev 145516)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.cpp 2013-03-12 11:16:01 UTC (rev 145517)
@@ -22,6 +22,7 @@
#include "Image.h"
#include "KURL.h"
+#include "QtWebContext.h"
#include "SharedBuffer.h"
#include "WKURLQt.h"
#include "WebContext.h"
@@ -30,6 +31,9 @@
#include <QtCore/QObject>
#include <QtCore/QUrl>
#include <QtGui/QImage>
+#include <WKContextPrivate.h>
+#include <WKRetainPtr.h>
+#include <WKStringQt.h>
namespace WebKit {
@@ -41,9 +45,6 @@
QtWebIconDatabaseClient::QtWebIconDatabaseClient(WebContext *context)
{
- // The setter calls the getter here as it triggers the startup of the icon database.
- if (!context->iconDatabase()->isOpen())
- context->setIconDatabasePath(context->iconDatabasePath());
m_iconDatabase = context->iconDatabase();
WKIconDatabaseClient iconDatabaseClient;
@@ -52,6 +53,9 @@
iconDatabaseClient.clientInfo = this;
iconDatabaseClient.didChangeIconForPageURL = didChangeIconForPageURL;
WKIconDatabaseSetIconDatabaseClient(toAPI(m_iconDatabase.get()), &iconDatabaseClient);
+ // Triggers the startup of the icon database.
+ WKRetainPtr<WKStringRef> path = adoptWK(WKStringCreateWithQString(QtWebContext::preparedStoragePath(QtWebContext::IconDatabaseStorage)));
+ WKContextSetIconDatabasePath(toAPI(context), path.get());
}
QtWebIconDatabaseClient::~QtWebIconDatabaseClient()
Modified: trunk/Source/WebKit2/UIProcess/qt/WebContextQt.cpp (145516 => 145517)
--- trunk/Source/WebKit2/UIProcess/qt/WebContextQt.cpp 2013-03-12 11:14:42 UTC (rev 145516)
+++ trunk/Source/WebKit2/UIProcess/qt/WebContextQt.cpp 2013-03-12 11:16:01 UTC (rev 145517)
@@ -28,13 +28,8 @@
#include "WebContext.h"
#include "ApplicationCacheStorage.h"
-#include "FileSystem.h"
-#include "QtDefaultDataLocation.h"
-#include "QtWebContext.h"
#include "WKSharedAPICast.h"
#include "WebProcessCreationParameters.h"
-#include <QCoreApplication>
-#include <QDir>
#include <QProcess>
#if ENABLE(GEOLOCATION)
@@ -44,28 +39,12 @@
namespace WebKit {
-static QString s_defaultDatabaseDirectory;
-static QString s_defaultLocalStorageDirectory;
-static QString s_defaultCookieStorageDirectory;
-
-String WebContext::platformDefaultDiskCacheDirectory() const
-{
- static String s_defaultDiskCacheDirectory;
-
- if (!s_defaultDiskCacheDirectory.isEmpty())
- return s_defaultDiskCacheDirectory;
-
- s_defaultDiskCacheDirectory = WebCore::pathByAppendingComponent(defaultDataLocation(), "cache/");
- WebCore::makeAllDirectories(s_defaultDiskCacheDirectory);
- return s_defaultDiskCacheDirectory;
-}
-
String WebContext::applicationCacheDirectory()
{
const String cacheDirectory = WebCore::cacheStorage().cacheDirectory();
if (cacheDirectory.isEmpty())
- return platformDefaultDiskCacheDirectory();
+ return diskCacheDirectory();
return cacheDirectory;
}
@@ -85,36 +64,27 @@
String WebContext::platformDefaultDatabaseDirectory() const
{
- if (!s_defaultDatabaseDirectory.isEmpty())
- return s_defaultDatabaseDirectory;
-
- s_defaultDatabaseDirectory = defaultDataLocation() + QLatin1String("Databases");
- QDir().mkpath(s_defaultDatabaseDirectory);
- return s_defaultDatabaseDirectory;
+ return String();
}
String WebContext::platformDefaultIconDatabasePath() const
{
- return defaultDataLocation() + QLatin1String("WebpageIcons.db");
+ return String();
}
String WebContext::platformDefaultLocalStorageDirectory() const
{
- if (!s_defaultLocalStorageDirectory.isEmpty())
- return s_defaultLocalStorageDirectory;
+ return String();
+}
- s_defaultLocalStorageDirectory = defaultDataLocation() + QLatin1String("LocalStorage");
- QDir().mkpath(s_defaultLocalStorageDirectory);
- return s_defaultLocalStorageDirectory;
+String WebContext::platformDefaultDiskCacheDirectory() const
+{
+ return String();
}
String WebContext::platformDefaultCookieStorageDirectory() const
{
- if (!s_defaultCookieStorageDirectory.isEmpty())
- return s_defaultCookieStorageDirectory;
-
- s_defaultCookieStorageDirectory = defaultDataLocation();
- return s_defaultCookieStorageDirectory;
+ return String();
}
} // namespace WebKit