diff options
author | Michal Klocek <michal.klocek@qt.io> | 2018-04-23 12:34:58 +0200 |
---|---|---|
committer | Michal Klocek <michal.klocek@qt.io> | 2018-05-28 14:36:54 +0000 |
commit | 6e28e764d7c425f942820f0881231eb83e553e6e (patch) | |
tree | 8ebcdb4c081cc92ec8be5a23d3473b74c53bba10 /src | |
parent | af313cb881610fedb04c9d486597462e6b3c8e12 (diff) |
Unify and simplify profile constructors
Use one constructor for private profile creation.
Change-Id: I57a227b6344b6e308cfd4931986fa1dede75cfce
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/browser_context_adapter.cpp | 17 | ||||
-rw-r--r-- | src/core/browser_context_adapter.h | 3 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineprofile.cpp | 2 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebengineprofile.cpp | 20 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebengineprofile_p.h | 2 |
5 files changed, 6 insertions, 38 deletions
diff --git a/src/core/browser_context_adapter.cpp b/src/core/browser_context_adapter.cpp index ecf9bdbc2..2aeb8c5bf 100644 --- a/src/core/browser_context_adapter.cpp +++ b/src/core/browser_context_adapter.cpp @@ -76,24 +76,9 @@ inline QString buildLocationFromStandardPath(const QString &standardPath, const namespace QtWebEngineCore { -BrowserContextAdapter::BrowserContextAdapter(bool offTheRecord): - m_offTheRecord(offTheRecord) - , m_httpCacheType(DiskHttpCache) - , m_persistentCookiesPolicy(AllowPersistentCookies) - , m_visitedLinksPolicy(TrackVisitedLinksOnDisk) - , m_httpCacheMaxSize(0) -{ - WebEngineContext::current()->addBrowserContext(this); - // creation of profile requires webengine context - m_browserContext.reset(new ProfileQt(this)); - content::BrowserContext::Initialize(m_browserContext.data(), toFilePath(dataPath())); - // fixme: this should not be here - m_browserContext->m_profileIOData->initializeOnUIThread(); -} - BrowserContextAdapter::BrowserContextAdapter(const QString &storageName): m_name(storageName) - , m_offTheRecord(false) + , m_offTheRecord(storageName.isEmpty()) , m_httpCacheType(DiskHttpCache) , m_persistentCookiesPolicy(AllowPersistentCookies) , m_visitedLinksPolicy(TrackVisitedLinksOnDisk) diff --git a/src/core/browser_context_adapter.h b/src/core/browser_context_adapter.h index 76d4f73c0..52dab2325 100644 --- a/src/core/browser_context_adapter.h +++ b/src/core/browser_context_adapter.h @@ -66,8 +66,7 @@ class VisitedLinksManagerQt; class QWEBENGINE_EXPORT BrowserContextAdapter : public QObject { public: - explicit BrowserContextAdapter(bool offTheRecord = false); - explicit BrowserContextAdapter(const QString &storagePrefix); + explicit BrowserContextAdapter(const QString &storagePrefix = QString()); virtual ~BrowserContextAdapter(); static BrowserContextAdapter* defaultContext(); diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp index 68cc701e0..3c22dba98 100644 --- a/src/webengine/api/qquickwebengineprofile.cpp +++ b/src/webengine/api/qquickwebengineprofile.cpp @@ -326,7 +326,7 @@ void QQuickWebEngineProfilePrivate::userScripts_clear(QQmlListProperty<QQuickWeb */ QQuickWebEngineProfile::QQuickWebEngineProfile(QObject *parent) : QObject(parent), - d_ptr(new QQuickWebEngineProfilePrivate(new QtWebEngineCore::BrowserContextAdapter(true))) + d_ptr(new QQuickWebEngineProfilePrivate(new QtWebEngineCore::BrowserContextAdapter())) { // Sets up the global WebEngineContext QQuickWebEngineProfile::defaultProfile(); diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp index 96cc2bb94..96e47a75d 100644 --- a/src/webenginewidgets/api/qwebengineprofile.cpp +++ b/src/webenginewidgets/api/qwebengineprofile.cpp @@ -147,25 +147,11 @@ using QtWebEngineCore::BrowserContextAdapter; \sa QWebEngineDownloadItem, QWebEnginePage::download() */ -// Fixme: fix storage name setters and unify constructors here and in BrowserContextAdapter -QWebEngineProfilePrivate::QWebEngineProfilePrivate(const QString &storageName) - : m_settings(new QWebEngineSettings()) - , m_browserContextAdapter(storageName.isEmpty()? - new QtWebEngineCore::BrowserContextAdapter(true): - new QtWebEngineCore::BrowserContextAdapter(storageName)) - , m_scriptCollection(new QWebEngineScriptCollection( - new QWebEngineScriptCollectionPrivate(m_browserContextAdapter->userResourceController()))) -{ - m_browserContextAdapter->addClient(this); - m_settings->d_ptr->initDefaults(); -} - -// Fixme: fix storage name setters and unify constructors here and in BrowserContextAdapter QWebEngineProfilePrivate::QWebEngineProfilePrivate(BrowserContextAdapter* browserContextAdapter) : m_settings(new QWebEngineSettings()) , m_browserContextAdapter(browserContextAdapter) , m_scriptCollection(new QWebEngineScriptCollection( - new QWebEngineScriptCollectionPrivate(m_browserContextAdapter->userResourceController()))) + new QWebEngineScriptCollectionPrivate(browserContextAdapter->userResourceController()))) { m_browserContextAdapter->addClient(this); m_settings->d_ptr->initDefaults(); @@ -267,7 +253,7 @@ void QWebEngineProfilePrivate::downloadUpdated(const DownloadItemInfo &info) */ QWebEngineProfile::QWebEngineProfile(QObject *parent) : QObject(parent) - , d_ptr(new QWebEngineProfilePrivate()) + , d_ptr(new QWebEngineProfilePrivate(new QtWebEngineCore::BrowserContextAdapter())) { d_ptr->q_ptr = this; } @@ -284,7 +270,7 @@ QWebEngineProfile::QWebEngineProfile(QObject *parent) */ QWebEngineProfile::QWebEngineProfile(const QString &storageName, QObject *parent) : QObject(parent) - , d_ptr(new QWebEngineProfilePrivate(storageName)) + , d_ptr(new QWebEngineProfilePrivate(new QtWebEngineCore::BrowserContextAdapter(storageName))) { d_ptr->q_ptr = this; } diff --git a/src/webenginewidgets/api/qwebengineprofile_p.h b/src/webenginewidgets/api/qwebengineprofile_p.h index d3bfe0b91..f363482e9 100644 --- a/src/webenginewidgets/api/qwebengineprofile_p.h +++ b/src/webenginewidgets/api/qwebengineprofile_p.h @@ -73,8 +73,6 @@ class QWebEngineSettings; class QWebEngineProfilePrivate : public QtWebEngineCore::BrowserContextAdapterClient { public: Q_DECLARE_PUBLIC(QWebEngineProfile) - QWebEngineProfilePrivate(const QString &storageName = QString()); - // This is used only by global profile QWebEngineProfilePrivate(QtWebEngineCore::BrowserContextAdapter *browserContextAdapter); ~QWebEngineProfilePrivate(); |