#include <KLocalizedString>
// Construct the class.
-UrlRequestInterceptor::UrlRequestInterceptor(QObject *parentObjectPointer) : QWebEngineUrlRequestInterceptor(parentObjectPointer) {}
+UrlRequestInterceptor::UrlRequestInterceptor(PrivacyWebEngineView *privacyWebEngineViewPointer) :
+ QWebEngineUrlRequestInterceptor(privacyWebEngineViewPointer), privacyWebEngineViewPointer(privacyWebEngineViewPointer) {}
void UrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &urlRequestInfo)
{
requestStructPointer->requestMethodString = urlRequestInfo.requestMethod();
requestStructPointer->resourceTypeInt = urlRequestInfo.resourceType();
requestStructPointer->urlString = urlRequestInfo.requestUrl().toString();
+ requestStructPointer->webPageUrlString = urlRequestInfo.firstPartyUrl().toString();
// Check the filter lists.
- bool continueProcessing = globalFilterListHelperPointer->checkFilterLists(urlRequestInfo, requestStructPointer);
+ bool continueProcessing = globalFilterListHelperPointer->checkFilterLists(privacyWebEngineViewPointer, urlRequestInfo, requestStructPointer);
// Further process the request if it hasn't already been handled.
if (continueProcessing) {
break;
}
}
+ }
- // Handle the request according to the navigation type.
- switch (urlRequestInfo.navigationType())
+ // 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:
{
- 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)
{
- // 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);
- }
+ // Get the hosts.
+ QString requestingHost = urlRequestInfo.initiator().host();
+ QString requestedHost = urlRequestInfo.requestUrl().host();
- break;
+ // Reapply the domain settings if the host is changing.
+ if (requestingHost != requestedHost)
+ emit applyDomainSettings(requestedHost);
}
- default:
- // Do nothing.
- break;
+ break;
}
+
+ default:
+ // Do nothing.
+ break;
}
// Send the request struct to the privacy WebEngine view.