diff --git a/src/webengine/api/qquickwebenginedownloaditem.cpp b/src/webengine/api/qquickwebenginedownloaditem.cpp index cc1a50db66f34c9b1e5d70e819851ab4351704d7..2c1ec1ce9e70157fd17da5a5fb029eb08d052168 100644 --- a/src/webengine/api/qquickwebenginedownloaditem.cpp +++ b/src/webengine/api/qquickwebenginedownloaditem.cpp @@ -36,7 +36,7 @@ #include "qquickwebenginedownloaditem_p.h" #include "qquickwebenginedownloaditem_p_p.h" -#include "qquickwebengineprofile_p_p.h" +#include "qquickwebengineprofile_p.h" using QtWebEngineCore::BrowserContextAdapterClient; diff --git a/src/webengine/api/qquickwebenginedownloaditem_p_p.h b/src/webengine/api/qquickwebenginedownloaditem_p_p.h index 4e36fec43b1d8cccbd5a913fb41614856370aa20..8e502c7364d3b331fc3ab913a9b2004e211792bc 100644 --- a/src/webengine/api/qquickwebenginedownloaditem_p_p.h +++ b/src/webengine/api/qquickwebenginedownloaditem_p_p.h @@ -50,7 +50,7 @@ #include "browser_context_adapter_client.h" #include "qquickwebenginedownloaditem_p.h" -#include "qquickwebengineprofile_p.h" +#include "qquickwebengineprofile.h" #include <private/qtwebengineglobal_p.h> #include <QString> #include <QPointer> diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp index 4871957c2439d4f58b3c4a3f398e38e9275878af..83ebd8e6ef371869ec7ec4e83f2525ddd4cc9b73 100644 --- a/src/webengine/api/qquickwebengineprofile.cpp +++ b/src/webengine/api/qquickwebengineprofile.cpp @@ -34,11 +34,11 @@ ** ****************************************************************************/ -#include "qquickwebengineprofile_p.h" +#include "qquickwebengineprofile.h" #include "qquickwebenginedownloaditem_p.h" #include "qquickwebenginedownloaditem_p_p.h" -#include "qquickwebengineprofile_p_p.h" +#include "qquickwebengineprofile_p.h" #include "qquickwebenginesettings_p.h" #include "qwebenginecookiestore.h" @@ -51,6 +51,68 @@ using QtWebEngineCore::BrowserContextAdapter; QT_BEGIN_NAMESPACE + +/*! + \class QQuickWebEngineProfile + \brief The QQuickWebEngineProfile class provides a web-engine profile shared by multiple pages. + \since 5.6 + + \inmodule QtWebEngine + + QQuickWebEngineProfile contains settings, scripts, and the list of visited links shared by all + web engine pages that belong to the profile. As such, profiles can be used to isolate pages + from each other. A typical use case is a dedicated profile for a 'private browsing' mode. + + The default profile is a built-in profile that all web pages not specifically created with + another profile belong to. +*/ + +/*! + \enum QQuickWebEngineProfile::HttpCacheType + + This enum describes the HTTP cache type: + + \value MemoryHttpCache Use an in-memory cache. This is the only setting possible if + \c off-the-record is set or no cache path is available. + \value DiskHttpCache Use a disk cache. This is the default. +*/ + +/*! + \enum QQuickWebEngineProfile::PersistentCookiesPolicy + + This enum describes policy for cookie persistency: + + \value NoPersistentCookies + Both session and persistent cookies are stored in memory. This is the only setting + possible if \c off-the-record is set or no persistent data path is available. + \value AllowPersistentCookies + Cookies marked persistent are saved to and restored from disk, whereas session cookies + are only stored to disk for crash recovery. This is the default setting. + \value ForcePersistentCookies + Both session and persistent cookies are saved to and restored from disk. +*/ + +/*! + \fn QQuickWebEngineProfile::downloadRequested(QQuickWebEngineDownloadItem *download) + + This signal is emitted whenever a download has been triggered. + The \a download argument holds the state of the download. + The download has to be explicitly accepted with + \c{QQuickWebEngineDownloadItem::accept()} or it will be + cancelled by default. + The download item is parented by the profile. If it is not accepted, it + will be deleted immediately after the signal emission. + This signal cannot be used with a queued connection. +*/ + +/*! + \fn QQuickWebEngineProfile::downloadFinished(QQuickWebEngineDownloadItem *download) + + This signal is emitted whenever downloading stops, because it finished successfully, was + cancelled, or was interrupted (for example, because connectivity was lost). + The \a download argument holds the state of the finished download instance. +*/ + QQuickWebEngineProfilePrivate::QQuickWebEngineProfilePrivate(BrowserContextAdapter* browserContext) : m_settings(new QQuickWebEngineSettings()) , m_browserContextRef(browserContext) @@ -163,8 +225,12 @@ void QQuickWebEngineProfilePrivate::downloadUpdated(const DownloadItemInfo &info The \a download argument holds the state of the finished download instance. */ -QQuickWebEngineProfile::QQuickWebEngineProfile() - : d_ptr(new QQuickWebEngineProfilePrivate(new BrowserContextAdapter(false))) +/*! + Constructs a new profile with the parent \a parent. +*/ +QQuickWebEngineProfile::QQuickWebEngineProfile(QObject *parent) + : QObject(parent), + d_ptr(new QQuickWebEngineProfilePrivate(new BrowserContextAdapter(false))) { // Sets up the global WebEngineContext QQuickWebEngineProfile::defaultProfile(); @@ -178,6 +244,9 @@ QQuickWebEngineProfile::QQuickWebEngineProfile(QQuickWebEngineProfilePrivate *pr d_ptr->q_ptr = this; } +/*! + \internal +*/ QQuickWebEngineProfile::~QQuickWebEngineProfile() { } @@ -191,6 +260,15 @@ QQuickWebEngineProfile::~QQuickWebEngineProfile() \sa WebEngineProfile::persistentStoragePath, WebEngineProfile::cachePath */ +/*! + \property QQuickWebEngineProfile::storageName + + The storage name that is used to create separate subdirectories for each profile that uses + the disk for storing persistent data and cache. + + \sa QQuickWebEngineProfile::persistentStoragePath, QQuickWebEngineProfile::cachePath +*/ + QString QQuickWebEngineProfile::storageName() const { const Q_D(QQuickWebEngineProfile); @@ -221,6 +299,16 @@ void QQuickWebEngineProfile::setStorageName(const QString &name) An off-the-record profile forces cookies, the HTTP cache, and other normally persistent data to be stored only in memory. */ + + +/*! + \property QQuickWebEngineProfile::offTheRecord + + Whether the web engine profile is \e off-the-record. + An off-the-record profile forces cookies, the HTTP cache, and other normally persistent data + to be stored only in memory. +*/ + bool QQuickWebEngineProfile::isOffTheRecord() const { const Q_D(QQuickWebEngineProfile); @@ -252,6 +340,18 @@ void QQuickWebEngineProfile::setOffTheRecord(bool offTheRecord) QStandardPaths::writableLocation(QStandardPaths::DataLocation) in a directory named using storageName. */ + +/*! + \property QQuickWebEngineProfile::persistentStoragePath + + The path to the location where the persistent data for the browser and web content are + stored. Persistent data includes persistent cookies, HTML5 local storage, and visited links. + + By default, the storage is located below + QStandardPaths::writableLocation(QStandardPaths::DataLocation) in a directory named using + storageName. +*/ + QString QQuickWebEngineProfile::persistentStoragePath() const { const Q_D(QQuickWebEngineProfile); @@ -276,6 +376,17 @@ void QQuickWebEngineProfile::setPersistentStoragePath(const QString &path) below QStandardPaths::writableLocation(QStandardPaths::CacheLocation) in a directory named using storageName. */ + +/*! + \property QQuickWebEngineProfile::cachePath + + The path to the location where the profile's caches are stored, in particular the HTTP cache. + + By default, the caches are stored + below QStandardPaths::writableLocation(QStandardPaths::CacheLocation) in a directory named using + storageName. +*/ + QString QQuickWebEngineProfile::cachePath() const { const Q_D(QQuickWebEngineProfile); @@ -296,6 +407,13 @@ void QQuickWebEngineProfile::setCachePath(const QString &path) The user-agent string sent with HTTP to identify the browser. */ + +/*! + \property QQuickWebEngineProfile::httpUserAgent + + The user-agent string sent with HTTP to identify the browser. +*/ + QString QQuickWebEngineProfile::httpUserAgent() const { const Q_D(QQuickWebEngineProfile); @@ -324,6 +442,14 @@ void QQuickWebEngineProfile::setHttpUserAgent(const QString &userAgent) Uses a disk cache. This is the default value. */ +/*! + \property QQuickWebEngineProfile::httpCacheType + + This enumeration describes the type of the HTTP cache. + + If the profile is off-the-record, MemoryHttpCache is returned. +*/ + QQuickWebEngineProfile::HttpCacheType QQuickWebEngineProfile::httpCacheType() const { const Q_D(QQuickWebEngineProfile); @@ -354,6 +480,13 @@ void QQuickWebEngineProfile::setHttpCacheType(QQuickWebEngineProfile::HttpCacheT Both session and persistent cookies are saved to and restored from disk. */ +/*! + \property QQuickWebEngineProfile::persistentCookiesPolicy + + This enumeration describes the policy of cookie persistency. + If the profile is off-the-record, NoPersistentCookies is returned. +*/ + QQuickWebEngineProfile::PersistentCookiesPolicy QQuickWebEngineProfile::persistentCookiesPolicy() const { const Q_D(QQuickWebEngineProfile); @@ -377,6 +510,16 @@ void QQuickWebEngineProfile::setPersistentCookiesPolicy(QQuickWebEngineProfile:: \sa httpCacheType */ + +/*! + \property QQuickWebEngineProfile::httpCacheMaximumSize + + The maximum size of the HTTP cache. If \c 0, the size will be controlled automatically by + QtWebEngine. The default value is \c 0. + + \sa httpCacheType +*/ + int QQuickWebEngineProfile::httpCacheMaximumSize() const { const Q_D(QQuickWebEngineProfile); @@ -399,6 +542,13 @@ void QQuickWebEngineProfile::setHttpCacheMaximumSize(int maximumSize) \since QtWebEngine 1.2 */ + +/*! + \property QQuickWebEngineProfile::httpAcceptLanguage + + The value of the Accept-Language HTTP request-header field. +*/ + QString QQuickWebEngineProfile::httpAcceptLanguage() const { Q_D(const QQuickWebEngineProfile); @@ -414,6 +564,13 @@ void QQuickWebEngineProfile::setHttpAcceptLanguage(const QString &httpAcceptLang emit httpAcceptLanguageChanged(); } +/*! + Returns the default profile. + + The default profile uses the storage name "Default". + + \sa storageName() +*/ QQuickWebEngineProfile *QQuickWebEngineProfile::defaultProfile() { static QQuickWebEngineProfile *profile = new QQuickWebEngineProfile( @@ -422,6 +579,9 @@ QQuickWebEngineProfile *QQuickWebEngineProfile::defaultProfile() return profile; } +/*! + Returns the cookie store singleton, if one has been set. +*/ QWebEngineCookieStore *QQuickWebEngineProfile::cookieStore() const { const Q_D(QQuickWebEngineProfile); diff --git a/src/webengine/api/qquickwebengineprofile.h b/src/webengine/api/qquickwebengineprofile.h new file mode 100644 index 0000000000000000000000000000000000000000..957e55d3f98a0f7ac83757b48e70f0bfd0324fef --- /dev/null +++ b/src/webengine/api/qquickwebengineprofile.h @@ -0,0 +1,146 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQUICKWEBENGINEPROFILE_H +#define QQUICKWEBENGINEPROFILE_H + + +#include <QtWebEngine/qtwebengineglobal.h> + +#include <QtCore/QObject> +#include <QtCore/QScopedPointer> +#include <QtCore/QString> + +namespace QtWebEngineCore { +class BrowserContextAdapter; +} + +QT_BEGIN_NAMESPACE + +class QQuickWebEngineDownloadItem; +class QQuickWebEngineProfilePrivate; +class QQuickWebEngineSettings; +class QWebEngineCookieStore; + +class Q_WEBENGINE_EXPORT QQuickWebEngineProfile : public QObject { + Q_OBJECT + Q_PROPERTY(QString storageName READ storageName WRITE setStorageName NOTIFY storageNameChanged FINAL) + Q_PROPERTY(bool offTheRecord READ isOffTheRecord WRITE setOffTheRecord NOTIFY offTheRecordChanged FINAL) + Q_PROPERTY(QString persistentStoragePath READ persistentStoragePath WRITE setPersistentStoragePath NOTIFY persistentStoragePathChanged FINAL) + Q_PROPERTY(QString cachePath READ cachePath WRITE setCachePath NOTIFY cachePathChanged FINAL) + Q_PROPERTY(QString httpUserAgent READ httpUserAgent WRITE setHttpUserAgent NOTIFY httpUserAgentChanged FINAL) + Q_PROPERTY(HttpCacheType httpCacheType READ httpCacheType WRITE setHttpCacheType NOTIFY httpCacheTypeChanged FINAL) + Q_PROPERTY(QString httpAcceptLanguage READ httpAcceptLanguage WRITE setHttpAcceptLanguage NOTIFY httpAcceptLanguageChanged FINAL REVISION 1) + Q_PROPERTY(PersistentCookiesPolicy persistentCookiesPolicy READ persistentCookiesPolicy WRITE setPersistentCookiesPolicy NOTIFY persistentCookiesPolicyChanged FINAL) + Q_PROPERTY(int httpCacheMaximumSize READ httpCacheMaximumSize WRITE setHttpCacheMaximumSize NOTIFY httpCacheMaximumSizeChanged FINAL) +public: + QQuickWebEngineProfile(QObject *parent = Q_NULLPTR); + ~QQuickWebEngineProfile(); + + enum HttpCacheType { + MemoryHttpCache, + DiskHttpCache + }; + Q_ENUM(HttpCacheType) + + enum PersistentCookiesPolicy { + NoPersistentCookies, + AllowPersistentCookies, + ForcePersistentCookies + }; + Q_ENUM(PersistentCookiesPolicy) + + QString storageName() const; + void setStorageName(const QString &name); + + bool isOffTheRecord() const; + void setOffTheRecord(bool offTheRecord); + + QString persistentStoragePath() const; + void setPersistentStoragePath(const QString &path); + + QString cachePath() const; + void setCachePath(const QString &path); + + QString httpUserAgent() const; + void setHttpUserAgent(const QString &userAgent); + + HttpCacheType httpCacheType() const; + void setHttpCacheType(QQuickWebEngineProfile::HttpCacheType); + + PersistentCookiesPolicy persistentCookiesPolicy() const; + void setPersistentCookiesPolicy(QQuickWebEngineProfile::PersistentCookiesPolicy); + + int httpCacheMaximumSize() const; + void setHttpCacheMaximumSize(int maxSize); + + QString httpAcceptLanguage() const; + void setHttpAcceptLanguage(const QString &httpAcceptLanguage); + + static QQuickWebEngineProfile *defaultProfile(); + + QWebEngineCookieStore *cookieStore() const; + +Q_SIGNALS: + void storageNameChanged(); + void offTheRecordChanged(); + void persistentStoragePathChanged(); + void cachePathChanged(); + void httpUserAgentChanged(); + void httpCacheTypeChanged(); + void persistentCookiesPolicyChanged(); + void httpCacheMaximumSizeChanged(); + Q_REVISION(1) void httpAcceptLanguageChanged(); + + void downloadRequested(QQuickWebEngineDownloadItem *download); + void downloadFinished(QQuickWebEngineDownloadItem *download); + +private: + Q_DECLARE_PRIVATE(QQuickWebEngineProfile) + QQuickWebEngineProfile(QQuickWebEngineProfilePrivate *, QObject *parent = 0); + QQuickWebEngineSettings *settings() const; + + friend class QQuickWebEngineSettings; + friend class QQuickWebEngineSingleton; + friend class QQuickWebEngineViewPrivate; + friend class QQuickWebEngineDownloadItem; + friend class QQuickWebEngineDownloadItemPrivate; + QScopedPointer<QQuickWebEngineProfilePrivate> d_ptr; +}; + +QT_END_NAMESPACE + +#endif // QQUICKWEBENGINEPROFILE_H diff --git a/src/webengine/api/qquickwebengineprofile_p.h b/src/webengine/api/qquickwebengineprofile_p.h index 5839d51a50f95210f777758a486718ed431663aa..8fb56a6166caf27eb79b8e27b357c89090bd2e7d 100644 --- a/src/webengine/api/qquickwebengineprofile_p.h +++ b/src/webengine/api/qquickwebengineprofile_p.h @@ -48,107 +48,40 @@ // We mean it. // -#include <private/qtwebengineglobal_p.h> +#include "browser_context_adapter_client.h" +#include "qquickwebengineprofile_p.h" +#include "browser_context_adapter.h" -#include <QObject> -#include <QScopedPointer> -#include <QString> - -namespace QtWebEngineCore { -class BrowserContextAdapter; -} +#include <QExplicitlySharedDataPointer> +#include <QMap> +#include <QPointer> QT_BEGIN_NAMESPACE class QQuickWebEngineDownloadItem; -class QQuickWebEngineProfilePrivate; class QQuickWebEngineSettings; -class QWebEngineCookieStore; -class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineProfile : public QObject { - Q_OBJECT - Q_PROPERTY(QString storageName READ storageName WRITE setStorageName NOTIFY storageNameChanged FINAL) - Q_PROPERTY(bool offTheRecord READ isOffTheRecord WRITE setOffTheRecord NOTIFY offTheRecordChanged FINAL) - Q_PROPERTY(QString persistentStoragePath READ persistentStoragePath WRITE setPersistentStoragePath NOTIFY persistentStoragePathChanged FINAL) - Q_PROPERTY(QString cachePath READ cachePath WRITE setCachePath NOTIFY cachePathChanged FINAL) - Q_PROPERTY(QString httpUserAgent READ httpUserAgent WRITE setHttpUserAgent NOTIFY httpUserAgentChanged FINAL) - Q_PROPERTY(HttpCacheType httpCacheType READ httpCacheType WRITE setHttpCacheType NOTIFY httpCacheTypeChanged FINAL) - Q_PROPERTY(QString httpAcceptLanguage READ httpAcceptLanguage WRITE setHttpAcceptLanguage NOTIFY httpAcceptLanguageChanged FINAL REVISION 1) - Q_PROPERTY(PersistentCookiesPolicy persistentCookiesPolicy READ persistentCookiesPolicy WRITE setPersistentCookiesPolicy NOTIFY persistentCookiesPolicyChanged FINAL) - Q_PROPERTY(int httpCacheMaximumSize READ httpCacheMaximumSize WRITE setHttpCacheMaximumSize NOTIFY httpCacheMaximumSizeChanged FINAL) +class QQuickWebEngineProfilePrivate : public QtWebEngineCore::BrowserContextAdapterClient { public: - QQuickWebEngineProfile(); - ~QQuickWebEngineProfile(); - - enum HttpCacheType { - MemoryHttpCache, - DiskHttpCache - }; - Q_ENUM(HttpCacheType) - - enum PersistentCookiesPolicy { - NoPersistentCookies, - AllowPersistentCookies, - ForcePersistentCookies - }; - Q_ENUM(PersistentCookiesPolicy) - - QString storageName() const; - void setStorageName(const QString &name); - - bool isOffTheRecord() const; - void setOffTheRecord(bool offTheRecord); - - QString persistentStoragePath() const; - void setPersistentStoragePath(const QString &path); - - QString cachePath() const; - void setCachePath(const QString &path); + Q_DECLARE_PUBLIC(QQuickWebEngineProfile) + QQuickWebEngineProfilePrivate(QtWebEngineCore::BrowserContextAdapter* browserContext); + ~QQuickWebEngineProfilePrivate(); - QString httpUserAgent() const; - void setHttpUserAgent(const QString &userAgent); + QtWebEngineCore::BrowserContextAdapter *browserContext() const { return m_browserContextRef.data(); } + QQuickWebEngineSettings *settings() const { return m_settings.data(); } - HttpCacheType httpCacheType() const; - void setHttpCacheType(QQuickWebEngineProfile::HttpCacheType); + void cancelDownload(quint32 downloadId); + void downloadDestroyed(quint32 downloadId); - PersistentCookiesPolicy persistentCookiesPolicy() const; - void setPersistentCookiesPolicy(QQuickWebEngineProfile::PersistentCookiesPolicy); - - int httpCacheMaximumSize() const; - void setHttpCacheMaximumSize(int maxSize); - - QString httpAcceptLanguage() const; - void setHttpAcceptLanguage(const QString &httpAcceptLanguage); - - static QQuickWebEngineProfile *defaultProfile(); - - Q_REVISION(1) Q_INVOKABLE QWebEngineCookieStore *cookieStore() const; - -signals: - void storageNameChanged(); - void offTheRecordChanged(); - void persistentStoragePathChanged(); - void cachePathChanged(); - void httpUserAgentChanged(); - void httpCacheTypeChanged(); - void persistentCookiesPolicyChanged(); - void httpCacheMaximumSizeChanged(); - Q_REVISION(1) void httpAcceptLanguageChanged(); - - void downloadRequested(QQuickWebEngineDownloadItem *download); - void downloadFinished(QQuickWebEngineDownloadItem *download); + void downloadRequested(DownloadItemInfo &info) Q_DECL_OVERRIDE; + void downloadUpdated(const DownloadItemInfo &info) Q_DECL_OVERRIDE; private: - Q_DECLARE_PRIVATE(QQuickWebEngineProfile) - QQuickWebEngineProfile(QQuickWebEngineProfilePrivate *, QObject *parent = 0); - QQuickWebEngineSettings *settings() const; - - friend class QQuickWebEngineSettings; - friend class QQuickWebEngineSingleton; friend class QQuickWebEngineViewPrivate; - friend class QQuickWebEngineDownloadItem; - friend class QQuickWebEngineDownloadItemPrivate; - QScopedPointer<QQuickWebEngineProfilePrivate> d_ptr; + QQuickWebEngineProfile *q_ptr; + QScopedPointer<QQuickWebEngineSettings> m_settings; + QExplicitlySharedDataPointer<QtWebEngineCore::BrowserContextAdapter> m_browserContextRef; + QMap<quint32, QPointer<QQuickWebEngineDownloadItem> > m_ongoingDownloads; }; QT_END_NAMESPACE diff --git a/src/webengine/api/qquickwebengineprofile_p_p.h b/src/webengine/api/qquickwebengineprofile_p_p.h deleted file mode 100644 index 4df5f19340bdee02d6291def8e9063bd539d0558..0000000000000000000000000000000000000000 --- a/src/webengine/api/qquickwebengineprofile_p_p.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWebEngine module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQUICKWEBENGINEPROFILE_P_P_H -#define QQUICKWEBENGINEPROFILE_P_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "browser_context_adapter_client.h" -#include "qquickwebengineprofile_p.h" - -#include <QExplicitlySharedDataPointer> -#include <QMap> -#include <QPointer> - -QT_BEGIN_NAMESPACE - -class QQuickWebEngineDownloadItem; -class QQuickWebEngineSettings; - -class QQuickWebEngineProfilePrivate : public QtWebEngineCore::BrowserContextAdapterClient { -public: - Q_DECLARE_PUBLIC(QQuickWebEngineProfile) - QQuickWebEngineProfilePrivate(QtWebEngineCore::BrowserContextAdapter* browserContext); - ~QQuickWebEngineProfilePrivate(); - - QtWebEngineCore::BrowserContextAdapter *browserContext() const { return m_browserContextRef.data(); } - QQuickWebEngineSettings *settings() const { return m_settings.data(); } - - void cancelDownload(quint32 downloadId); - void downloadDestroyed(quint32 downloadId); - - void downloadRequested(DownloadItemInfo &info) Q_DECL_OVERRIDE; - void downloadUpdated(const DownloadItemInfo &info) Q_DECL_OVERRIDE; - -private: - friend class QQuickWebEngineViewPrivate; - QQuickWebEngineProfile *q_ptr; - QScopedPointer<QQuickWebEngineSettings> m_settings; - QExplicitlySharedDataPointer<QtWebEngineCore::BrowserContextAdapter> m_browserContextRef; - QMap<quint32, QPointer<QQuickWebEngineDownloadItem> > m_ongoingDownloads; -}; - -QT_END_NAMESPACE - -#endif // QQUICKWEBENGINEPROFILE_P_P_H diff --git a/src/webengine/api/qquickwebenginesettings.cpp b/src/webengine/api/qquickwebenginesettings.cpp index 8f2e1bcf22db5a06f36cfbdbbfd957a57bf6491f..fe421993a0933a0edd13d4dde704143657eb3f43 100644 --- a/src/webengine/api/qquickwebenginesettings.cpp +++ b/src/webengine/api/qquickwebenginesettings.cpp @@ -36,9 +36,9 @@ #include "qquickwebenginesettings_p.h" -#include "qquickwebengineprofile_p.h" #include "web_engine_settings.h" +#include <QtWebEngine/QQuickWebEngineProfile> #include <QtCore/QList> QT_BEGIN_NAMESPACE diff --git a/src/webengine/api/qquickwebenginesingleton.cpp b/src/webengine/api/qquickwebenginesingleton.cpp index ba4d470167c0697d477eb168fd83082520897712..b7a8c3b69700e5f803c3266f96a8f4f81e0c46af 100644 --- a/src/webengine/api/qquickwebenginesingleton.cpp +++ b/src/webengine/api/qquickwebenginesingleton.cpp @@ -37,7 +37,7 @@ #include "qquickwebenginesingleton_p.h" #include "qquickwebenginesettings_p.h" -#include "qquickwebengineprofile_p.h" +#include <QtWebEngine/QQuickWebEngineProfile> QT_BEGIN_NAMESPACE diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index 5c0e67f706ac3d29c0afb435fca6e47dc3c68a9c..ff2647e3e1b0fd9e236c721d046ad5da989e5ec7 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -48,7 +48,6 @@ #include "qquickwebenginenavigationrequest_p.h" #include "qquickwebenginenewviewrequest_p.h" #include "qquickwebengineprofile_p.h" -#include "qquickwebengineprofile_p_p.h" #include "qquickwebenginesettings_p.h" #include "qquickwebenginescript_p_p.h" @@ -74,6 +73,7 @@ #include <QQmlEngine> #include <QQmlProperty> #include <QQmlWebChannel> +#include <QQuickWebEngineProfile> #include <QScreen> #include <QStringBuilder> #include <QUrl> diff --git a/src/webengine/doc/src/qtwebengine-modules.qdoc b/src/webengine/doc/src/qtwebengine-modules.qdoc index 8530f5d0189841a9dc893eaf429a8c3ade6705d6..451165b26f68301c44016ff9c3411f0c84094a30 100644 --- a/src/webengine/doc/src/qtwebengine-modules.qdoc +++ b/src/webengine/doc/src/qtwebengine-modules.qdoc @@ -42,4 +42,7 @@ \section2 Qt WebEngineWidgets Module \generatelist {classesbymodule QtWebEngineWidgets} + + \section2 Qt WebEngine Module + \generatelist {classesbymodule QtWebEngine} */ diff --git a/src/webengine/plugin/plugin.cpp b/src/webengine/plugin/plugin.cpp index fa84c9f5a53b3c09b01575a374554385c8c709fe..ca4fb2e74af927439807df03079fa07dd778ad19 100644 --- a/src/webengine/plugin/plugin.cpp +++ b/src/webengine/plugin/plugin.cpp @@ -35,6 +35,7 @@ ****************************************************************************/ #include <QtQml/qqmlextensionplugin.h> +#include <QtWebEngine/QQuickWebEngineProfile> #include "qquickwebenginecertificateerror_p.h" #include "qquickwebenginedownloaditem_p.h" @@ -42,7 +43,6 @@ #include "qquickwebengineloadrequest_p.h" #include "qquickwebenginenavigationrequest_p.h" #include "qquickwebenginenewviewrequest_p.h" -#include "qquickwebengineprofile_p.h" #include "qquickwebenginesettings_p.h" #include "qquickwebenginesingleton_p.h" #include "qquickwebengineview_p.h" diff --git a/src/webengine/webengine.pro b/src/webengine/webengine.pro index 8bb5a8e77a1a0b19f2bf7495d82e1041673be139..8f802d5c47c844846b19d275b5ae9a8b839b7e90 100644 --- a/src/webengine/webengine.pro +++ b/src/webengine/webengine.pro @@ -37,8 +37,8 @@ HEADERS = \ api/qquickwebengineloadrequest_p.h \ api/qquickwebenginenavigationrequest_p.h \ api/qquickwebenginenewviewrequest_p.h \ + api/qquickwebengineprofile.h \ api/qquickwebengineprofile_p.h \ - api/qquickwebengineprofile_p_p.h \ api/qquickwebenginescript_p.h \ api/qquickwebenginesettings_p.h \ api/qquickwebenginesingleton_p.h \ diff --git a/tests/auto/quick/publicapi/tst_publicapi.cpp b/tests/auto/quick/publicapi/tst_publicapi.cpp index 9bb4711fc55a15099b87d293fba4c943ae58a966..face62352b874f1fc80a1daf69494a85c1155d5c 100644 --- a/tests/auto/quick/publicapi/tst_publicapi.cpp +++ b/tests/auto/quick/publicapi/tst_publicapi.cpp @@ -46,6 +46,7 @@ #include <QMetaType> #include <QQmlListProperty> #include <QtTest/QtTest> +#include <QtWebEngine/QQuickWebEngineProfile> #include <private/qquickwebengineview_p.h> #include <private/qquickwebenginecertificateerror_p.h> #include <private/qquickwebenginedownloaditem_p.h> @@ -53,7 +54,6 @@ #include <private/qquickwebengineloadrequest_p.h> #include <private/qquickwebenginenavigationrequest_p.h> #include <private/qquickwebenginenewviewrequest_p.h> -#include <private/qquickwebengineprofile_p.h> #include <private/qquickwebenginescript_p.h> #include <private/qquickwebenginesettings_p.h> #include <private/qquickwebenginesingleton_p.h> diff --git a/tests/quicktestbrowser/main.cpp b/tests/quicktestbrowser/main.cpp index 12ebfa2d59865ce46bb702cdbda42073916b8807..61977a01833a63c94783bf8a53118f13cd6f8b94 100644 --- a/tests/quicktestbrowser/main.cpp +++ b/tests/quicktestbrowser/main.cpp @@ -52,6 +52,7 @@ typedef QGuiApplication Application; #include <QtQml/QQmlContext> #include <QtQml/QQmlComponent> #include <QtWebEngine/qtwebengineglobal.h> +#include <QtWebEngine/QQuickWebEngineProfile> #include <QtWebEngineCore/qwebenginecookiestore.h> static QUrl startupUrl() @@ -84,17 +85,10 @@ int main(int argc, char **argv) appEngine.load(QUrl("qrc:/ApplicationRoot.qml")); QObject *rootObject = appEngine.rootObjects().first(); - QQmlComponent component(&appEngine); - component.setData(QByteArrayLiteral("import QtQuick 2.0\n" - "import QtWebEngine 1.1\n" - "WebEngineProfile {\n" - "storageName: \"Test\"\n" - "}") - , QUrl()); - QObject *profile = component.create(); + QQuickWebEngineProfile *profile = new QQuickWebEngineProfile(rootObject); + QWebEngineCookieStore *client = profile->cookieStore(); + const QMetaObject *rootMeta = rootObject->metaObject(); - QWebEngineCookieStore *client = 0; - QMetaObject::invokeMethod(profile, "cookieStore", Q_RETURN_ARG(QWebEngineCookieStore*, client)); int index = rootMeta->indexOfProperty("thirdPartyCookiesEnabled"); Q_ASSERT(index != -1); QMetaProperty thirdPartyCookiesProperty = rootMeta->property(index);