summaryrefslogtreecommitdiffstats
path: root/src/webenginewidgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/webenginewidgets')
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp37
-rw-r--r--src/webenginewidgets/api/qwebenginepage.h3
-rw-r--r--src/webenginewidgets/api/qwebenginepage_p.h2
-rw-r--r--src/webenginewidgets/api/qwebengineprofile.cpp76
-rw-r--r--src/webenginewidgets/api/qwebengineprofile.h7
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp38
6 files changed, 105 insertions, 58 deletions
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index 45519bfd0..6a70203be 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -241,6 +241,7 @@ QWebEnginePagePrivate::QWebEnginePagePrivate(QWebEngineProfile *_profile)
, webChannelWorldId(QWebEngineScript::MainWorld)
, defaultAudioMuted(false)
, defaultZoomFactor(1.0)
+ , requestInterceptor(nullptr)
#if QT_CONFIG(webengine_printing_and_pdf)
, currentPrinter(nullptr)
#endif
@@ -260,6 +261,8 @@ QWebEnginePagePrivate::QWebEnginePagePrivate(QWebEngineProfile *_profile)
QWebEnginePagePrivate::~QWebEnginePagePrivate()
{
+ if (requestInterceptor)
+ profile->d_ptr->profileAdapter()->removePageRequestInterceptor();
delete history;
delete settings;
}
@@ -1850,6 +1853,40 @@ void QWebEnginePagePrivate::printRequested()
});
}
+/*!
+ \since 5.13
+
+ Registers the request interceptor \a interceptor to intercept URL requests.
+
+ The page does not take ownership of the pointer. This interceptor is called
+ after any interceptors on the profile, and unlike profile interceptors, is run
+ on the UI thread, making it thread-safer. Only URL requests from this page are
+ intercepted.
+
+ To unset the request interceptor, set a \c nullptr.
+
+ \sa QWebEngineUrlRequestInfo, QWebEngineProfile::setRequestInterceptor()
+*/
+
+void QWebEnginePage::setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor)
+{
+ Q_D(QWebEnginePage);
+ bool hadInterceptorChanged = bool(d->requestInterceptor) != bool(interceptor);
+ d->requestInterceptor = interceptor;
+ if (hadInterceptorChanged) {
+ if (interceptor)
+ d->profile->d_ptr->profileAdapter()->addPageRequestInterceptor();
+ else
+ d->profile->d_ptr->profileAdapter()->removePageRequestInterceptor();
+ }
+}
+
+void QWebEnginePagePrivate::interceptRequest(QWebEngineUrlRequestInfo &info)
+{
+ if (requestInterceptor)
+ requestInterceptor->interceptRequest(info);
+}
+
#if QT_CONFIG(menu)
QMenu *QWebEnginePage::createStandardContextMenu()
{
diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h
index 69e0ce4a3..4fd195074 100644
--- a/src/webenginewidgets/api/qwebenginepage.h
+++ b/src/webenginewidgets/api/qwebenginepage.h
@@ -71,6 +71,7 @@ class QWebEngineQuotaRequest;
class QWebEngineRegisterProtocolHandlerRequest;
class QWebEngineScriptCollection;
class QWebEngineSettings;
+class QWebEngineUrlRequestInterceptor;
class QWEBENGINEWIDGETS_EXPORT QWebEnginePage : public QObject {
Q_OBJECT
@@ -305,6 +306,8 @@ public:
void setDevToolsPage(QWebEnginePage *page);
QWebEnginePage *devToolsPage() const;
+ void setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor);
+
const QWebEngineContextMenuData &contextMenuData() const;
Q_SIGNALS:
diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h
index eecbf0b65..7b4e52f79 100644
--- a/src/webenginewidgets/api/qwebenginepage_p.h
+++ b/src/webenginewidgets/api/qwebenginepage_p.h
@@ -151,6 +151,7 @@ public:
void printRequested() override;
const QObject *holdingQObject() const override;
ClientType clientType() override { return QtWebEngineCore::WebContentsAdapterClient::WidgetsClient; }
+ void interceptRequest(QWebEngineUrlRequestInfo &) override;
void widgetChanged(QtWebEngineCore::RenderWidgetHostViewQtDelegate *newWidget) override;
QtWebEngineCore::ProfileAdapter *profileAdapter() override;
@@ -193,6 +194,7 @@ public:
bool defaultAudioMuted;
qreal defaultZoomFactor;
QTimer wasShownTimer;
+ QWebEngineUrlRequestInterceptor *requestInterceptor;
QtWebEngineCore::RenderWidgetHostViewQtDelegateWidget *widget = nullptr;
mutable QtWebEngineCore::CallbackDirectory m_callbacks;
diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp
index 537cf41fd..d80ed997c 100644
--- a/src/webenginewidgets/api/qwebengineprofile.cpp
+++ b/src/webenginewidgets/api/qwebengineprofile.cpp
@@ -667,20 +667,7 @@ QWebEngineSettings *QWebEngineProfile::settings() const
const QWebEngineUrlSchemeHandler *QWebEngineProfile::urlSchemeHandler(const QByteArray &scheme) const
{
const Q_D(QWebEngineProfile);
- if (d->profileAdapter()->customUrlSchemeHandlers().contains(scheme))
- return d->profileAdapter()->customUrlSchemeHandlers().value(scheme);
- return 0;
-}
-
-static bool checkInternalScheme(const QByteArray &scheme)
-{
- static QSet<QByteArray> internalSchemes;
- if (internalSchemes.isEmpty()) {
- internalSchemes << QByteArrayLiteral("qrc") << QByteArrayLiteral("data") << QByteArrayLiteral("blob")
- << QByteArrayLiteral("http") << QByteArrayLiteral("https") << QByteArrayLiteral("ftp")
- << QByteArrayLiteral("javascript");
- }
- return internalSchemes.contains(scheme);
+ return d->profileAdapter()->urlSchemeHandler(scheme);
}
/*!
@@ -694,20 +681,7 @@ static bool checkInternalScheme(const QByteArray &scheme)
void QWebEngineProfile::installUrlSchemeHandler(const QByteArray &scheme, QWebEngineUrlSchemeHandler *handler)
{
Q_D(QWebEngineProfile);
- Q_ASSERT(handler);
- QByteArray canonicalScheme = scheme.toLower();
- if (checkInternalScheme(canonicalScheme)) {
- qWarning("Cannot install a URL scheme handler overriding internal scheme: %s", scheme.constData());
- return;
- }
-
- if (d->profileAdapter()->customUrlSchemeHandlers().contains(canonicalScheme)) {
- if (d->profileAdapter()->customUrlSchemeHandlers().value(canonicalScheme) != handler)
- qWarning("URL scheme handler already installed for the scheme: %s", scheme.constData());
- return;
- }
- d->profileAdapter()->addCustomUrlSchemeHandler(canonicalScheme, handler);
- connect(handler, SIGNAL(_q_destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler*)), this, SLOT(destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler*)));
+ d->profileAdapter()->installUrlSchemeHandler(scheme, handler);
}
/*!
@@ -720,10 +694,7 @@ void QWebEngineProfile::installUrlSchemeHandler(const QByteArray &scheme, QWebEn
void QWebEngineProfile::removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *handler)
{
Q_D(QWebEngineProfile);
- Q_ASSERT(handler);
- if (!d->profileAdapter()->removeCustomUrlSchemeHandler(handler))
- return;
- disconnect(handler, SIGNAL(_q_destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler*)), this, SLOT(destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler*)));
+ d->profileAdapter()->removeUrlSchemeHandler(handler);
}
/*!
@@ -736,10 +707,7 @@ void QWebEngineProfile::removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *handl
void QWebEngineProfile::removeUrlScheme(const QByteArray &scheme)
{
Q_D(QWebEngineProfile);
- QWebEngineUrlSchemeHandler *handler = d->profileAdapter()->takeCustomUrlSchemeHandler(scheme);
- if (!handler)
- return;
- disconnect(handler, SIGNAL(_q_destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler*)), this, SLOT(destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler*)));
+ d->profileAdapter()->removeUrlScheme(scheme);
}
/*!
@@ -750,12 +718,42 @@ void QWebEngineProfile::removeUrlScheme(const QByteArray &scheme)
void QWebEngineProfile::removeAllUrlSchemeHandlers()
{
Q_D(QWebEngineProfile);
- d->profileAdapter()->clearCustomUrlSchemeHandlers();
+ d->profileAdapter()->removeAllUrlSchemeHandlers();
+}
+
+/*!
+ \since 5.13
+
+ Sets this profile to be used for downloading and caching when needed during
+ certificate verification, for instance for OCSP, CRLs, and AIA.
+
+ Only one QWebEngineProfile can do this at a time, and it is recommended
+ that the profile fullfilling this role has a disk HTTP cache to avoid
+ needlessly re-downloading.
+
+ Currently only affects Linux/NSS installations where it enables OCSP.
+
+ As long as one profile has this option enabled, all other profiles will be
+ able to use it for their certificate verification.
+
+ \sa isUsedForGlobalCertificateVerification(), httpCacheType()
+*/
+void QWebEngineProfile::setUseForGlobalCertificateVerification()
+{
+ Q_D(QWebEngineProfile);
+ d->profileAdapter()->setUseForGlobalCertificateVerification();
}
-void QWebEngineProfile::destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler *obj)
+/*!
+ \since 5.13
+
+ Returns \c true if this profile is currently being used for global
+ certificate verification.
+*/
+bool QWebEngineProfile::isUsedForGlobalCertificateVerification() const
{
- removeUrlSchemeHandler(obj);
+ Q_D(const QWebEngineProfile);
+ return d->profileAdapter()->isUsedForGlobalCertificateVerification();
}
/*!
diff --git a/src/webenginewidgets/api/qwebengineprofile.h b/src/webenginewidgets/api/qwebengineprofile.h
index f9a564cd2..7ec28ac0a 100644
--- a/src/webenginewidgets/api/qwebengineprofile.h
+++ b/src/webenginewidgets/api/qwebengineprofile.h
@@ -128,19 +128,20 @@ public:
void setSpellCheckEnabled(bool enabled);
bool isSpellCheckEnabled() const;
+ void setUseForGlobalCertificateVerification();
+ bool isUsedForGlobalCertificateVerification() const;
+
static QWebEngineProfile *defaultProfile();
Q_SIGNALS:
void downloadRequested(QWebEngineDownloadItem *download);
-private Q_SLOTS:
- void destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler *obj);
-
private:
Q_DISABLE_COPY(QWebEngineProfile)
Q_DECLARE_PRIVATE(QWebEngineProfile)
QWebEngineProfile(QWebEngineProfilePrivate *, QObject *parent = Q_NULLPTR);
+ friend class QWebEnginePage;
friend class QWebEnginePagePrivate;
friend class QWebEngineUrlSchemeHandler;
QScopedPointer<QWebEngineProfilePrivate> d_ptr;
diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
index e34bca875..45e87477f 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
@@ -133,25 +133,31 @@ RenderWidgetHostViewQtDelegateWidget::RenderWidgetHostViewQtDelegateWidget(Rende
"QSurfaceFormat before the QtGui application instance is created.");
}
#endif
-
- // Make sure the OpenGL profile of the QQuickWidget matches the shared context profile.
- if (sharedFormat.profile() == QSurfaceFormat::CoreProfile) {
- int major;
- int minor;
- QSurfaceFormat::OpenGLContextProfile profile;
-
+ int major;
+ int minor;
+ QSurfaceFormat::OpenGLContextProfile profile;
#ifdef Q_OS_MACOS
- // Due to QTBUG-63180, requesting the sharedFormat.majorVersion() on macOS will lead to
- // a failed creation of QQuickWidget shared context. Thus make sure to request the
- // major version specified in the defaultFormat instead.
- major = defaultFormat.majorVersion();
- minor = defaultFormat.minorVersion();
- profile = defaultFormat.profile();
+ // Due to QTBUG-63180, requesting the sharedFormat.majorVersion() on macOS will lead to
+ // a failed creation of QQuickWidget shared context. Thus make sure to request the
+ // major version specified in the defaultFormat instead.
+ major = defaultFormat.majorVersion();
+ minor = defaultFormat.minorVersion();
+ profile = defaultFormat.profile();
#else
- major = sharedFormat.majorVersion();
- minor = sharedFormat.minorVersion();
- profile = sharedFormat.profile();
+ major = sharedFormat.majorVersion();
+ minor = sharedFormat.minorVersion();
+ profile = sharedFormat.profile();
+#endif
+
+ // Make sure the OpenGL profile of the QQuickWidget matches the shared context profile.
+ // It covers the following cases:
+ // 1) Desktop OpenGL Core Profile.
+ // 2) Windows ANGLE OpenGL ES profile.
+ if (sharedFormat.profile() == QSurfaceFormat::CoreProfile
+#ifdef Q_OS_WIN
+ || globalSharedContext->isOpenGLES()
#endif
+ ) {
format.setMajorVersion(major);
format.setMinorVersion(minor);
format.setProfile(profile);