summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndras Becsi <andras.becsi@digia.com>2013-07-26 19:34:08 +0200
committerZeno Albisser <zeno.albisser@digia.com>2013-07-26 23:30:30 +0200
commitaebb91d9a2293b027b64601aea10d56240759050 (patch)
treefec19421f8b40aef12c886b9c4bc6c8fec33281d
parent0c6e6d63d93882c3d682cdcf15f96c3d682c338d (diff)
Fix BrowserContextQt::GetPath() to return path to user data directory
Besides returning a proper application specific user data directory, this patch removes the duplicate definition of GetPath() which was added by accident with the recent chromium update. Change-Id: Ia30d598e3ef99eb88000498ef3a00ccae0593ff8 Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
-rw-r--r--lib/browser_context_qt.h63
-rw-r--r--lib/render_widget_host_view_qt.h10
-rw-r--r--lib/web_engine_context.cpp10
-rw-r--r--shared/shared_globals.h21
4 files changed, 64 insertions, 40 deletions
diff --git a/lib/browser_context_qt.h b/lib/browser_context_qt.h
index 5b83a4367..098f01a9f 100644
--- a/lib/browser_context_qt.h
+++ b/lib/browser_context_qt.h
@@ -46,6 +46,8 @@
#include "base/files/scoped_temp_dir.h"
+#include "shared/shared_globals.h"
+
#include "base/time/time.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/resource_context.h"
@@ -55,6 +57,11 @@
#include <qglobal.h>
#include <QByteArray>
+#include <QCoreApplication>
+#include <QDir>
+#include <QStandardPaths>
+#include <QString>
+#include <QStringBuilder>
#include "resource_context_qt.h"
#include "url_request_context_getter_qt.h"
@@ -64,52 +71,63 @@ class BrowserContextQt : public content::BrowserContext
public:
explicit BrowserContextQt()
{
- tempBasePath.CreateUniqueTempDir();
resourceContext.reset(new ResourceContextQt(this));
}
- virtual ~BrowserContextQt() {}
- virtual base::FilePath GetPath()
- {
- return tempBasePath.path();
- }
+ virtual ~BrowserContextQt() Q_DECL_OVERRIDE {}
- virtual bool IsOffTheRecord() const
+ virtual base::FilePath GetPath() const Q_DECL_OVERRIDE
{
- return false;
+ QString dataLocation = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
+ if (dataLocation.isEmpty())
+ dataLocation = QDir::homePath() % QDir::separator() % QChar::fromLatin1('.') % QCoreApplication::applicationName();
+
+ dataLocation.append(QDir::separator() % QStringLiteral("QtWebEngine"));
+ return base::FilePath(qStringToStringType(dataLocation));
}
- virtual base::FilePath GetPath() const
+ virtual bool IsOffTheRecord() const Q_DECL_OVERRIDE
{
- // FIXME: return the path of the directory where this context's data is stored.
- return base::FilePath();
+ return false;
}
- virtual net::URLRequestContextGetter* GetRequestContext()
+ virtual net::URLRequestContextGetter* GetRequestContext() Q_DECL_OVERRIDE
{
return GetDefaultStoragePartition(this)->GetURLRequestContext();
}
- virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess(int) { return GetRequestContext(); }
- virtual net::URLRequestContextGetter* GetMediaRequestContext() { return GetRequestContext(); }
- virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(int) { return GetRequestContext(); }
- virtual net::URLRequestContextGetter* GetMediaRequestContextForStoragePartition(const base::FilePath&, bool) { return GetRequestContext(); }
+ virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess(int) Q_DECL_OVERRIDE { return GetRequestContext(); }
+ virtual net::URLRequestContextGetter* GetMediaRequestContext() Q_DECL_OVERRIDE { return GetRequestContext(); }
+ virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(int) Q_DECL_OVERRIDE { return GetRequestContext(); }
+ virtual net::URLRequestContextGetter* GetMediaRequestContextForStoragePartition(const base::FilePath&, bool) Q_DECL_OVERRIDE { return GetRequestContext(); }
- virtual void RequestMIDISysExPermission(int render_process_id, int render_view_id, const GURL& requesting_frame, const MIDISysExPermissionCallback& callback)
+ virtual void RequestMIDISysExPermission(int render_process_id, int render_view_id, const GURL& requesting_frame, const MIDISysExPermissionCallback& callback) Q_DECL_OVERRIDE
{
// Always reject requests for testing.
callback.Run(false);
}
- virtual content::ResourceContext* GetResourceContext()
+ virtual content::ResourceContext* GetResourceContext() Q_DECL_OVERRIDE
{
return resourceContext.get();
}
- virtual content::DownloadManagerDelegate* GetDownloadManagerDelegate() { return 0; }
- virtual content::GeolocationPermissionContext* GetGeolocationPermissionContext() { return 0; }
- virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() { return 0; }
+ virtual content::DownloadManagerDelegate* GetDownloadManagerDelegate() Q_DECL_OVERRIDE
+ {
+ QT_NOT_YET_IMPLEMENTED
+ return 0;
+ }
+ virtual content::GeolocationPermissionContext* GetGeolocationPermissionContext() Q_DECL_OVERRIDE
+ {
+ QT_NOT_YET_IMPLEMENTED
+ return 0;
+ }
+ virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() Q_DECL_OVERRIDE
+ {
+ QT_NOT_YET_IMPLEMENTED
+ return 0;
+ }
- net::URLRequestContextGetter *CreateRequestContext(content::ProtocolHandlerMap* protocol_handlers)
+ net::URLRequestContextGetter *CreateRequestContext(content::ProtocolHandlerMap* protocol_handlers) Q_DECL_OVERRIDE
{
url_request_getter_ = new URLRequestContextGetterQt(GetPath());
static_cast<ResourceContextQt*>(resourceContext.get())->set_url_request_context_getter(url_request_getter_.get());
@@ -118,7 +136,6 @@ public:
private:
scoped_ptr<content::ResourceContext> resourceContext;
- base::ScopedTempDir tempBasePath; // ### Should become permanent location.
scoped_refptr<net::URLRequestContextGetter> url_request_getter_;
DISALLOW_COPY_AND_ASSIGN(BrowserContextQt);
diff --git a/lib/render_widget_host_view_qt.h b/lib/render_widget_host_view_qt.h
index 2ae735053..8ad3ceed2 100644
--- a/lib/render_widget_host_view_qt.h
+++ b/lib/render_widget_host_view_qt.h
@@ -42,17 +42,11 @@
#ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_QT_H_
#define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_QT_H_
+#include "shared/shared_globals.h"
+
#include "content/browser/renderer_host/render_widget_host_view_base.h"
#include <qglobal.h>
-#ifdef QT_WEBENGINE_LOGGING
-#define QT_NOT_YET_IMPLEMENTED fprintf(stderr, "function %s not implemented! - %s:%d\n", __func__, __FILE__, __LINE__);
-#define QT_NOT_USED fprintf(stderr, "# function %s should not be used! - %s:%d\n", __func__, __FILE__, __LINE__); Q_UNREACHABLE();
-#else
-#define QT_NOT_YET_IMPLEMENTED qt_noop();
-#define QT_NOT_USED Q_UNREACHABLE(); // This will assert in debug.
-#endif
-
class BackingStoreQt;
class QEvent;
class QFocusEvent;
diff --git a/lib/web_engine_context.cpp b/lib/web_engine_context.cpp
index ecd4b6643..0a3f28eb8 100644
--- a/lib/web_engine_context.cpp
+++ b/lib/web_engine_context.cpp
@@ -41,6 +41,7 @@
#include "web_engine_context.h"
+#include "shared/shared_globals.h"
#include <math.h>
#include "base/command_line.h"
@@ -63,15 +64,6 @@ namespace {
static WebEngineContext* sContext = 0;
-static inline base::FilePath::StringType qStringToStringType(const QString &str)
-{
-#if defined(OS_POSIX)
- return str.toStdString();
-#elif defined(OS_WIN)
- return str.toStdWString();
-#endif
-}
-
static QByteArray subProcessPath() {
static bool initialized = false;
#ifdef QTWEBENGINEPROCESS_PATH
diff --git a/shared/shared_globals.h b/shared/shared_globals.h
index 1e4b9183a..c0b167269 100644
--- a/shared/shared_globals.h
+++ b/shared/shared_globals.h
@@ -42,8 +42,19 @@
#ifndef SHARED_GLOBALS_H
#define SHARED_GLOBALS_H
+#include "base/files/file_path.h"
#include "third_party/WebKit/public/platform/WebScreenInfo.h"
+#include <QString>
+
+#ifdef QT_WEBENGINE_LOGGING
+#define QT_NOT_YET_IMPLEMENTED fprintf(stderr, "function %s not implemented! - %s:%d\n", __func__, __FILE__, __LINE__);
+#define QT_NOT_USED fprintf(stderr, "# function %s should not be used! - %s:%d\n", __func__, __FILE__, __LINE__); Q_UNREACHABLE();
+#else
+#define QT_NOT_YET_IMPLEMENTED qt_noop();
+#define QT_NOT_USED Q_UNREACHABLE(); // This will assert in debug.
+#endif
+
namespace content {
class WebContentsImpl;
class WebContentsViewPort;
@@ -55,4 +66,14 @@ class QWindow;
void GetScreenInfoFromNativeWindow(QWindow* window, WebKit::WebScreenInfo* results);
+
+inline base::FilePath::StringType qStringToStringType(const QString &str)
+{
+#if defined(OS_POSIX)
+ return str.toStdString();
+#elif defined(OS_WIN)
+ return str.toStdWString();
+#endif
+}
+
#endif