summaryrefslogtreecommitdiffstats
path: root/src/webengine
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-01-09 17:52:58 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-01-15 19:17:38 +0000
commita3fe8bc7859a84bbdd91f3ce73108878798b3986 (patch)
tree0d75e37bdebd3220ed844bc15d7069d1878a8296 /src/webengine
parented3a0f052910b09edc393dfb6c6940f118b267ea (diff)
Protect QML profiles as well as core
Moves QWebEngineBrowserContext to core and makes use of it from both widget and qml. Change-Id: I34748f302b0515b11b5831690d28478dfa6a852b Reviewed-by: Michal Klocek <michal.klocek@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'src/webengine')
-rw-r--r--src/webengine/api/qquickwebengineprofile.cpp20
-rw-r--r--src/webengine/api/qquickwebengineprofile_p.h7
2 files changed, 16 insertions, 11 deletions
diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp
index 3364e4169..e051d8755 100644
--- a/src/webengine/api/qquickwebengineprofile.cpp
+++ b/src/webengine/api/qquickwebengineprofile.cpp
@@ -142,9 +142,8 @@ ASSERT_ENUMS_MATCH(QQuickWebEngineDownloadItem::MimeHtmlSaveFormat, QtWebEngineC
QQuickWebEngineProfilePrivate::QQuickWebEngineProfilePrivate(QSharedPointer<BrowserContextAdapter> browserContext)
: m_settings(new QQuickWebEngineSettings())
- , m_browserContextRef(browserContext)
+ , m_browserContext(new QWebEngineBrowserContext(browserContext, this))
{
- m_browserContextRef->addClient(this);
m_settings->d_ptr->initDefaults(browserContext->isOffTheRecord());
// Fullscreen API was implemented before the supported setting, so we must
// make it default true to avoid change in default API behavior.
@@ -153,21 +152,26 @@ QQuickWebEngineProfilePrivate::QQuickWebEngineProfilePrivate(QSharedPointer<Brow
QQuickWebEngineProfilePrivate::~QQuickWebEngineProfilePrivate()
{
- m_browserContextRef->setRequestInterceptor(nullptr);
-
- m_browserContextRef->removeClient(this);
-
- Q_FOREACH (QQuickWebEngineDownloadItem* download, m_ongoingDownloads) {
+ Q_FOREACH (QQuickWebEngineDownloadItem *download, m_ongoingDownloads) {
if (download)
download->cancel();
}
m_ongoingDownloads.clear();
+
+ if (m_browserContext)
+ m_browserContext->shutdown();
+}
+
+QSharedPointer<QtWebEngineCore::BrowserContextAdapter> QQuickWebEngineProfilePrivate::browserContext() const
+{
+ return m_browserContext ? m_browserContext->browserContextRef : nullptr;
}
void QQuickWebEngineProfilePrivate::cancelDownload(quint32 downloadId)
{
- browserContext()->cancelDownload(downloadId);
+ if (m_browserContext)
+ m_browserContext->browserContextRef->cancelDownload(downloadId);
}
void QQuickWebEngineProfilePrivate::downloadDestroyed(quint32 downloadId)
diff --git a/src/webengine/api/qquickwebengineprofile_p.h b/src/webengine/api/qquickwebengineprofile_p.h
index 1828f8085..660433fd9 100644
--- a/src/webengine/api/qquickwebengineprofile_p.h
+++ b/src/webengine/api/qquickwebengineprofile_p.h
@@ -52,8 +52,9 @@
//
#include "browser_context_adapter_client.h"
-#include "qquickwebengineprofile_p.h"
#include "browser_context_adapter.h"
+#include "qwebenginebrowsercontext_p.h"
+#include "qquickwebengineprofile_p.h"
#include <QExplicitlySharedDataPointer>
#include <QMap>
@@ -71,7 +72,7 @@ public:
QQuickWebEngineProfilePrivate(QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext);
~QQuickWebEngineProfilePrivate();
- QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext() const { return m_browserContextRef; }
+ QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext() const;
QQuickWebEngineSettings *settings() const { return m_settings.data(); }
void cancelDownload(quint32 downloadId);
@@ -90,7 +91,7 @@ private:
friend class QQuickWebEngineViewPrivate;
QQuickWebEngineProfile *q_ptr;
QScopedPointer<QQuickWebEngineSettings> m_settings;
- QSharedPointer<QtWebEngineCore::BrowserContextAdapter> m_browserContextRef;
+ QPointer<QWebEngineBrowserContext> m_browserContext;
QMap<quint32, QPointer<QQuickWebEngineDownloadItem> > m_ongoingDownloads;
QList<QQuickWebEngineScript *> m_userScripts;
};