]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blobdiff - src/interceptors/UrlRequestInterceptor.cpp
Make the Request Details dialog scrollable. https://redmine.stoutner.com/issues...
[PrivacyBrowserPC.git] / src / interceptors / UrlRequestInterceptor.cpp
index 18944ea5ae0587bb06940c9f2286bd7a4e6b7358..0a8c04fe47b1717ca7555d93c20410c930249f53 100644 (file)
@@ -27,7 +27,8 @@
 #include <KLocalizedString>
 
 // Construct the class.
-UrlRequestInterceptor::UrlRequestInterceptor(QObject *parentObjectPointer) : QWebEngineUrlRequestInterceptor(parentObjectPointer) {}
+UrlRequestInterceptor::UrlRequestInterceptor(PrivacyWebEngineView *privacyWebEngineViewPointer) :
+                                             QWebEngineUrlRequestInterceptor(privacyWebEngineViewPointer), privacyWebEngineViewPointer(privacyWebEngineViewPointer) {}
 
 void UrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &urlRequestInfo)
 {
@@ -43,9 +44,10 @@ void UrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &urlReques
     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) {
@@ -76,35 +78,35 @@ void UrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &urlReques
                 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.