summaryrefslogtreecommitdiffstats
path: root/src/webenginequick
diff options
context:
space:
mode:
Diffstat (limited to 'src/webenginequick')
-rw-r--r--src/webenginequick/api/qquickwebenginefaviconprovider.cpp224
-rw-r--r--src/webenginequick/api/qquickwebenginefaviconprovider_p_p.h83
-rw-r--r--src/webenginequick/api/qquickwebengineforeigntypes_p.h34
-rw-r--r--src/webenginequick/api/qquickwebengineprofile.cpp229
-rw-r--r--src/webenginequick/api/qquickwebengineprofile.h20
-rw-r--r--src/webenginequick/api/qquickwebenginesettings.cpp4
-rw-r--r--src/webenginequick/api/qquickwebengineview.cpp259
-rw-r--r--src/webenginequick/api/qquickwebengineview_p.h42
-rw-r--r--src/webenginequick/api/qquickwebengineview_p_p.h16
-rw-r--r--src/webenginequick/doc/src/webengine_permission.qdoc137
-rw-r--r--src/webenginequick/doc/src/webengineframe.qdoc129
-rw-r--r--src/webenginequick/doc/src/webengineview_lgpl.qdoc70
12 files changed, 1007 insertions, 240 deletions
diff --git a/src/webenginequick/api/qquickwebenginefaviconprovider.cpp b/src/webenginequick/api/qquickwebenginefaviconprovider.cpp
index 56bbb97ac..00c7f1949 100644
--- a/src/webenginequick/api/qquickwebenginefaviconprovider.cpp
+++ b/src/webenginequick/api/qquickwebenginefaviconprovider.cpp
@@ -11,9 +11,9 @@
#include "web_contents_adapter.h"
#include <QtCore/qmimedatabase.h>
-#include <QtCore/qtimer.h>
#include <QtGui/qicon.h>
#include <QtGui/qpixmap.h>
+#include <QThread>
QT_BEGIN_NAMESPACE
@@ -79,123 +79,167 @@ static bool isIconURL(const QUrl &url)
return false;
}
-static QQuickWebEngineView *findViewById(const QString &id, QList<QQuickWebEngineView *> *views)
-{
- QQuickWebEngineView *result = nullptr;
- for (QQuickWebEngineView *view : *views) {
- if (isIconURL(QUrl(id))) {
- if (view->icon() == QQuickWebEngineFaviconProvider::faviconProviderUrl(QUrl(id))) {
- result = view;
- break;
- }
- } else if (view->url() == QUrl(id)) {
- result = view;
- break;
- }
- }
-
- return result;
-}
-
-FaviconImageResponseRunnable::FaviconImageResponseRunnable(const QString &id,
- const QSize &requestedSize,
- QList<QQuickWebEngineView *> *views)
- : m_id(id), m_requestedSize(requestedSize), m_views(views)
+FaviconImageRequester::FaviconImageRequester(const QUrl &imageSource, const QSize &requestedSize)
+ : m_imageSource(imageSource), m_requestedSize(requestedSize)
{
}
-void FaviconImageResponseRunnable::run()
+void FaviconImageRequester::start()
{
- if (tryNextView() == -1) {
+ if (!tryNextView()) {
// There is no non-otr view to access icon database.
Q_EMIT done(QPixmap());
}
}
-void FaviconImageResponseRunnable::iconRequestDone(const QIcon &icon)
+void FaviconImageRequester::iconRequestDone(const QIcon &icon)
{
if (icon.isNull()) {
- if (tryNextView() == -1) {
+ if (!tryNextView()) {
// Ran out of views.
Q_EMIT done(QPixmap());
}
return;
}
- Q_EMIT done(extractPixmap(icon, m_requestedSize).copy());
+ Q_EMIT done(extractPixmap(icon, m_requestedSize));
+}
+
+bool FaviconImageRequester::tryNextView()
+{
+ if (auto view = getNextViewForProcessing()) {
+ requestFaviconFromDatabase(view);
+ return true;
+ }
+
+ return false;
+}
+
+void FaviconImageRequester::requestFaviconFromDatabase(QPointer<QQuickWebEngineView> view)
+{
+ QtWebEngineCore::ProfileAdapter *profileAdapter = view->d_ptr->profileAdapter();
+ bool touchIconsEnabled = view->profile()->settings()->touchIconsEnabled();
+ if (isIconURL(m_imageSource)) {
+ profileAdapter->requestIconForIconURL(
+ m_imageSource, qMax(m_requestedSize.width(), m_requestedSize.height()),
+ touchIconsEnabled, [this](const QIcon &icon, const QUrl &) {
+ QMetaObject::invokeMethod(this, "iconRequestDone", Qt::QueuedConnection,
+ Q_ARG(const QIcon &, icon));
+ });
+ } else {
+ profileAdapter->requestIconForPageURL(
+ m_imageSource, qMax(m_requestedSize.width(), m_requestedSize.height()),
+ touchIconsEnabled, [this](const QIcon &icon, const QUrl &, const QUrl &) {
+ QMetaObject::invokeMethod(this, "iconRequestDone", Qt::QueuedConnection,
+ Q_ARG(const QIcon &, icon));
+ });
+ }
}
-int FaviconImageResponseRunnable::tryNextView()
+QPointer<QQuickWebEngineView> FaviconImageRequester::getNextViewForProcessing()
{
- for (; m_nextViewIndex < m_views->size(); ++m_nextViewIndex) {
- QQuickWebEngineView *view = m_views->at(m_nextViewIndex);
+ Q_ASSERT(QThread::currentThread() == QCoreApplication::instance()->thread());
+
+ for (QPointer<QQuickWebEngineView> view : FaviconProviderHelper::instance()->views()) {
+ if (view.isNull())
+ continue;
if (view->profile()->isOffTheRecord())
continue;
+ if (m_processedViews.contains(view))
+ continue;
+ m_processedViews.append(view);
+ return view;
+ }
+ return nullptr;
+}
- requestIconOnUIThread(view);
+FaviconProviderHelper::FaviconProviderHelper()
+{
+ moveToThread(qApp->thread());
+}
- return m_nextViewIndex++;
- }
+FaviconProviderHelper *FaviconProviderHelper::instance()
+{
+ static FaviconProviderHelper instance;
+ return &instance;
+}
- return -1;
+void FaviconProviderHelper::attach(QPointer<QQuickWebEngineView> view)
+{
+ if (!m_views.contains(view))
+ m_views.append(view);
}
-void FaviconImageResponseRunnable::requestIconOnUIThread(QQuickWebEngineView *view)
+void FaviconProviderHelper::detach(QPointer<QQuickWebEngineView> view)
{
- QTimer *timer = new QTimer();
- timer->moveToThread(qApp->thread());
- timer->setSingleShot(true);
- QObject::connect(timer, &QTimer::timeout, [this, view, timer]() {
- QtWebEngineCore::ProfileAdapter *profileAdapter = view->d_ptr->profileAdapter();
- bool touchIconsEnabled = view->profile()->settings()->touchIconsEnabled();
- if (isIconURL(QUrl(m_id))) {
- profileAdapter->requestIconForIconURL(QUrl(m_id),
- qMax(m_requestedSize.width(), m_requestedSize.height()),
- touchIconsEnabled,
- [this](const QIcon &icon, const QUrl &) { iconRequestDone(icon); });
- } else {
- profileAdapter->requestIconForPageURL(QUrl(m_id),
- qMax(m_requestedSize.width(), m_requestedSize.height()),
- touchIconsEnabled,
- [this](const QIcon &icon, const QUrl &, const QUrl &) { iconRequestDone(icon); });
- }
- timer->deleteLater();
- });
- QMetaObject::invokeMethod(timer, "start", Qt::QueuedConnection, Q_ARG(int, 0));
+ m_views.removeAll(view);
}
-FaviconImageResponse::FaviconImageResponse()
+void FaviconProviderHelper::handleImageRequest(QPointer<FaviconImageResponse> faviconResponse)
{
- Q_EMIT finished();
+ Q_ASSERT(QThread::currentThread() == QCoreApplication::instance()->thread());
+
+ if (faviconResponse.isNull())
+ return;
+
+ if (m_views.isEmpty()) {
+ QMetaObject::invokeMethod(faviconResponse, "handleDone", Qt::QueuedConnection,
+ Q_ARG(QPixmap, QPixmap()));
+ return;
+ }
+
+ auto view = findViewByImageSource(faviconResponse->imageSource());
+ if (view) {
+ QIcon icon = view->d_ptr->adapter->icon();
+ if (!icon.isNull()) {
+ QMetaObject::invokeMethod(
+ faviconResponse, "handleDone", Qt::QueuedConnection,
+ Q_ARG(QPixmap, extractPixmap(icon, faviconResponse->requestedSize())));
+ return;
+ }
+ }
+ startFaviconRequest(faviconResponse);
}
-FaviconImageResponse::FaviconImageResponse(const QString &id, const QSize &requestedSize,
- QList<QQuickWebEngineView *> *views, QThreadPool *pool)
+QPointer<QQuickWebEngineView> FaviconProviderHelper::findViewByImageSource(const QUrl &imageSource) const
{
- if (QQuickWebEngineView *view = findViewById(id, views)) {
- QTimer *timer = new QTimer();
- timer->moveToThread(qApp->thread());
- timer->setSingleShot(true);
- QObject::connect(timer, &QTimer::timeout, [this, id, requestedSize, views, pool, view, timer]() {
- QIcon icon = view->d_ptr->adapter->icon();
- if (icon.isNull())
- startRunnable(id, requestedSize, views, pool);
- else
- handleDone(extractPixmap(icon, requestedSize).copy());
- timer->deleteLater();
- });
- QMetaObject::invokeMethod(timer, "start", Qt::QueuedConnection, Q_ARG(int, 0));
- } else {
- startRunnable(id, requestedSize, views, pool);
+ for (QPointer<QQuickWebEngineView> view : m_views) {
+ if (view.isNull())
+ continue;
+
+ if (isIconURL(imageSource)) {
+ if (view->icon() == QQuickWebEngineFaviconProvider::faviconProviderUrl(imageSource)) {
+ return view;
+ }
+ } else if (view->url() == imageSource) {
+ return view;
+ }
}
+
+ return nullptr;
}
-FaviconImageResponse::~FaviconImageResponse() { }
+void FaviconProviderHelper::startFaviconRequest(QPointer<FaviconImageResponse> faviconResponse)
+{
+ FaviconImageRequester *requester = new FaviconImageRequester(faviconResponse->imageSource(),
+ faviconResponse->requestedSize());
+
+ connect(requester, &FaviconImageRequester::done, [requester, faviconResponse](QPixmap pixmap) {
+ QMetaObject::invokeMethod(faviconResponse, "handleDone", Qt::QueuedConnection,
+ Q_ARG(QPixmap, pixmap));
+ requester->deleteLater();
+ });
+
+ requester->start();
+}
+
+FaviconImageResponse::FaviconImageResponse(const QUrl &imageSource, const QSize &requestedSize)
+ : m_imageSource(imageSource), m_requestedSize(requestedSize)
+{
+}
void FaviconImageResponse::handleDone(QPixmap pixmap)
{
- if (m_runnable)
- delete m_runnable;
m_image = pixmap.toImage();
Q_EMIT finished();
}
@@ -205,16 +249,6 @@ QQuickTextureFactory *FaviconImageResponse::textureFactory() const
return QQuickTextureFactory::textureFactoryForImage(m_image);
}
-void FaviconImageResponse::startRunnable(const QString &id, const QSize &requestedSize,
- QList<QQuickWebEngineView *> *views, QThreadPool *pool)
-{
- m_runnable = new FaviconImageResponseRunnable(id, requestedSize, views);
- m_runnable->setAutoDelete(false);
- connect(m_runnable, &FaviconImageResponseRunnable::done, this,
- &FaviconImageResponse::handleDone);
- pool->start(m_runnable);
-}
-
QString QQuickWebEngineFaviconProvider::identifier()
{
return QStringLiteral("favicon");
@@ -238,17 +272,17 @@ QUrl QQuickWebEngineFaviconProvider::faviconProviderUrl(const QUrl &url)
return providerUrl;
}
-QQuickWebEngineFaviconProvider::QQuickWebEngineFaviconProvider() { }
-
-QQuickWebEngineFaviconProvider::~QQuickWebEngineFaviconProvider() { }
+QQuickWebEngineFaviconProvider::QQuickWebEngineFaviconProvider()
+{
+ connect(this, &QQuickWebEngineFaviconProvider::imageResponseRequested,
+ FaviconProviderHelper::instance(), &FaviconProviderHelper::handleImageRequest);
+}
QQuickImageResponse *
QQuickWebEngineFaviconProvider::requestImageResponse(const QString &id, const QSize &requestedSize)
{
- if (m_views.empty())
- return new FaviconImageResponse;
-
- FaviconImageResponse *response = new FaviconImageResponse(id, requestedSize, &m_views, &m_pool);
+ FaviconImageResponse *response = new FaviconImageResponse(QUrl(id), requestedSize);
+ emit imageResponseRequested(response);
return response;
}
diff --git a/src/webenginequick/api/qquickwebenginefaviconprovider_p_p.h b/src/webenginequick/api/qquickwebenginefaviconprovider_p_p.h
index 89bfb6e73..f1d948413 100644
--- a/src/webenginequick/api/qquickwebenginefaviconprovider_p_p.h
+++ b/src/webenginequick/api/qquickwebenginefaviconprovider_p_p.h
@@ -17,8 +17,6 @@
#include <QtWebEngineQuick/private/qtwebenginequickglobal_p.h>
#include <QtCore/qlist.h>
-#include <QtCore/qrunnable.h>
-#include <QtCore/qthreadpool.h>
#include <QtGui/qimage.h>
#include <QtQuick/qquickimageprovider.h>
@@ -26,65 +24,84 @@ QT_BEGIN_NAMESPACE
class QQuickWebEngineView;
-class FaviconImageResponseRunnable : public QObject, public QRunnable
+class FaviconImageResponse : public QQuickImageResponse
{
Q_OBJECT
public:
- FaviconImageResponseRunnable(const QString &id, const QSize &requestedSize,
- QList<QQuickWebEngineView *> *views);
- void run() override;
- void iconRequestDone(const QIcon &icon);
+ FaviconImageResponse(const QUrl &imageSource, const QSize &requestedSize);
-signals:
- void done(QPixmap pixmap);
+ QQuickTextureFactory *textureFactory() const override;
+ const QUrl &imageSource() const { return m_imageSource; }
+ const QSize &requestedSize() const { return m_requestedSize; }
-private:
- int tryNextView();
- void requestIconOnUIThread(QQuickWebEngineView *view);
+public slots:
+ void handleDone(QPixmap pixmap);
- QString m_id;
+private:
+ QImage m_image;
+ QUrl m_imageSource;
QSize m_requestedSize;
- QList<QQuickWebEngineView *> *m_views;
- int m_nextViewIndex = 0;
};
-class FaviconImageResponse : public QQuickImageResponse
+class FaviconImageRequester : public QObject
{
+ Q_OBJECT
+
public:
- FaviconImageResponse();
- FaviconImageResponse(const QString &id, const QSize &requestedSize,
- QList<QQuickWebEngineView *> *views, QThreadPool *pool);
- ~FaviconImageResponse();
- void handleDone(QPixmap pixmap);
- QQuickTextureFactory *textureFactory() const override;
+ FaviconImageRequester(const QUrl &imageSource, const QSize &requestedSize);
+ void start();
+
+public slots:
+ void iconRequestDone(const QIcon &icon);
+
+signals:
+ void done(QPixmap pixmap);
private:
- void startRunnable(const QString &id, const QSize &requestedSize,
- QList<QQuickWebEngineView *> *views, QThreadPool *pool);
+ bool tryNextView();
+ void requestFaviconFromDatabase(QPointer<QQuickWebEngineView> view);
+ QPointer<QQuickWebEngineView> getNextViewForProcessing();
- FaviconImageResponseRunnable *m_runnable = nullptr;
- QImage m_image;
+ QUrl m_imageSource;
+ QSize m_requestedSize;
+ QList<QPointer<QQuickWebEngineView>> m_processedViews;
};
class Q_WEBENGINEQUICK_EXPORT QQuickWebEngineFaviconProvider : public QQuickAsyncImageProvider
{
+ Q_OBJECT
+
public:
static QString identifier();
static QUrl faviconProviderUrl(const QUrl &);
QQuickWebEngineFaviconProvider();
- ~QQuickWebEngineFaviconProvider();
-
- void attach(QQuickWebEngineView *view) { m_views.append(view); }
- void detach(QQuickWebEngineView *view) { m_views.removeAll(view); }
-
QQuickImageResponse *requestImageResponse(const QString &id,
const QSize &requestedSize) override;
+signals:
+ void imageResponseRequested(QPointer<FaviconImageResponse> faviconResponse);
+};
+
+class Q_WEBENGINEQUICK_EXPORT FaviconProviderHelper : public QObject
+{
+ Q_OBJECT
+
+public:
+ static FaviconProviderHelper *instance();
+ void attach(QPointer<QQuickWebEngineView> view);
+ void detach(QPointer<QQuickWebEngineView> view);
+ const QList<QPointer<QQuickWebEngineView>> &views() const { return m_views; }
+
+public slots:
+ void handleImageRequest(QPointer<FaviconImageResponse> faviconResponse);
+
private:
- QThreadPool m_pool;
- QList<QQuickWebEngineView *> m_views;
+ FaviconProviderHelper();
+ void startFaviconRequest(QPointer<FaviconImageResponse> faviconResponse);
+ QPointer<QQuickWebEngineView> findViewByImageSource(const QUrl &imageSource) const;
+ QList<QPointer<QQuickWebEngineView>> m_views;
};
QT_END_NAMESPACE
diff --git a/src/webenginequick/api/qquickwebengineforeigntypes_p.h b/src/webenginequick/api/qquickwebengineforeigntypes_p.h
index 2d205254e..58dee066f 100644
--- a/src/webenginequick/api/qquickwebengineforeigntypes_p.h
+++ b/src/webenginequick/api/qquickwebengineforeigntypes_p.h
@@ -32,6 +32,7 @@
#include <QtWebEngineCore/qwebengineregisterprotocolhandlerrequest.h>
#include <QtWebEngineCore/qwebenginefilesystemaccessrequest.h>
#include <QtWebEngineCore/qwebenginewebauthuxrequest.h>
+#include <QtWebEngineCore/qwebenginepermission.h>
QT_BEGIN_NAMESPACE
@@ -231,6 +232,39 @@ struct ForeignWebEngineWebAuthUxRequest
QML_UNCREATABLE("")
};
+struct ForeginWebEngineWebAuthPinRequest
+{
+ Q_GADGET
+ QML_FOREIGN(QWebEngineWebAuthPinRequest)
+ QML_NAMED_ELEMENT(WebEngineWebAuthPinRequest)
+ QML_ADDED_IN_VERSION(6, 8)
+ QML_UNCREATABLE("")
+};
+
+// To prevent the same type from being exported twice into qmltypes
+// (for value type and for the enums)
+class QWebEnginePermissionDerived : public QWebEnginePermission
+{
+ Q_GADGET
+};
+
+namespace ForeignWebEnginePermissionNamespace
+{
+ Q_NAMESPACE
+ QML_FOREIGN_NAMESPACE(QWebEnginePermissionDerived)
+ QML_NAMED_ELEMENT(WebEnginePermission)
+ QML_ADDED_IN_VERSION(6, 8)
+}
+
+struct ForeignWebEnginePermission
+{
+ Q_GADGET
+ QML_FOREIGN(QWebEnginePermission)
+ QML_VALUE_TYPE(webEnginePermission)
+ QML_ADDED_IN_VERSION(6, 8)
+ QML_UNCREATABLE("")
+};
+
QT_END_NAMESPACE
#endif // QQUICKWEBENGINEFOREIGNTYPES_H
diff --git a/src/webenginequick/api/qquickwebengineprofile.cpp b/src/webenginequick/api/qquickwebengineprofile.cpp
index 7c3d11fcf..d3373d0b9 100644
--- a/src/webenginequick/api/qquickwebengineprofile.cpp
+++ b/src/webenginequick/api/qquickwebengineprofile.cpp
@@ -19,6 +19,7 @@
#include <QtWebEngineCore/qwebenginenotification.h>
#include <QtWebEngineCore/private/qwebenginedownloadrequest_p.h>
#include <QtWebEngineCore/qwebengineurlscheme.h>
+#include <QtWebEngineCore/private/qwebenginepermission_p.h>
#include <QtCore/qdir.h>
#include <QtCore/qfileinfo.h>
@@ -95,6 +96,28 @@ QT_BEGIN_NAMESPACE
*/
/*!
+ \enum QQuickWebEngineProfile::PersistentPermissionsPolicy
+
+ \since 6.8
+
+ This enum describes the policy for permission persistence:
+
+ \value NoPersistentPermissions
+ The application will ask for permissions every time they're needed, regardless of
+ whether they've been granted before or not. This is intended for backwards compatibility
+ with existing applications, and otherwise not recommended.
+ \value PersistentPermissionsInMemory
+ A request will be made only the first time a permission is needed. Any subsequent
+ requests will be automatically granted or denied, depending on the initial user choice.
+ This carries over to all pages that use the same QQuickWebEngineProfile instance, until the
+ application is shut down. This is the setting applied if \c off-the-record is set
+ or no persistent data path is available.
+ \value PersistentPermissionsOnDisk
+ Works the same way as \c PersistentPermissionsInMemory, but the permissions are saved to
+ and restored from disk. This is the default setting.
+*/
+
+/*!
\fn QQuickWebEngineProfile::downloadRequested(QQuickWebEngineDownloadRequest *download)
This signal is emitted whenever a download has been triggered.
@@ -105,6 +128,8 @@ QT_BEGIN_NAMESPACE
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.
+
+ \note To use from C++ static_cast \a download to QWebEngineDownloadRequest
*/
/*!
@@ -113,6 +138,8 @@ QT_BEGIN_NAMESPACE
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.
+
+ \note To use from C++ static_cast \a download to QWebEngineDownloadRequest
*/
/*!
@@ -431,15 +458,18 @@ void QQuickWebEngineProfile::setStorageName(const QString &name)
if (d->profileAdapter()->storageName() == name)
return;
ProfileAdapter::HttpCacheType oldCacheType = d->profileAdapter()->httpCacheType();
- ProfileAdapter::PersistentCookiesPolicy oldPolicy = d->profileAdapter()->persistentCookiesPolicy();
+ ProfileAdapter::PersistentCookiesPolicy oldCookiePolicy = d->profileAdapter()->persistentCookiesPolicy();
+ ProfileAdapter::PersistentPermissionsPolicy oldPermissionsPolicy = d->profileAdapter()->persistentPermissionsPolicy();
d->profileAdapter()->setStorageName(name);
emit storageNameChanged();
emit persistentStoragePathChanged();
emit cachePathChanged();
if (d->profileAdapter()->httpCacheType() != oldCacheType)
emit httpCacheTypeChanged();
- if (d->profileAdapter()->persistentCookiesPolicy() != oldPolicy)
+ if (d->profileAdapter()->persistentCookiesPolicy() != oldCookiePolicy)
emit persistentCookiesPolicyChanged();
+ if (d->profileAdapter()->persistentPermissionsPolicy() != oldPermissionsPolicy)
+ emit persistentPermissionsPolicyChanged();
}
/*!
@@ -471,13 +501,16 @@ void QQuickWebEngineProfile::setOffTheRecord(bool offTheRecord)
if (d->profileAdapter()->isOffTheRecord() == offTheRecord)
return;
ProfileAdapter::HttpCacheType oldCacheType = d->profileAdapter()->httpCacheType();
- ProfileAdapter::PersistentCookiesPolicy oldPolicy = d->profileAdapter()->persistentCookiesPolicy();
+ ProfileAdapter::PersistentCookiesPolicy oldCookiePolicy = d->profileAdapter()->persistentCookiesPolicy();
+ ProfileAdapter::PersistentPermissionsPolicy oldPermissionsPolicy = d->profileAdapter()->persistentPermissionsPolicy();
d->profileAdapter()->setOffTheRecord(offTheRecord);
emit offTheRecordChanged();
if (d->profileAdapter()->httpCacheType() != oldCacheType)
emit httpCacheTypeChanged();
- if (d->profileAdapter()->persistentCookiesPolicy() != oldPolicy)
+ if (d->profileAdapter()->persistentCookiesPolicy() != oldCookiePolicy)
emit persistentCookiesPolicyChanged();
+ if (d->profileAdapter()->persistentPermissionsPolicy() != oldPermissionsPolicy)
+ emit persistentPermissionsPolicyChanged();
}
/*!
@@ -624,7 +657,7 @@ void QQuickWebEngineProfile::setHttpCacheType(QQuickWebEngineProfile::HttpCacheT
/*!
\qmlproperty enumeration WebEngineProfile::persistentCookiesPolicy
- This enumeration describes the policy of cookie persistency:
+ This enumeration describes the policy of cookie persistence:
\value WebEngineProfile.NoPersistentCookies
Both session and persistent cookies are stored in memory. This is the only setting
@@ -660,6 +693,51 @@ void QQuickWebEngineProfile::setPersistentCookiesPolicy(QQuickWebEngineProfile::
}
/*!
+ \qmlproperty enumeration WebEngineProfile::persistentPermissionsPolicy
+
+ \since 6.8
+
+ This enumeration describes the policy for permission persistence:
+
+ \value WebEngineProfile.NoPersistentPermissions
+ The application will ask for permissions every time they're needed, regardless of
+ whether they've been granted before or not. This is intended for backwards compatibility
+ with existing applications, and otherwise not recommended.
+ \value WebEngineProfile.PersistentPermissionsInMemory
+ A request will be made only the first time a permission is needed. Any subsequent
+ requests will be automatically granted or denied, depending on the initial user choice.
+ This carries over to all pages using the same QWebEngineProfile instance, until the
+ application is shut down. This is the setting applied if \c off-the-record is set
+ or no persistent data path is available.
+ \value WebEngineProfile.PersistentPermissionsOnDisk
+ Works the same way as \c PersistentPermissionsInMemory, but the permissions are saved to
+ and restored from disk. This is the default setting.
+*/
+
+/*!
+ \property QQuickWebEngineProfile::persistentPermissionsPolicy
+ \since 6.8
+
+ Describes the policy of permission persistence.
+ If the profile is off-the-record, NoPersistentCookies is returned.
+*/
+
+QQuickWebEngineProfile::PersistentPermissionsPolicy QQuickWebEngineProfile::persistentPermissionsPolicy() const
+{
+ Q_D(const QQuickWebEngineProfile);
+ return QQuickWebEngineProfile::PersistentPermissionsPolicy(d->profileAdapter()->persistentPermissionsPolicy());
+}
+
+void QQuickWebEngineProfile::setPersistentPermissionsPolicy(QQuickWebEngineProfile::PersistentPermissionsPolicy newPersistentPermissionsPolicy)
+{
+ Q_D(QQuickWebEngineProfile);
+ ProfileAdapter::PersistentPermissionsPolicy oldPolicy = d->profileAdapter()->persistentPermissionsPolicy();
+ d->profileAdapter()->setPersistentPermissionsPolicy(ProfileAdapter::PersistentPermissionsPolicy(newPersistentPermissionsPolicy));
+ if (d->profileAdapter()->persistentPermissionsPolicy() != oldPolicy)
+ emit persistentPermissionsPolicyChanged();
+}
+
+/*!
\qmlproperty int WebEngineProfile::httpCacheMaximumSize
The maximum size of the HTTP cache. If \c 0, the size will be controlled automatically by
@@ -1036,6 +1114,147 @@ QWebEngineClientHints *QQuickWebEngineProfile::clientHints() const
return d->m_clientHints.data();
}
+/*!
+ \fn QQuickWebEngineProfile::getPermission(const QUrl &securityOrigin, QWebEnginePermission::Feature feature) const
+
+ Returns a QWebEnginePermission object corresponding to a single permission for the provided \a securityOrigin and
+ \a feature. The object may be used to query for the current state of the permission, or to change it. It is not required
+ for a permission to already exist; the returned object may also be used to pre-grant a permission if a website is
+ known to use it.
+
+ \note This may only be used for permanent feature types. Calling it with a transient \a feature will return an invalid object.
+ \since 6.8
+ \sa listPermissions(), QWebEnginePermission::Feature
+ */
+
+/*!
+ \qmlmethod void WebEngineProfile::getPermission(url securityOrigin, WebEnginePermission.Feature feature) const
+
+ Returns a webEnginePermission object corresponding to a single permission for the provided \a securityOrigin and
+ \a feature. The object may be used to query for the current state of the permission, or to change it. It is not required
+ for a permission to already exist; the returned object may also be used to pre-grant a permission if a website is
+ known to use it.
+
+ \note This may only be used for permanent feature types. Calling it with a transient \a feature will return an invalid object.
+ \since 6.8
+ \sa listPermissions()
+ */
+QWebEnginePermission QQuickWebEngineProfile::getPermission(const QUrl &securityOrigin, QWebEnginePermission::Feature feature) const
+{
+ Q_D(const QQuickWebEngineProfile);
+
+ if (feature == QWebEnginePermission::Unsupported) {
+ qWarning("Attempting to get unsupported permission. Returned object will be in an invalid state.");
+ return QWebEnginePermission(new QWebEnginePermissionPrivate());
+ }
+
+ if (QWebEnginePermission::isTransient(feature)) {
+ qWarning() << "Attempting to get permission for feature" << feature << ". Returned object will be in an invalid state.";
+ return QWebEnginePermission(new QWebEnginePermissionPrivate());
+ }
+
+ auto *pvt = new QWebEnginePermissionPrivate(securityOrigin, feature, nullptr, d->profileAdapter());
+ return QWebEnginePermission(pvt);
+}
+
+/*!
+ \qmlmethod list<webEnginePermission> WebEngineProfile::listPermissions() const
+
+ Returns a \l list of webEnginePermission objects, each one representing a single permission currently
+ present in the permissions store. The returned list contains all previously granted/denied permissions for this profile,
+ except for those of a transient feature type.
+
+ \since 6.8
+ \sa getPermission()
+ */
+
+/*!
+ Returns a QList of QWebEnginePermission objects, each one representing a single permission currently
+ present in the permissions store. The returned list contains all previously granted/denied permissions for this profile,
+ except for those of a transient feature type.
+
+ \since 6.8
+ \sa getPermission()
+ */
+QList<QWebEnginePermission> QQuickWebEngineProfile::listPermissions() const
+{
+ Q_D(const QQuickWebEngineProfile);
+ if (persistentPermissionsPolicy() == NoPersistentPermissions)
+ return QList<QWebEnginePermission>();
+ return d->profileAdapter()->listPermissions();
+}
+
+/*!
+ \qmlmethod list<webEnginePermission> WebEngineProfile::listPermissions(url securityOrigin) const
+
+ Returns a \l list of webEnginePermission objects, each one representing a single permission currently
+ present in the permissions store. The returned list contains all previously granted/denied permissions associated with a
+ specific \a securityOrigin for this profile, except for those of a transient feature type.
+
+ \note Since permissions are granted on a per-origin basis, the provided \a securityOrigin will be stripped to its
+ origin form, and the returned list will contain all permissions for the origin. Thus, passing https://www.example.com/some/page.html
+ is the same as passing just https://www.example.com/.
+ \since 6.8
+ \sa getPermission()
+ */
+
+/*!
+ Returns a QList of QWebEnginePermission objects, each one representing a single permission currently
+ present in the permissions store. The returned list contains all previously granted/denied permissions associated with a
+ specific \a securityOrigin for this profile, except for those of a transient feature type.
+
+ \note Since permissions are granted on a per-origin basis, the provided \a securityOrigin will be stripped to its
+ origin form, and the returned list will contain all permissions for the origin. Thus, passing https://www.example.com/some/page.html
+ is the same as passing just https://www.example.com/.
+ \since 6.8
+ \sa getPermission()
+ */
+QList<QWebEnginePermission> QQuickWebEngineProfile::listPermissions(const QUrl &securityOrigin) const
+{
+ Q_D(const QQuickWebEngineProfile);
+ if (persistentPermissionsPolicy() == NoPersistentPermissions)
+ return QList<QWebEnginePermission>();
+ return d->profileAdapter()->listPermissions(securityOrigin);
+}
+
+/*!
+ \qmlmethod list<webEnginePermission> WebEngineProfile::listPermissions(WebEnginePermission.Feature feature) const
+
+ Returns a \l list of webEnginePermission objects, each one representing a single permission currently
+ present in the permissions store. The returned list contains all previously granted/denied permissions of the \a feature
+ type for this profile. If the feature is of a transient or unsupported type, the list will be empty.
+
+ \since 6.8
+ \sa getPermission()
+ */
+
+/*!
+ Returns a QList of QWebEnginePermission objects, each one representing a single permission currently
+ present in the permissions store. The returned list contains all previously granted/denied permissions of the \a feature
+ type for this profile. If the feature is of a transient or unsupported type, the list will be empty.
+
+ \since 6.8
+ \sa getPermission(), QWebEnginePermission::Feature
+ */
+QList<QWebEnginePermission> QQuickWebEngineProfile::listPermissions(QWebEnginePermission::Feature feature) const
+{
+ Q_D(const QQuickWebEngineProfile);
+ if (persistentPermissionsPolicy() == NoPersistentPermissions)
+ return QList<QWebEnginePermission>();
+
+ if (feature == QWebEnginePermission::Unsupported) {
+ qWarning("Attempting to get permission list for an unsupported type. Returned list will be empty.");
+ return QList<QWebEnginePermission>();
+ }
+
+ if (QWebEnginePermission::isTransient(feature)) {
+ qWarning() << "Attempting to get permission list for feature" << feature << ". Returned list will be empty.";
+ return QList<QWebEnginePermission>();
+ }
+
+ return d->profileAdapter()->listPermissions(QUrl(), feature);
+}
+
void QQuickWebEngineProfile::ensureQmlContext(const QObject *object)
{
if (!qmlContext(this)) {
diff --git a/src/webenginequick/api/qquickwebengineprofile.h b/src/webenginequick/api/qquickwebengineprofile.h
index 088a971e0..186a11d7b 100644
--- a/src/webenginequick/api/qquickwebengineprofile.h
+++ b/src/webenginequick/api/qquickwebengineprofile.h
@@ -5,6 +5,7 @@
#define QQUICKWEBENGINEPROFILE_H
#include <QtWebEngineQuick/qtwebenginequickglobal.h>
+#include <QtWebEngineCore/qwebenginepermission.h>
#include <QtCore/qobject.h>
#include <QtCore/qscopedpointer.h>
#include <QtCore/qstring.h>
@@ -33,6 +34,7 @@ class Q_WEBENGINEQUICK_EXPORT QQuickWebEngineProfile : public QObject {
Q_PROPERTY(HttpCacheType httpCacheType READ httpCacheType WRITE setHttpCacheType NOTIFY httpCacheTypeChanged FINAL)
Q_PROPERTY(QString httpAcceptLanguage READ httpAcceptLanguage WRITE setHttpAcceptLanguage NOTIFY httpAcceptLanguageChanged FINAL REVISION(1,1))
Q_PROPERTY(PersistentCookiesPolicy persistentCookiesPolicy READ persistentCookiesPolicy WRITE setPersistentCookiesPolicy NOTIFY persistentCookiesPolicyChanged FINAL)
+ Q_PROPERTY(PersistentPermissionsPolicy persistentPermissionsPolicy READ persistentPermissionsPolicy WRITE setPersistentPermissionsPolicy NOTIFY persistentPermissionsPolicyChanged FINAL)
Q_PROPERTY(int httpCacheMaximumSize READ httpCacheMaximumSize WRITE setHttpCacheMaximumSize NOTIFY httpCacheMaximumSizeChanged FINAL)
Q_PROPERTY(QStringList spellCheckLanguages READ spellCheckLanguages WRITE setSpellCheckLanguages NOTIFY spellCheckLanguagesChanged FINAL REVISION(1,3))
Q_PROPERTY(bool spellCheckEnabled READ isSpellCheckEnabled WRITE setSpellCheckEnabled NOTIFY spellCheckEnabledChanged FINAL REVISION(1,3))
@@ -61,6 +63,13 @@ public:
};
Q_ENUM(PersistentCookiesPolicy)
+ enum PersistentPermissionsPolicy : quint8 {
+ NoPersistentPermissions,
+ PersistentPermissionsInMemory,
+ PersistentPermissionsOnDisk,
+ };
+ Q_ENUM(PersistentPermissionsPolicy)
+
QString storageName() const;
void setStorageName(const QString &name);
@@ -82,6 +91,9 @@ public:
PersistentCookiesPolicy persistentCookiesPolicy() const;
void setPersistentCookiesPolicy(QQuickWebEngineProfile::PersistentCookiesPolicy);
+ PersistentPermissionsPolicy persistentPermissionsPolicy() const;
+ void setPersistentPermissionsPolicy(QQuickWebEngineProfile::PersistentPermissionsPolicy);
+
int httpCacheMaximumSize() const;
void setHttpCacheMaximumSize(int maxSize);
@@ -116,6 +128,11 @@ public:
QWebEngineClientCertificateStore *clientCertificateStore();
QWebEngineClientHints *clientHints() const;
+ Q_REVISION(6,8) Q_INVOKABLE QWebEnginePermission getPermission(const QUrl &securityOrigin, QWebEnginePermission::Feature feature) const;
+ Q_REVISION(6,8) Q_INVOKABLE QList<QWebEnginePermission> listPermissions() const;
+ Q_REVISION(6,8) Q_INVOKABLE QList<QWebEnginePermission> listPermissions(const QUrl &securityOrigin) const;
+ Q_REVISION(6,8) Q_INVOKABLE QList<QWebEnginePermission> listPermissions(QWebEnginePermission::Feature feature) const;
+
static QQuickWebEngineProfile *defaultProfile();
Q_SIGNALS:
@@ -133,6 +150,7 @@ Q_SIGNALS:
Q_REVISION(1,5) void downloadPathChanged();
Q_REVISION(6,5) void pushServiceEnabledChanged();
Q_REVISION(6,7) void clearHttpCacheCompleted();
+ Q_REVISION(6,8) void persistentPermissionsPolicyChanged();
void downloadRequested(QQuickWebEngineDownloadRequest *download);
void downloadFinished(QQuickWebEngineDownloadRequest *download);
@@ -144,7 +162,7 @@ private:
QQuickWebEngineSettings *settings() const;
void ensureQmlContext(const QObject *object);
- friend class FaviconImageResponseRunnable;
+ friend class FaviconImageRequester;
friend class QQuickWebEngineSingleton;
friend class QQuickWebEngineViewPrivate;
friend class QQuickWebEngineView;
diff --git a/src/webenginequick/api/qquickwebenginesettings.cpp b/src/webenginequick/api/qquickwebenginesettings.cpp
index 31ed7a661..5dc093a44 100644
--- a/src/webenginequick/api/qquickwebenginesettings.cpp
+++ b/src/webenginequick/api/qquickwebenginesettings.cpp
@@ -79,7 +79,7 @@ bool QQuickWebEngineSettings::javascriptCanOpenWindows() const
Since unrestricted clipboard access is a potential security concern, it is
recommended that applications leave this disabled and instead respond to
- \l{WebEngineView::ClipboardReadWrite}{ClipboardReadWrite} feature permission requests.
+ \l{WebEnginePermission::ClipboardReadWrite}{ClipboardReadWrite} feature permission requests.
Disabled by default.
*/
@@ -389,7 +389,7 @@ bool QQuickWebEngineSettings::webRTCPublicInterfacesOnly() const
Since unrestricted clipboard access is a potential security concern, it is
recommended that applications leave this disabled and instead respond to
- \l{WebEngineView::ClipboardReadWrite}{ClipboardReadWrite} feature permission requests.
+ \l{WebEnginePermission::ClipboardReadWrite}{ClipboardReadWrite} feature permission requests.
Disabled by default.
*/
diff --git a/src/webenginequick/api/qquickwebengineview.cpp b/src/webenginequick/api/qquickwebengineview.cpp
index 89cdd20ca..852d00c76 100644
--- a/src/webenginequick/api/qquickwebengineview.cpp
+++ b/src/webenginequick/api/qquickwebengineview.cpp
@@ -41,6 +41,7 @@
#include <QtWebEngineCore/qwebengineregisterprotocolhandlerrequest.h>
#include <QtWebEngineCore/qwebenginescriptcollection.h>
#include <QtWebEngineCore/qwebenginewebauthuxrequest.h>
+#include <QtWebEngineCore/qwebenginepermission.h>
#include <QtWebEngineCore/private/qwebenginecontextmenurequest_p.h>
#include <QtWebEngineCore/private/qwebenginedesktopmediarequest_p.h>
#include <QtWebEngineCore/private/qwebenginehistory_p.h>
@@ -48,6 +49,7 @@
#include <QtWebEngineCore/private/qwebenginescriptcollection_p.h>
#include <QtWebEngineCore/private/qwebenginepage_p.h>
#include <QtWebEngineCore/private/qtwebenginecoreglobal_p.h>
+#include <QtWebEngineCore/private/qwebenginepermission_p.h>
#include <QtCore/qloggingcategory.h>
#include <QtCore/qmimedata.h>
@@ -332,8 +334,7 @@ QQuickWebEngineViewPrivate::~QQuickWebEngineViewPrivate()
{
Q_ASSERT(m_profileInitialized);
m_profile->d_ptr->removeWebContentsAdapterClient(this);
- if (m_faviconProvider)
- m_faviconProvider->detach(q_ptr);
+ FaviconProviderHelper::instance()->detach(q_ptr);
bindViewAndDelegateItem(this, nullptr);
}
@@ -485,29 +486,67 @@ void QQuickWebEngineViewPrivate::selectClientCert(
Q_EMIT q->selectClientCertificate(certSelection);
}
-static QQuickWebEngineView::Feature toFeature(QtWebEngineCore::ProfileAdapter::PermissionType type)
+#if QT_DEPRECATED_SINCE(6, 8)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
+static QQuickWebEngineView::Feature toDeprecatedFeature(QWebEnginePermission::Feature feature)
{
- switch (type) {
- case QtWebEngineCore::ProfileAdapter::NotificationPermission:
+ switch (feature) {
+ case QWebEnginePermission::Feature::Notifications:
return QQuickWebEngineView::Notifications;
- case QtWebEngineCore::ProfileAdapter::GeolocationPermission:
+ case QWebEnginePermission::Feature::Geolocation:
return QQuickWebEngineView::Geolocation;
- case QtWebEngineCore::ProfileAdapter::ClipboardReadWrite:
+ case QWebEnginePermission::Feature::ClipboardReadWrite:
return QQuickWebEngineView::ClipboardReadWrite;
- case QtWebEngineCore::ProfileAdapter::LocalFontsPermission:
+ case QWebEnginePermission::Feature::LocalFontsAccess:
return QQuickWebEngineView::LocalFontsAccess;
- default:
+ case QWebEnginePermission::Feature::MediaAudioCapture:
+ return QQuickWebEngineView::MediaAudioCapture;
+ case QWebEnginePermission::Feature::MediaVideoCapture:
+ return QQuickWebEngineView::MediaVideoCapture;
+ case QWebEnginePermission::Feature::MediaAudioVideoCapture:
+ return QQuickWebEngineView::MediaAudioVideoCapture;
+ case QWebEnginePermission::Feature::DesktopVideoCapture:
+ return QQuickWebEngineView::DesktopVideoCapture;
+ case QWebEnginePermission::Feature::DesktopAudioVideoCapture:
+ return QQuickWebEngineView::DesktopAudioVideoCapture;
+ case QWebEnginePermission::Feature::MouseLock:
+ case QWebEnginePermission::Feature::Unsupported:
break;
}
+
Q_UNREACHABLE();
return QQuickWebEngineView::Feature(-1);
}
+QT_WARNING_POP
+#endif // QT_DEPRECATED_SINCE(6, 8)
-
-void QQuickWebEngineViewPrivate::runFeaturePermissionRequest(QtWebEngineCore::ProfileAdapter::PermissionType permission, const QUrl &url)
+void QQuickWebEngineViewPrivate::runFeaturePermissionRequest(QWebEnginePermission::Feature feature, const QUrl &url)
{
Q_Q(QQuickWebEngineView);
- Q_EMIT q->featurePermissionRequested(url, toFeature(permission));
+ switch (feature) {
+ case QWebEnginePermission::Notifications:
+ case QWebEnginePermission::Geolocation:
+ case QWebEnginePermission::ClipboardReadWrite:
+ case QWebEnginePermission::LocalFontsAccess:
+ Q_EMIT q->permissionRequested(createFeaturePermissionObject(url, feature));
+#if QT_DEPRECATED_SINCE(6, 8)
+ QT_WARNING_PUSH
+ QT_WARNING_DISABLE_DEPRECATED
+ Q_EMIT q->featurePermissionRequested(url, toDeprecatedFeature(feature));
+ QT_WARNING_POP
+#endif // QT_DEPRECATED_SINCE(6, 8)
+ return;
+ case QWebEnginePermission::MouseLock:
+ case QWebEnginePermission::MediaAudioCapture:
+ case QWebEnginePermission::MediaVideoCapture:
+ case QWebEnginePermission::MediaAudioVideoCapture:
+ case QWebEnginePermission::DesktopAudioVideoCapture:
+ case QWebEnginePermission::DesktopVideoCapture:
+ case QWebEnginePermission::Unsupported:
+ Q_UNREACHABLE();
+ return;
+ }
}
void QQuickWebEngineViewPrivate::showColorDialog(QSharedPointer<ColorChooserController> controller)
@@ -573,6 +612,12 @@ void QQuickWebEngineViewPrivate::iconChanged(const QUrl &url)
QTimer::singleShot(0, q, &QQuickWebEngineView::iconChanged);
}
+void QQuickWebEngineViewPrivate::zoomFactorChanged(qreal factor)
+{
+ Q_Q(QQuickWebEngineView);
+ Q_EMIT q->zoomFactorChanged(factor);
+}
+
void QQuickWebEngineViewPrivate::loadProgressChanged(int progress)
{
Q_Q(QQuickWebEngineView);
@@ -779,19 +824,41 @@ void QQuickWebEngineViewPrivate::runMediaAccessPermissionRequest(const QUrl &sec
Q_Q(QQuickWebEngineView);
if (!requestFlags)
return;
- QQuickWebEngineView::Feature feature;
+ QWebEnginePermission::Feature feature;
if (requestFlags.testFlag(WebContentsAdapterClient::MediaAudioCapture) && requestFlags.testFlag(WebContentsAdapterClient::MediaVideoCapture))
- feature = QQuickWebEngineView::MediaAudioVideoCapture;
+ feature = QWebEnginePermission::MediaAudioVideoCapture;
else if (requestFlags.testFlag(WebContentsAdapterClient::MediaAudioCapture))
- feature = QQuickWebEngineView::MediaAudioCapture;
+ feature = QWebEnginePermission::MediaAudioCapture;
else if (requestFlags.testFlag(WebContentsAdapterClient::MediaVideoCapture))
- feature = QQuickWebEngineView::MediaVideoCapture;
+ feature = QWebEnginePermission::MediaVideoCapture;
else if (requestFlags.testFlag(WebContentsAdapterClient::MediaDesktopAudioCapture) &&
requestFlags.testFlag(WebContentsAdapterClient::MediaDesktopVideoCapture))
- feature = QQuickWebEngineView::DesktopAudioVideoCapture;
+ feature = QWebEnginePermission::DesktopAudioVideoCapture;
else // if (requestFlags.testFlag(WebContentsAdapterClient::MediaDesktopVideoCapture))
- feature = QQuickWebEngineView::DesktopVideoCapture;
- Q_EMIT q->featurePermissionRequested(securityOrigin, feature);
+ feature = QWebEnginePermission::DesktopVideoCapture;
+ Q_EMIT q->permissionRequested(createFeaturePermissionObject(securityOrigin, feature));
+
+#if QT_DEPRECATED_SINCE(6, 8)
+ QT_WARNING_PUSH
+ QT_WARNING_DISABLE_DEPRECATED
+ QQuickWebEngineView::Feature deprecatedFeature;
+
+ if (requestFlags.testFlag(WebContentsAdapterClient::MediaAudioCapture)
+ && requestFlags.testFlag(WebContentsAdapterClient::MediaVideoCapture))
+ deprecatedFeature = QQuickWebEngineView::MediaAudioVideoCapture;
+ else if (requestFlags.testFlag(WebContentsAdapterClient::MediaAudioCapture))
+ deprecatedFeature = QQuickWebEngineView::MediaAudioCapture;
+ else if (requestFlags.testFlag(WebContentsAdapterClient::MediaVideoCapture))
+ deprecatedFeature = QQuickWebEngineView::MediaVideoCapture;
+ else if (requestFlags.testFlag(WebContentsAdapterClient::MediaDesktopAudioCapture)
+ && requestFlags.testFlag(WebContentsAdapterClient::MediaDesktopVideoCapture))
+ deprecatedFeature = QQuickWebEngineView::DesktopAudioVideoCapture;
+ else // if (requestFlags.testFlag(WebContentsAdapterClient::MediaDesktopVideoCapture))
+ deprecatedFeature = QQuickWebEngineView::DesktopVideoCapture;
+
+ Q_EMIT q->featurePermissionRequested(securityOrigin, deprecatedFeature);
+ QT_WARNING_POP
+#endif // QT_DEPRECATED_SINCE(6, 8)
}
void QQuickWebEngineViewPrivate::runMouseLockPermissionRequest(const QUrl &securityOrigin)
@@ -837,6 +904,14 @@ void QQuickWebEngineViewPrivate::printRequested()
});
}
+void QQuickWebEngineViewPrivate::printRequestedByFrame(quint64 frameId)
+{
+ Q_Q(QQuickWebEngineView);
+ QTimer::singleShot(0, q, [this, q, frameId]() {
+ Q_EMIT q->printRequestedByFrame(QWebEngineFrame(this, frameId));
+ });
+}
+
void QQuickWebEngineViewPrivate::findTextFinished(const QWebEngineFindTextResult &result)
{
Q_Q(QQuickWebEngineView);
@@ -951,16 +1026,7 @@ void QQuickWebEngineViewPrivate::ensureContentsAdapter()
adapter->loadDefault();
}
- if (!m_faviconProvider) {
- QQmlEngine *engine = qmlEngine(q_ptr);
- // TODO: this is a workaround for QTBUG-65044
- if (!engine)
- return;
- m_faviconProvider = static_cast<QQuickWebEngineFaviconProvider *>(
- engine->imageProvider(QQuickWebEngineFaviconProvider::identifier()));
- m_faviconProvider->attach(q_ptr);
- Q_ASSERT(m_faviconProvider);
- }
+ FaviconProviderHelper::instance()->attach(q_ptr);
}
void QQuickWebEngineViewPrivate::initializationFinished()
@@ -1235,7 +1301,6 @@ void QQuickWebEngineView::setZoomFactor(qreal arg)
d->adapter->setZoomFactor(arg);
// MEMO: should reset if factor was not applied due to being invalid
d->m_zoomFactor = zoomFactor();
- emit zoomFactorChanged(d->m_zoomFactor);
} else {
d->m_zoomFactor = arg;
}
@@ -1306,22 +1371,26 @@ bool QQuickWebEngineView::activeFocusOnPress() const
return d->m_activeFocusOnPress;
}
-void QQuickWebEngineViewPrivate::didRunJavaScript(quint64 requestId, const QVariant &result)
+void QQuickWebEngineViewPrivate::runJavaScript(
+ const QString &script, quint32 worldId, quint64 frameId,
+ const std::function<void(const QVariant &)> &callback)
{
- Q_Q(QQuickWebEngineView);
- QJSValue callback = m_callbacks.take(requestId);
- QJSValueList args;
- args.append(qmlEngine(q)->toScriptValue(result));
- callback.call(args);
+ ensureContentsAdapter();
+ adapter->runJavaScript(script, worldId, frameId, callback);
}
-void QQuickWebEngineViewPrivate::didPrintPage(quint64 requestId, QSharedPointer<QByteArray> result)
+void QQuickWebEngineViewPrivate::printToPdf(const QString &filePath, const QPageLayout &layout,
+ const QPageRanges &ranges, quint64 frameId)
{
- Q_Q(QQuickWebEngineView);
- QJSValue callback = m_callbacks.take(requestId);
- QJSValueList args;
- args.append(qmlEngine(q)->toScriptValue(*(result.data())));
- callback.call(args);
+ adapter->printToPDF(layout, ranges, filePath, frameId);
+}
+
+void QQuickWebEngineViewPrivate::printToPdf(
+ std::function<void(QSharedPointer<QByteArray>)> &&callback, const QPageLayout &layout,
+ const QPageRanges &ranges, quint64 frameId)
+{
+ adapter->printToPDFCallbackResult(std::move(callback), layout, ranges, /*colorMode*/ true,
+ /*useCustomMargins*/ true, frameId);
}
void QQuickWebEngineViewPrivate::didPrintPageToPdf(const QString &filePath, bool success)
@@ -1459,6 +1528,12 @@ void QQuickWebEngineViewPrivate::showWebAuthDialog(QWebEngineWebAuthUxRequest *r
Q_EMIT q->webAuthUxRequested(request);
}
+QWebEnginePermission QQuickWebEngineViewPrivate::createFeaturePermissionObject(const QUrl &securityOrigin, QWebEnginePermission::Feature feature)
+{
+ auto *returnPrivate = new QWebEnginePermissionPrivate(securityOrigin, feature, adapter, profileAdapter());
+ return QWebEnginePermission(returnPrivate);
+}
+
bool QQuickWebEngineView::isLoading() const
{
Q_D(const QQuickWebEngineView);
@@ -1497,16 +1572,15 @@ void QQuickWebEngineView::runJavaScript(const QString &script, const QJSValue &c
void QQuickWebEngineView::runJavaScript(const QString &script, quint32 worldId, const QJSValue &callback)
{
Q_D(QQuickWebEngineView);
- d->ensureContentsAdapter();
+ std::function<void(const QVariant &)> wrappedCallback;
if (!callback.isUndefined()) {
- quint64 requestId = d_ptr->adapter->runJavaScriptCallbackResult(script, worldId);
- if (requestId) {
- d->m_callbacks.insert(requestId, callback);
- } else {
- callback.call();
- }
- } else
- d->adapter->runJavaScript(script, worldId);
+ wrappedCallback = [this, callback](const QVariant &result) {
+ QJSValueList args;
+ args.append(qmlEngine(this)->toScriptValue(result));
+ callback.call(args);
+ };
+ }
+ d->runJavaScript(script, worldId, WebContentsAdapter::kUseMainFrameId, wrappedCallback);
}
qreal QQuickWebEngineView::zoomFactor() const
@@ -1581,7 +1655,7 @@ void QQuickWebEngineView::printToPdf(const QString& filePath, PrintedPageSizeId
QPageLayout pageLayout(layoutSize, layoutOrientation, QMarginsF(0.0, 0.0, 0.0, 0.0));
QPageRanges ranges;
d->ensureContentsAdapter();
- d->adapter->printToPDF(pageLayout, ranges, filePath);
+ d->printToPdf(filePath, pageLayout, ranges, WebContentsAdapter::kUseMainFrameId);
#else
Q_UNUSED(filePath);
Q_UNUSED(pageSizeId);
@@ -1602,8 +1676,14 @@ void QQuickWebEngineView::printToPdf(const QJSValue &callback, PrintedPageSizeId
return;
d->ensureContentsAdapter();
- quint64 requestId = d->adapter->printToPDFCallbackResult(pageLayout, ranges);
- d->m_callbacks.insert(requestId, callback);
+ std::function wrappedCallback = [this, callback](QSharedPointer<QByteArray> result) {
+ QJSValueList args;
+ args.append(qmlEngine(this)->toScriptValue(*result));
+ callback.call(args);
+ };
+
+ d->printToPdf(std::move(wrappedCallback), pageLayout, ranges,
+ WebContentsAdapter::kUseMainFrameId);
#else
Q_UNUSED(pageSizeId);
Q_UNUSED(orientation);
@@ -1749,55 +1829,49 @@ void QQuickWebEngineView::setDevToolsView(QQuickWebEngineView *devToolsView)
Q_EMIT devToolsViewChanged();
}
+#if QT_DEPRECATED_SINCE(6, 8)
+QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED
void QQuickWebEngineView::grantFeaturePermission(const QUrl &securityOrigin, QQuickWebEngineView::Feature feature, bool granted)
{
- if (!granted && ((feature >= MediaAudioCapture && feature <= MediaAudioVideoCapture) ||
- (feature >= DesktopVideoCapture && feature <= DesktopAudioVideoCapture))) {
- d_ptr->adapter->grantMediaAccessPermission(securityOrigin, WebContentsAdapterClient::MediaNone);
- return;
- }
+ Q_D(QQuickWebEngineView);
+ QWebEnginePermission::Feature f;
switch (feature) {
- case MediaAudioCapture:
- d_ptr->adapter->grantMediaAccessPermission(securityOrigin, WebContentsAdapterClient::MediaAudioCapture);
+ case QQuickWebEngineView::Notifications:
+ f = QWebEnginePermission::Notifications;
break;
- case MediaVideoCapture:
- d_ptr->adapter->grantMediaAccessPermission(securityOrigin, WebContentsAdapterClient::MediaVideoCapture);
+ case QQuickWebEngineView::Geolocation:
+ f = QWebEnginePermission::Geolocation;
break;
- case MediaAudioVideoCapture:
- d_ptr->adapter->grantMediaAccessPermission(securityOrigin, WebContentsAdapterClient::MediaRequestFlags(WebContentsAdapterClient::MediaAudioCapture | WebContentsAdapterClient::MediaVideoCapture));
+ case QQuickWebEngineView::MediaAudioCapture:
+ f = QWebEnginePermission::MediaAudioCapture;
break;
- case DesktopVideoCapture:
- d_ptr->adapter->grantMediaAccessPermission(securityOrigin, WebContentsAdapterClient::MediaDesktopVideoCapture);
+ case QQuickWebEngineView::MediaVideoCapture:
+ f = QWebEnginePermission::MediaVideoCapture;
break;
- case DesktopAudioVideoCapture:
- d_ptr->adapter->grantMediaAccessPermission(
- securityOrigin,
- WebContentsAdapterClient::MediaRequestFlags(
- WebContentsAdapterClient::MediaDesktopAudioCapture |
- WebContentsAdapterClient::MediaDesktopVideoCapture));
+ case QQuickWebEngineView::MediaAudioVideoCapture:
+ f = QWebEnginePermission::MediaAudioVideoCapture;
break;
- case Geolocation:
- d_ptr->adapter->grantFeaturePermission(securityOrigin, ProfileAdapter::GeolocationPermission,
- granted ? ProfileAdapter::AllowedPermission : ProfileAdapter::DeniedPermission);
+ case QQuickWebEngineView::DesktopVideoCapture:
+ f = QWebEnginePermission::DesktopVideoCapture;
break;
- case Notifications:
- d_ptr->adapter->grantFeaturePermission(securityOrigin, ProfileAdapter::NotificationPermission,
- granted ? ProfileAdapter::AllowedPermission : ProfileAdapter::DeniedPermission);
+ case QQuickWebEngineView::DesktopAudioVideoCapture:
+ f = QWebEnginePermission::DesktopAudioVideoCapture;
break;
- case ClipboardReadWrite:
- d_ptr->adapter->grantFeaturePermission(securityOrigin, ProfileAdapter::ClipboardReadWrite,
- granted ? ProfileAdapter::AllowedPermission
- : ProfileAdapter::DeniedPermission);
+ case QQuickWebEngineView::ClipboardReadWrite:
+ f = QWebEnginePermission::ClipboardReadWrite;
break;
- case LocalFontsAccess:
- d_ptr->adapter->grantFeaturePermission(securityOrigin, ProfileAdapter::LocalFontsPermission,
- granted ? ProfileAdapter::AllowedPermission : ProfileAdapter::DeniedPermission);
+ case QQuickWebEngineView::LocalFontsAccess:
+ f = QWebEnginePermission::LocalFontsAccess;
break;
default:
Q_UNREACHABLE();
}
+
+ d->adapter->setFeaturePermission(securityOrigin, f, granted ? QWebEnginePermission::Granted : QWebEnginePermission::Denied);
}
+QT_WARNING_POP
+#endif // QT_DEPRECATED_SINCE(6, 8)
void QQuickWebEngineView::setActiveFocusOnPress(bool arg)
{
@@ -2529,6 +2603,19 @@ QQmlComponent *QQuickWebEngineView::touchHandleDelegate() const
return d_ptr->m_touchHandleDelegate;
}
+QWebEngineFrame QQuickWebEngineView::mainFrame()
+{
+ Q_D(QQuickWebEngineView);
+ return QWebEngineFrame(d, d->adapter->mainFrameId());
+}
+
+QWebEngineFrame QQuickWebEngineView::findFrameByName(const QString &name)
+{
+ Q_D(QQuickWebEngineView);
+ auto maybeId = d->adapter->findFrameIdByName(name);
+ return QWebEngineFrame(d, maybeId.value_or(WebContentsAdapter::kInvalidFrameId));
+}
+
void QQuickWebEngineView::save(const QString &filePath,
QWebEngineDownloadRequest::SavePageFormat format) const
{
diff --git a/src/webenginequick/api/qquickwebengineview_p.h b/src/webenginequick/api/qquickwebengineview_p.h
index 0fdd9f787..ea09dff9f 100644
--- a/src/webenginequick/api/qquickwebengineview_p.h
+++ b/src/webenginequick/api/qquickwebengineview_p.h
@@ -19,6 +19,8 @@
#include <QtWebEngineCore/qwebenginequotarequest.h>
#include <QtWebEngineCore/qwebenginedesktopmediarequest.h>
#include <QtWebEngineCore/qwebenginedownloadrequest.h>
+#include <QtWebEngineCore/qwebengineframe.h>
+#include <QtWebEngineCore/qwebenginepermission.h>
#include <QtWebEngineQuick/private/qtwebenginequickglobal_p.h>
#include <QtGui/qcolor.h>
#include <QtQml/qqmlregistration.h>
@@ -91,6 +93,7 @@ class Q_WEBENGINEQUICK_EXPORT QQuickWebEngineView : public QQuickItem {
Q_PROPERTY(qint64 renderProcessPid READ renderProcessPid NOTIFY renderProcessPidChanged FINAL REVISION(1,11))
Q_PROPERTY(QQmlComponent *touchHandleDelegate READ touchHandleDelegate WRITE
setTouchHandleDelegate NOTIFY touchHandleDelegateChanged REVISION(0) FINAL)
+ Q_PROPERTY(QWebEngineFrame mainFrame READ mainFrame FINAL REVISION(6, 8))
QML_NAMED_ELEMENT(WebEngineView)
QML_ADDED_IN_VERSION(1, 0)
QML_EXTRA_VERSION(2, 0)
@@ -164,8 +167,12 @@ QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED
Q_ENUM(NewViewDestination)
QT_WARNING_POP
#endif
-
- enum Feature {
+#if QT_DEPRECATED_SINCE(6, 8)
+QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED
+ enum QT_DEPRECATED_VERSION_X_6_8(
+ "WebEnginePage::Feature has been deprecated. "
+ "The updated permissions API uses WebEnginePermission::Feature.")
+ Feature {
MediaAudioCapture,
MediaVideoCapture,
MediaAudioVideoCapture,
@@ -177,6 +184,8 @@ QT_WARNING_POP
LocalFontsAccess,
};
Q_ENUM(Feature)
+QT_WARNING_POP
+#endif
enum WebAction {
NoWebAction = - 1,
@@ -472,6 +481,9 @@ QT_WARNING_POP
QQmlComponent *touchHandleDelegate() const;
void setTouchHandleDelegate(QQmlComponent *delegagte);
+ QWebEngineFrame mainFrame();
+ Q_REVISION(6, 8) Q_INVOKABLE QWebEngineFrame findFrameByName(const QString &name);
+
public Q_SLOTS:
void runJavaScript(const QString&, const QJSValue & = QJSValue());
Q_REVISION(1,3) void runJavaScript(const QString&, quint32 worldId, const QJSValue & = QJSValue());
@@ -484,7 +496,17 @@ public Q_SLOTS:
void stop();
Q_REVISION(1,1) void findText(const QString &subString, FindFlags options = { }, const QJSValue &callback = QJSValue());
Q_REVISION(1,1) void fullScreenCancelled();
+#if QT_DEPRECATED_SINCE(6, 8)
+#if !defined(Q_MOC_RUN)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
+#endif // !defined(Q_MOC_RUN)
+ QT_DEPRECATED_VERSION_X_6_8("Setting permissions through WebEngineView has been deprecated. Please use WebEnginePermission instead.")
Q_REVISION(1,1) void grantFeaturePermission(const QUrl &securityOrigin, QQuickWebEngineView::Feature, bool granted);
+#if !defined(Q_MOC_RUN)
+QT_WARNING_POP
+#endif // !defined(Q_MOC_RUN)
+#endif // QT_DEPRECATED_SINCE(6, 8)
Q_REVISION(1,2) void setActiveFocusOnPress(bool arg);
Q_REVISION(1,2) void triggerWebAction(WebAction action);
Q_REVISION(1,3) void printToPdf(const QString &filePath, PrintedPageSizeId pageSizeId = PrintedPageSizeId::A4, PrintedPageOrientation orientation = PrintedPageOrientation::Portrait);
@@ -510,9 +532,19 @@ Q_SIGNALS:
Q_REVISION(1,1) void certificateError(const QWebEngineCertificateError &error);
Q_REVISION(1,1) void fullScreenRequested(const QWebEngineFullScreenRequest &request);
Q_REVISION(1,1) void isFullScreenChanged();
+#if QT_DEPRECATED_SINCE(6, 8)
+#if !defined(Q_MOC_RUN)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
+#endif // !defined(Q_MOC_RUN)
+ QT_MOC_COMPAT QT_DEPRECATED_VERSION_X_6_8("The signal has been deprecated; please use permissionRequested instead.")
Q_REVISION(1, 1)
void featurePermissionRequested(const QUrl &securityOrigin,
QQuickWebEngineView::Feature feature);
+#if !defined(Q_MOC_RUN)
+QT_WARNING_POP
+#endif // !defined(Q_MOC_RUN)
+#endif // QT_DEPRECATED_SINCE(6, 8)
Q_REVISION(1,1) void zoomFactorChanged(qreal arg);
Q_REVISION(1,1) void profileChanged();
Q_REVISION(1,1) void webChannelChanged();
@@ -556,6 +588,8 @@ Q_SIGNALS:
Q_REVISION(6,4) void fileSystemAccessRequested(const QWebEngineFileSystemAccessRequest &request);
Q_REVISION(6, 7) void webAuthUxRequested(QWebEngineWebAuthUxRequest *request);
Q_REVISION(6,7) void desktopMediaRequested(const QWebEngineDesktopMediaRequest &request);
+ Q_REVISION(6, 8) void printRequestedByFrame(QWebEngineFrame frame);
+ Q_REVISION(6,8) void permissionRequested(QWebEnginePermission permissionRequest);
protected:
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
@@ -572,8 +606,8 @@ private:
QScopedPointer<QQuickWebEngineViewPrivate> d_ptr;
friend class QQuickContextMenuBuilder;
- friend class FaviconImageResponse;
- friend class FaviconImageResponseRunnable;
+ friend class FaviconProviderHelper;
+ friend class FaviconImageRequester;
#if QT_CONFIG(accessibility)
friend class QQuickWebEngineViewAccessible;
#endif // QT_CONFIG(accessibility)
diff --git a/src/webenginequick/api/qquickwebengineview_p_p.h b/src/webenginequick/api/qquickwebengineview_p_p.h
index 58236bc58..e61f32bcb 100644
--- a/src/webenginequick/api/qquickwebengineview_p_p.h
+++ b/src/webenginequick/api/qquickwebengineview_p_p.h
@@ -37,7 +37,6 @@ class WebContentsAdapter;
QT_BEGIN_NAMESPACE
class QQmlComponent;
-class QQuickWebEngineFaviconProvider;
class QQuickWebEngineScriptCollection;
class QQuickWebEngineSettings;
class QQuickWebEngineView;
@@ -65,6 +64,7 @@ public:
void titleChanged(const QString&) override;
void urlChanged() override;
void iconChanged(const QUrl&) override;
+ void zoomFactorChanged(qreal factor) override;
void loadProgressChanged(int progress) override;
void didUpdateTargetURL(const QUrl&) override;
void selectionChanged() override;
@@ -93,10 +93,14 @@ public:
void runFileChooser(QSharedPointer<QtWebEngineCore::FilePickerController>) override;
void desktopMediaRequested(QtWebEngineCore::DesktopMediaController *) override;
void showColorDialog(QSharedPointer<QtWebEngineCore::ColorChooserController>) override;
- void didRunJavaScript(quint64, const QVariant&) override;
+ void runJavaScript(const QString &script, quint32 worldId, quint64 frameId,
+ const std::function<void(const QVariant &)> &callback) override;
void didFetchDocumentMarkup(quint64, const QString&) override { }
void didFetchDocumentInnerText(quint64, const QString&) override { }
- void didPrintPage(quint64 requestId, QSharedPointer<QByteArray>) override;
+ void printToPdf(const QString &filePath, const QPageLayout &layout, const QPageRanges &ranges,
+ quint64 frameId) override;
+ void printToPdf(std::function<void(QSharedPointer<QByteArray>)> &&callback,
+ const QPageLayout &layout, const QPageRanges &ranges, quint64 frameId) override;
void didPrintPageToPdf(const QString &filePath, bool success) override;
bool passOnFocus(bool reverse) override;
void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID) override;
@@ -110,7 +114,7 @@ public:
void allowCertificateError(const QWebEngineCertificateError &error) override;
void selectClientCert(const QSharedPointer<QtWebEngineCore::ClientCertSelectController>
&selectController) override;
- void runFeaturePermissionRequest(QtWebEngineCore::ProfileAdapter::PermissionType permission, const QUrl &securityOrigin) override;
+ void runFeaturePermissionRequest(QWebEnginePermission::Feature feature, const QUrl &securityOrigin) override;
void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, int exitCode) override;
void requestGeometryChange(const QRect &geometry, const QRect &frameGeometry) override;
void updateScrollPosition(const QPointF &position) override;
@@ -129,11 +133,13 @@ public:
QtWebEngineCore::ProfileAdapter *profileAdapter() override;
QtWebEngineCore::WebContentsAdapter *webContentsAdapter() override;
void printRequested() override;
+ void printRequestedByFrame(quint64 frameId) override;
void findTextFinished(const QWebEngineFindTextResult &result) override;
void showAutofillPopup(QtWebEngineCore::AutofillPopupController *controller,
const QRect &bounds, bool autoselectFirstSuggestion) override;
void hideAutofillPopup() override;
void showWebAuthDialog(QWebEngineWebAuthUxRequest *request) override;
+ QWebEnginePermission createFeaturePermissionObject(const QUrl &securityOrigin, QWebEnginePermission::Feature feature) override;
void updateAction(QQuickWebEngineView::WebAction) const;
bool adoptWebContents(QtWebEngineCore::WebContentsAdapter *webContents);
@@ -158,7 +164,6 @@ public:
bool m_fullscreenMode;
bool isLoading;
bool m_activeFocusOnPress;
- QMap<quint64, QJSValue> m_callbacks;
QQmlWebChannel *m_webChannel;
QPointer<QQuickWebEngineView> inspectedView;
QPointer<QQuickWebEngineView> devToolsView;
@@ -178,7 +183,6 @@ private:
bool m_profileInitialized;
QWebEngineContextMenuRequest *m_contextMenuRequest;
QScopedPointer<QQuickWebEngineScriptCollection> m_scriptCollection;
- QPointer<QQuickWebEngineFaviconProvider> m_faviconProvider;
QQmlComponent *m_touchHandleDelegate;
};
diff --git a/src/webenginequick/doc/src/webengine_permission.qdoc b/src/webenginequick/doc/src/webengine_permission.qdoc
new file mode 100644
index 000000000..f59f57fa0
--- /dev/null
+++ b/src/webenginequick/doc/src/webengine_permission.qdoc
@@ -0,0 +1,137 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \qmltype webEnginePermission
+ \instantiates QWebEnginePermission
+ \inqmlmodule QtWebEngine
+ \brief An object used to access and modify the state of a single permission that's been
+ granted or denied to a specific origin URL.
+
+ The typical usage pattern is as follows:
+ \list 1
+ \li A website requests a specific feature, triggering the WebEngineView::permissionRequested signal;
+ \li The signal handler triggers a prompt asking the user whether they want to grant the permission;
+ \li When the user has made their decision, the application calls \l grant() or \l deny();
+ \endlist
+
+ Alternatively, an application interested in modifying already granted permissions may use WebEngineProfile::listPermissions()
+ to get a list of existing permissions associated with a profile, or WebEngineProfile::getPermission() to get
+ a webEnginePermission object for a specific permission.
+
+ The \l origin property can be used to query which origin the webEnginePermission is associated with, while the
+ \l feature property describes the associated feature. A website origin is the combination of its scheme, hostname,
+ and port. Permissions are granted on a per-origin basis; thus, if the web page \c{https://www.example.com:12345/some/page.html}
+ requests a permission, it will be granted to the origin \c{https://www.example.com:12345/}.
+
+ The usability lifetime of a webEnginePermission is tied either to its associated WebEngineView
+ (for transient feature types), or WebEngineProfile (for permanent feature types). A transient permission is one which
+ needs to be explicitly granted or denied every time it's needed (e.g. webcam/screen sharing permission), whereas a permanent
+ one might be stored inside the current profile, depending on the value of WebEngineProfile::persistentPermissionsPolicy.
+ You can check whether a webEnginePermission is in a valid state using its \l isValid() property. For invalid objects, calls to \l grant(),
+ \l deny(), or \l reset() will do nothing, and their \l state() will always be WebEnginePermission.Invalid.
+
+ The feature types Qt WebEngine supports are described in \l feature.
+
+ \sa WebEngineView::permissionRequested, WebEngineProfile::getPermission(),
+ WebEngineProfile::listPermissions()
+*/
+
+/*!
+ \qmlproperty url webEnginePermission::origin
+ \brief The URL of the permission's associated origin.
+
+ A website origin is the combination of its scheme, hostname, and port. Permissions are granted on a
+ per-origin basis; thus, if the web page \c{https://www.example.com:12345/some/page.html}
+ requests a permission, it will be granted to the origin \c{https://www.example.com:12345/}.
+*/
+
+/*!
+ \qmlproperty enumeration webEnginePermission::feature
+ \brief The feature type associated with this permission.
+
+ \value WebEnginePermission.MediaAudioCapture Access to a microphone, or another audio source. This feature is transient.
+ \value WebEnginePermission.MediaVideoCapture Access to a webcam, or another video source. This feature is transient.
+ \value WebEnginePermission.MediaAudioVideoCapture Combination of \l MediaAudioCapture and \l MediaVideoCapture. This feature is transient.
+ \value WebEnginePermission.DesktopVideoCapture Access to the contents of the user's screen. This feature is transient.
+ \value WebEnginePermission.DesktopAudioVideoCapture Access to the contents of the user's screen, and application audio. This feature is transient.
+ \value WebEnginePermission.MouseLock Locks the pointer inside an element on the web page. This feature is transient.
+ \value WebEnginePermission.Notifications Allows the website to send notifications to the user.
+ \value WebEnginePermission.Geolocation Access to the user's physical location.
+ \value WebEnginePermission.ClipboardReadWrite Access to the user's clipboard.
+ \value WebEnginePermission.LocalFontsAccess Access to the fonts installed on the user's machine. Only available on desktops.
+ \value WebEnginePermission.Unsupported An unsupported feature type.
+
+ \note Transient feature types are ones that will never be remembered by the underlying storage, and will trigger
+ a permission request every time a website tries to use them.
+*/
+
+/*!
+ \qmlproperty enumeration webEnginePermission::state
+ \brief The current state of the permission.
+
+ \value WebEnginePermission.Invalid Object is in an invalid state, and any attempts to modify the described permission will fail.
+ \value WebEnginePermission.Ask Either the permission has not been requested before, or the feature() is transient.
+ \value WebEnginePermission.Granted Permission has already been granted.
+ \value WebEnginePermission.Denied Permission has already been denied.
+
+ If a permission for the specified \l feature and \l origin has already been granted or denied,
+ the return value is WebEnginePermission.Granted, or WebEnginePermission.Denied, respectively.
+ When this is the first time the permission is requested, or if the \l feature is transient,
+ the return value is WebEnginePermission.Ask. If the object is in an invalid state, the returned
+ value is WebEnginePermission.Invalid.
+
+ \sa isValid, isTransient
+*/
+
+/*!
+ \qmlproperty bool webEnginePermission::isValid
+ \brief Indicates whether attempts to change the permission's state will be successful.
+
+ An invalid webEnginePermission is either:
+ \list
+ \li One whose \l feature is unsupported;
+ \li One whose \l feature is transient, and the associated page/view has been destroyed;
+ \li One whose \l feature is permanent, but the associated profile has been destroyed;
+ \li One whose \l origin is invalid.
+ \endlist
+
+ \sa isTransient
+*/
+
+/*!
+ \qmlmethod void webEnginePermission::grant()
+
+ Allows the associated origin to access the requested feature. Does nothing when \l isValid evaluates to false.
+
+ \sa deny, reset, isValid
+*/
+
+/*!
+ \qmlmethod void webEnginePermission::deny()
+
+ Stops the associated origin from accessing the requested feature. Does nothing when \l isValid evaluates to false.
+
+ \sa grant, reset, isValid
+*/
+
+/*!
+ \qmlmethod void webEnginePermission::reset()
+
+ Removes the permission from the profile's underlying storage. By default, permissions are stored on disk (except for
+ off-the-record profiles, where permissions are stored in memory and are destroyed with the profile).
+ This means that an already granted/denied permission will not be requested twice, but will get automatically
+ granted/denied every subsequent time a website requests it. Calling reset() allows the query to be asked
+ again the next time the website requests it.
+
+ Does nothing when \l isValid evaluates to false.
+
+ \sa grant, deny, isValid, WebEngineProfile::persistentPermissionsPolicy
+*/
+
+/*!
+ \qmlmethod void webEnginePermission::isTransient(WebEnginePermission.Feature feature)
+
+ Returns whether \a feature is transient, meaning that a permission will be requested
+ every time the associated functionality is used by a web page.
+*/
diff --git a/src/webenginequick/doc/src/webengineframe.qdoc b/src/webenginequick/doc/src/webengineframe.qdoc
new file mode 100644
index 000000000..8f852501e
--- /dev/null
+++ b/src/webenginequick/doc/src/webengineframe.qdoc
@@ -0,0 +1,129 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \qmltype webEngineFrame
+ \instantiates QQuickWebEngineFrame
+ \brief webEngineFrame provides information about and control over a page frame.
+ \since 6.8
+ \ingroup qmlvaluetypes
+ \inqmlmodule QtWebEngine
+
+ A web engine frame represents a single frame within a web page, such as those created by
+ \c <frame> or \c <iframe> HTML elements.
+ An active \l WebEngineView has one or more frames arranged in a tree structure. The top-level
+ frame, the root of this tree, can be accessed through the view's \l {WebEngineView::mainFrame}
+ {mainFrame} property.
+
+ A frame's lifetime is, at most, as long as the \l WebEngineView object that produced it.
+ However, frames may be created and deleted spontaneously and dynamically, for example through
+ navigation and script execution.
+*/
+
+/*!
+ \qmlproperty bool webEngineFrame::isValid
+
+ Returns \c{true} if this object represents an existing frame; \c{false} otherwise.
+
+ Once a frame is invalid, it never becomes valid again.
+*/
+
+/*!
+ \qmlproperty string webEngineFrame::name
+
+ Returns the frame name; that is, what would be returned by \c window.name in JavaScript.
+
+ If the frame could not be found, returns an empty string.
+
+ \sa htmlName
+*/
+
+/*!
+ \qmlproperty string webEngineFrame::htmlName
+
+ Returns the value of the frame's \c name HTML attribute, or an empty string if it has none.
+
+ If the frame could not be found, returns an empty string.
+
+ \sa name
+*/
+
+/*!
+ \qmlproperty url webEngineFrame::url
+
+ Returns the URL of the content currently loaded in this frame.
+
+ If the frame could not be found, returns an empty URL.
+*/
+
+/*!
+ \qmlproperty size webEngineFrame::size
+
+ Returns the size of the frame within the viewport.
+
+ If the frame could not be found, returns a default size with dimensions (-1, -1).
+*/
+
+/*!
+ \qmlproperty bool webEngineFrame::isMainFrame
+
+ Returns \c{true} if this object represents the page's main frame; \c{false} otherwise.
+*/
+
+/*!
+ \qmlmethod void webEngineFrame::runJavaScript(string script, variant callback)
+ \qmlmethod void webEngineFrame::runJavaScript(string script, uint worldId, variant callback)
+
+ Runs the JavaScript code contained in \a script on this frame, without checking
+ whether the DOM of the page has been constructed.
+
+ To avoid conflicts with other scripts executed on the page, the world in
+ which the script is run is specified by \a worldId. The world ID values are
+ the same as provided by QWebEngineScript::ScriptWorldId, and between \c 0
+ and \c 256. If you leave out the \c world ID, the script is run in the
+ \c MainWorld.
+
+ The \a callback parameter is optional. If a callback function is provided, it will be
+ invoked after the script finishes running.
+ \code
+ frame.runJavaScript("document.title", function(result) { console.log(result); });
+ \endcode
+
+ Only plain data can be returned from JavaScript as the result value.
+ Supported data types include all of the JSON data types as well as, for
+ example, \c{Date} and \c{ArrayBuffer}. Unsupported data types include, for
+ example, \c{Function} and \c{Promise}.
+
+ The script will run in the same \e world as other scripts that are
+ part of the loaded site.
+
+ \warning Do not execute lengthy routines in the callback function, because it might block the
+ rendering of the web content.
+
+ For more information about injecting scripts, see \l {Script Injection}.
+ For an alternative way to inject scripts, see WebEngineView::userScripts.
+*/
+
+/*!
+ \qmlmethod void webEngineFrame::printToPdf(string filePath)
+
+ Prints the frame's current content to a PDF document and stores it
+ under \a filePath. The resulting document will have A4 page size and
+ portrait orientation.
+
+ This method issues an asynchronous request for printing the web page into a
+ PDF and returns immediately. To be informed about the result of the
+ request, connect to the signal \l WebEngineView::pdfPrintingFinished().
+
+ \sa WebEngineView::pdfPrintingFinished()
+*/
+
+/*!
+ \qmlmethod void webEngineFrame::printToPdf(variant callback)
+
+ Prints the frame's current content to a PDF document and returns it in a byte array. The
+ resulting document will have A4 page size and portrait orientation.
+
+ The \a callback must take a string parameter. This string will contain the document's data upon
+ successful printing and an empty string otherwise.
+*/
diff --git a/src/webenginequick/doc/src/webengineview_lgpl.qdoc b/src/webenginequick/doc/src/webengineview_lgpl.qdoc
index eeae34dcc..f7b17fa7b 100644
--- a/src/webenginequick/doc/src/webengineview_lgpl.qdoc
+++ b/src/webenginequick/doc/src/webengineview_lgpl.qdoc
@@ -111,10 +111,9 @@
\section2 Platform Features
Web pages can request access to platform features, such as geolocation or audio and video
- capture devices. The \l featurePermissionRequested() signal is emitted when a web page requests
- to make use of a resource. The supported platform features are described by the \l Feature
- property. If users grant the permission, the \l grantFeaturePermission() method is used to set
- it to \e granted.
+ capture devices. The \l permissionRequested() signal is emitted when a web page requests
+ to make use of a resource. The supported platform features are described by the QWebEnginePermission::Feature
+ property.
\section2 Rendering to OpenGL Surface
@@ -367,6 +366,8 @@
/*!
\qmlmethod void WebEngineView::runJavaScript(string script, variant callback)
+ \qmlmethod void WebEngineView::runJavaScript(string script, int worldId, variant callback)
+
Runs the specified \a script in the content of the web view.
The \a callback parameter is optional. If a callback function is provided,
@@ -381,8 +382,10 @@
example, \c{Date} and \c{ArrayBuffer}. Unsupported data types include, for
example, \c{Function} and \c{Promise}.
- The script will run in the same \e world as other scripts that are
- part of the loaded site.
+ To avoid conflicts with other scripts executed on the page, the world in
+ which the script is run can be specified by \a worldId. The world ID must be
+ between \c 0 and \c 256. If you leave out the \c world ID, the script is
+ run in the \c MainWorld.
\warning Do not execute lengthy routines in the callback function, because it might block the
rendering of the web content.
@@ -441,6 +444,7 @@
/*!
\qmlmethod void WebEngineView::grantFeaturePermission(url securityOrigin, Feature feature, bool granted)
\since QtWebEngine 1.1
+ \deprecated [6.8] Use webEnginePermission.grant() or webEnginePermission.deny() instead.
Sets or unsets the permission, depending on \a granted, for the web site
identified by \a securityOrigin to use \a feature.
@@ -497,6 +501,7 @@
/*!
\qmlsignal WebEngineView::featurePermissionRequested(url securityOrigin, Feature feature)
\since QtWebEngine 1.1
+ \deprecated [6.8] Use \l permissionRequested() instead.
This signal is emitted when the web site identified by \a securityOrigin requests
to make use of the resource or device identified by \a feature.
@@ -505,6 +510,15 @@
*/
/*!
+ \qmlsignal WebEngineView::permissionRequested(webEnginePermission permission)
+ \since QtWebEngine 6.8
+
+ This signal is emitted when a web site requests to make use of a feature (e.g. geolocation access,
+ permission to send notifications). The \a permission object can queried for the requesting URL
+ and the \c{WebEnginePermission.Feature} it's asking for, as well as to grant or deny permission.
+*/
+
+/*!
\qmlsignal WebEngineView::loadingChanged(WebEngineLoadingInfo loadingInfo)
This signal is emitted when a page load begins, ends, or fails.
@@ -840,6 +854,7 @@
/*!
\qmlproperty enumeration WebEngineView::Feature
+ \deprecated [6.8] Replaced by WebEnginePermission.Feature.
Describes the platform feature access categories that the user may be asked to grant or deny
access to:
@@ -1343,14 +1358,27 @@
\qmlsignal WebEngineView::printRequested
\since QtWebEngine 1.8
- This signal is emitted when the JavaScript \c{window.print()} method is called or the user pressed the print
- button of PDF viewer plugin.
+ This signal is emitted when the JavaScript \c{window.print()} method is called on the main
+ frame, or the user pressed the print button of PDF viewer plugin.
Typically, the signal handler can simply call printToPdf().
+ Since QtWebEngine 6.8, this signal is only emitted for the main frame, instead of being emitted
+ for any frame that requests printing.
+
\sa printToPdf
*/
/*!
+ \qmlsignal WebEngineView::printRequestedByFrame(webEngineFrame frame)
+ \since QtWebEngine 6.8
+
+ This signal is emitted when the JavaScript \c{window.print()} method is called on \a frame.
+ If the frame is the main frame, \c{printRequested} is emitted instead.
+
+ \sa printRequested
+*/
+
+/*!
\qmlsignal WebEngineView::selectClientCertificate(WebEngineClientCertificateSelection clientCertificateSelection)
\since QtWebEngine 1.9
@@ -1551,6 +1579,23 @@
*/
/*!
+ \qmlproperty webEngineFrame WebEngineView::mainFrame
+ \since QtWebEngine 6.8
+
+ The main, top-level frame of the page. All other frames on this page are accessible
+ as children of the main frame.
+ */
+
+/*!
+ \qmlmethod webEngineFrame WebEngineView::findFrameByName(string name)
+ \since QtWebEngine 6.8
+
+ Returns the frame with the given \a name. If there are multiple frames with the same
+ name, which one is returned is arbitrary. If no frame was found, returns an
+ \l{webEngineFrame::isValid}{invalid} frame.
+*/
+
+/*!
\qmlmethod void WebEngineView::save(const QString &filePath, QWebEngineDownloadRequest::SavePageFormat format)
\since QtWebEngine 6.6
@@ -1581,5 +1626,14 @@
\sa QWebEngineWebAuthUxRequest
*/
+/*!
+ \qmlsignal WebEngineView::zoomFactorChanged(qreal factor);
+ \since QtWebEngine 6.8
+
+ This signal is emitted whenever the zoom \a factor for the page changes.
+
+ \sa zoomFactor
+*/
+
\sa {WebEngine Qt Quick Custom Touch Handle Example}
*/