X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserPC.git;a=blobdiff_plain;f=src%2Finterceptors%2FUrlRequestInterceptor.cpp;fp=src%2Finterceptors%2FUrlRequestInterceptor.cpp;h=83f104595ac8ab67e904d04b48b769b3c05556f8;hp=634889867ad386464e5472b1d01c5ff1ccca6075;hb=15219459baed09d03d17a12c72302595c135fd53;hpb=b516206c4d278640374cbfe244a5510e5ac70b54 diff --git a/src/interceptors/UrlRequestInterceptor.cpp b/src/interceptors/UrlRequestInterceptor.cpp index 6348898..83f1045 100644 --- a/src/interceptors/UrlRequestInterceptor.cpp +++ b/src/interceptors/UrlRequestInterceptor.cpp @@ -31,34 +31,6 @@ UrlRequestInterceptor::UrlRequestInterceptor(QObject *parentObjectPointer) : QWe void UrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &urlRequestInfo) { - // Handle the request according to the navigation type. - switch (urlRequestInfo.navigationType()) - { - case QWebEngineUrlRequestInfo::NavigationTypeLink: - case QWebEngineUrlRequestInfo::NavigationTypeTyped: - case QWebEngineUrlRequestInfo::NavigationTypeBackForward: - case QWebEngineUrlRequestInfo::NavigationTypeRedirect: - { - // Only check the hosts if the main URL is changing. - if (urlRequestInfo.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeMainFrame) - { - // Get the hosts. - QString requestingHost = urlRequestInfo.initiator().host(); - QString requestedHost = urlRequestInfo.requestUrl().host(); - - // Reapply the domain settings if the host is changing. - if (requestingHost != requestedHost) - emit applyDomainSettings(requestedHost); - } - - break; - } - - default: - // Do nothing. - break; - } - // Handle the request according to the resource type. switch (urlRequestInfo.resourceType()) { @@ -96,4 +68,33 @@ void UrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &urlReques break; } } + + // Handle the request according to the navigation type. + switch (urlRequestInfo.navigationType()) + { + case QWebEngineUrlRequestInfo::NavigationTypeLink: + case QWebEngineUrlRequestInfo::NavigationTypeTyped: + case QWebEngineUrlRequestInfo::NavigationTypeBackForward: + // case QWebEngineUrlRequestInfo::NavigationTypeReload: This can be uncommented once https://redmine.stoutner.com/issues/821 has been fixed. + case QWebEngineUrlRequestInfo::NavigationTypeRedirect: + { + // Only check the hosts if the main URL is changing. + if (urlRequestInfo.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeMainFrame) + { + // Get the hosts. + QString requestingHost = urlRequestInfo.initiator().host(); + QString requestedHost = urlRequestInfo.requestUrl().host(); + + // Reapply the domain settings if the host is changing. + if (requestingHost != requestedHost) + emit applyDomainSettings(requestedHost); + } + + break; + } + + default: + // Do nothing. + break; + } }