diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-01-09 17:52:58 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-01-15 19:17:38 +0000 |
commit | a3fe8bc7859a84bbdd91f3ce73108878798b3986 (patch) | |
tree | 0d75e37bdebd3220ed844bc15d7069d1878a8296 /src/webenginewidgets/api/qwebengineprofile.cpp | |
parent | ed3a0f052910b09edc393dfb6c6940f118b267ea (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/webenginewidgets/api/qwebengineprofile.cpp')
-rw-r--r-- | src/webenginewidgets/api/qwebengineprofile.cpp | 32 |
1 files changed, 5 insertions, 27 deletions
diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp index e1e72aa45..b39512d60 100644 --- a/src/webenginewidgets/api/qwebengineprofile.cpp +++ b/src/webenginewidgets/api/qwebengineprofile.cpp @@ -47,8 +47,9 @@ #include "qwebenginesettings.h" #include "qwebenginescriptcollection_p.h" +#include "qwebenginebrowsercontext_p.h" +#include "qtwebenginecoreglobal.h" #include "browser_context_adapter.h" -#include <qtwebenginecoreglobal.h> #include "visited_links_manager_qt.h" #include "web_engine_settings.h" @@ -145,30 +146,6 @@ using QtWebEngineCore::BrowserContextAdapter; \sa QWebEngineDownloadItem */ -QWebEngineBrowserContext::QWebEngineBrowserContext(QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext, QWebEngineProfilePrivate *profile) - : QObject(BrowserContextAdapter::globalQObjectRoot()) - , browserContextRef(browserContext) - , m_profile(profile) -{ - browserContextRef->addClient(m_profile); -} - -QWebEngineBrowserContext::~QWebEngineBrowserContext() -{ - if (m_profile) - shutdown(); -} - -void QWebEngineBrowserContext::shutdown() -{ - Q_ASSERT(m_profile); - // In the case the user sets this profile as the parent of the interceptor - // it can be deleted before the browser-context still referencing it is. - browserContextRef->setRequestInterceptor(nullptr); - browserContextRef->removeClient(m_profile); - m_profile = 0; -} - QWebEngineProfilePrivate::QWebEngineProfilePrivate(QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext) : m_settings(new QWebEngineSettings()) , m_scriptCollection(new QWebEngineScriptCollection(new QWebEngineScriptCollectionPrivate(browserContext->userResourceController()))) @@ -194,12 +171,13 @@ QWebEngineProfilePrivate::~QWebEngineProfilePrivate() QSharedPointer<QtWebEngineCore::BrowserContextAdapter> QWebEngineProfilePrivate::browserContext() const { - return m_browserContext->browserContextRef; + return m_browserContext ? m_browserContext->browserContextRef : nullptr; } void QWebEngineProfilePrivate::cancelDownload(quint32 downloadId) { - browserContext()->cancelDownload(downloadId); + if (m_browserContext) + m_browserContext->browserContextRef->cancelDownload(downloadId); } void QWebEngineProfilePrivate::downloadDestroyed(quint32 downloadId) |