summaryrefslogtreecommitdiffstats
path: root/src/core/net/network_delegate_qt.cpp
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2019-10-07 10:59:45 +0200
committerMichal Klocek <michal.klocek@qt.io>2019-10-10 14:22:52 +0200
commit7d08de5b527cb2112556a126b889dd7d0d888d22 (patch)
tree92c03667f705d86bf8643ce704b6d366e9d76da5 /src/core/net/network_delegate_qt.cpp
parentb44ed0fb99cd3d7047fcd322010c27cfa7989a18 (diff)
Fix life cycle issue of QWebEngineUrlRequestInterceptor
Since 5e92adf intercept() is called on ui thread, however this patch does not consider deletion of interceptor while io thread still process the request and for examples checks interceptor's deprecated property. Fix it. Note this only fixes issue for interceptors which are not deprecated therefore run on ui thread. Change-Id: I5d5909065563e57a0cacb81fd04271b3f88596de Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core/net/network_delegate_qt.cpp')
-rw-r--r--src/core/net/network_delegate_qt.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/core/net/network_delegate_qt.cpp b/src/core/net/network_delegate_qt.cpp
index 7f278fd92..2cca152e6 100644
--- a/src/core/net/network_delegate_qt.cpp
+++ b/src/core/net/network_delegate_qt.cpp
@@ -136,11 +136,11 @@ int NetworkDelegateQt::OnBeforeURLRequest(net::URLRequest *request, net::Complet
// Deprecated =begin
// quick peek if deprecated
- QWebEngineUrlRequestInterceptor* profileInterceptor = m_profileIOData->requestInterceptor();
- if (profileInterceptor && profileInterceptor->property("deprecated").toBool()) {
- profileInterceptor = nullptr;
- if (QWebEngineUrlRequestInterceptor* interceptor = m_profileIOData->acquireInterceptor()) {
- interceptor->interceptRequest(requestInfo);
+
+ if (m_profileIOData->isInterceptorDeprecated()) {
+ QWebEngineUrlRequestInterceptor* profileInterceptor = m_profileIOData->acquireInterceptor();
+ if (profileInterceptor && m_profileIOData->isInterceptorDeprecated()) {
+ profileInterceptor->interceptRequest(requestInfo);
m_profileIOData->releaseInterceptor();
if (requestInfo.changed()) {
int result = infoPrivate->shouldBlockRequest ? net::ERR_BLOCKED_BY_CLIENT : net::OK;
@@ -174,7 +174,9 @@ int NetworkDelegateQt::OnBeforeURLRequest(net::URLRequest *request, net::Complet
if (!resourceInfo)
return net::OK;
- if (!m_profileIOData->hasPageInterceptors() && !profileInterceptor && !content::IsResourceTypeFrame(resourceType))
+ // try to bail out
+ if (!m_profileIOData->hasPageInterceptors() && (!m_profileIOData->requestInterceptor() || m_profileIOData->isInterceptorDeprecated()) &&
+ !content::IsResourceTypeFrame(resourceType))
return net::OK;
auto webContentsGetter = resourceInfo->GetWebContentsGetterForRequest();
@@ -185,7 +187,7 @@ int NetworkDelegateQt::OnBeforeURLRequest(net::URLRequest *request, net::Complet
std::move(requestInfo),
webContentsGetter,
std::move(callback),
- profileInterceptor ? m_profileIOData->profileAdapter() : nullptr
+ m_profileIOData->profileAdapter()
);
// We'll run the callback after we notified the UI thread.