]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/commitdiff
Apply domain settings even when the main URL is explicitly allowed by the filter...
authorSoren Stoutner <soren@stoutner.com>
Wed, 31 Jul 2024 02:51:18 +0000 (19:51 -0700)
committerSoren Stoutner <soren@stoutner.com>
Wed, 31 Jul 2024 02:51:18 +0000 (19:51 -0700)
doc/index.docbook
src/helpers/UserAgentHelper.cpp
src/interceptors/UrlRequestInterceptor.cpp
src/widgets/CMakeLists.txt
src/widgets/PrivacyWebEnginePage.cpp [new file with mode: 0644]
src/widgets/PrivacyWebEnginePage.h [new file with mode: 0644]
src/widgets/PrivacyWebEngineView.cpp

index 600dd3c9ab4dbac65dc39554ed89bc9c33898639..54b204df7d363ad666484c25aba2b9e4333c86de 100644 (file)
 
         <!-- Version 0.6. -->
         <sect1 id="version_0.6">
-            <title>0.6 - 15 July 2024</title>
+            <title><ulink url="https://www.stoutner.com/privacy-browser-pc-0-6/">0.6</ulink> -
+                <ulink url="https://gitweb.stoutner.com/?p=PrivacyBrowserPC.git;a=commitdiff;h=dd08da27e3e1cae734790cae8e3b8626fdf40c4b;ds=sidebyside">15 July 2024</ulink></title>
 
             <itemizedlist>
                 <listitem><para>Add <ulink url="https://redmine.stoutner.com/issues/969">filter lists</ulink>.</para></listitem>
index 1e49813c1981c033f91d32522cdd3e345bed7c81..4bd143258d2f38b40fc4510c018ae4bbf52e0a35 100644 (file)
@@ -39,7 +39,7 @@ const QString UserAgentHelper::SAFARI_MACOS_DATABASE = QLatin1String("Safari mac
 // Define the public user agent constants.
 const QString UserAgentHelper::PRIVACY_BROWSER_USER_AGENT = QLatin1String("PrivacyBrowser/1.0");
 const QString UserAgentHelper::FIREFOX_LINUX_USER_AGENT = QLatin1String("Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0");
-const QString UserAgentHelper::CHROMIUM_LINUX_USER_AGENT = QLatin1String("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36");
+const QString UserAgentHelper::CHROMIUM_LINUX_USER_AGENT = QLatin1String("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36");
 const QString UserAgentHelper::FIREFOX_WINDOWS_USER_AGENT = QLatin1String("Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0");
 const QString UserAgentHelper::CHROME_WINDOWS_USER_AGENT = QLatin1String("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36");
 const QString UserAgentHelper::EDGE_WINDOWS_USER_AGENT = QLatin1String("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0");
index 940848f940cd17166c214284147f47e9d8f27a39..0a8c04fe47b1717ca7555d93c20410c930249f53 100644 (file)
@@ -78,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.
index 9fe904f0761dcfec36dac8c3b4827d8ed298dc40..9eaebbb2d6ec8f1d8c6b4a51574449eba725c4be 100644 (file)
@@ -20,6 +20,7 @@
 target_sources(privacybrowser PRIVATE
     DevToolsWebEngineView.cpp
     DraggableTreeView.cpp
+    PrivacyWebEnginePage.cpp
     PrivacyWebEngineView.cpp
     TabWidget.cpp
     UrlLineEdit.cpp
diff --git a/src/widgets/PrivacyWebEnginePage.cpp b/src/widgets/PrivacyWebEnginePage.cpp
new file mode 100644 (file)
index 0000000..b2fec02
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2024 Soren Stoutner <soren@stoutner.com>.
+ *
+ * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc/>.
+ *
+ * Privacy Browser PC is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Privacy Browser PC is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Privacy Browser PC.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+// Application headers.
+#include "PrivacyWebEnginePage.h"
+
+// Construct the class.
+PrivacyWebEnginePage::PrivacyWebEnginePage(QWebEngineProfile *webEngineProfilePointer, QObject *parentObjectPointer) : QWebEnginePage(webEngineProfilePointer, parentObjectPointer) {}
+
diff --git a/src/widgets/PrivacyWebEnginePage.h b/src/widgets/PrivacyWebEnginePage.h
new file mode 100644 (file)
index 0000000..9880b0b
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2024 Soren Stoutner <soren@stoutner.com>.
+ *
+ * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc/>.
+ *
+ * Privacy Browser PC is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Privacy Browser PC is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Privacy Browser PC.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef PRIVACY_WEBENGINE_PAGE_H
+#define PRIVACY_WEBENGINE_PAGE_H
+
+// Qt toolkit headers.
+#include <QWebEnginePage>
+
+class PrivacyWebEnginePage : public QWebEnginePage
+{
+    // Include the Q_OBJECT macro.
+    Q_OBJECT
+
+public:
+    // The default constructor.
+    explicit PrivacyWebEnginePage(QWebEngineProfile *webEngineProfilePointer, QObject *parentObjectPointer = nullptr);
+
+//protected:
+};
+#endif
index 71f10a3f8b46594c3a7ba4db9574d9af1387773d..6314f2b2a01fc020f3acb83baaabfefd5fe34dda 100644 (file)
@@ -19,6 +19,7 @@
 
 // Application headers.
 #include "PrivacyWebEngineView.h"
+#include "PrivacyWebEnginePage.h"
 #include "Settings.h"
 #include "ui_HttpAuthenticationDialog.h"
 #include "databases/CookiesDatabase.h"
@@ -39,13 +40,13 @@ PrivacyWebEngineView::PrivacyWebEngineView(QWidget *parentWidgetPointer) : QWebE
     webEngineProfilePointer = new QWebEngineProfile(QLatin1String(""));
 
     // Create a WebEngine page.
-    QWebEnginePage *webEnginePagePointer = new QWebEnginePage(webEngineProfilePointer);
+    PrivacyWebEnginePage *privacyWebEnginePagePointer = new PrivacyWebEnginePage(webEngineProfilePointer);
 
     // Set the WebEngine page.
-    setPage(webEnginePagePointer);
+    setPage(privacyWebEnginePagePointer);
 
     // Get handles for the various aspects of the WebEngine.
-    webEngineSettingsPointer = webEnginePagePointer->settings();
+    webEngineSettingsPointer = privacyWebEnginePagePointer->settings();
 
     // Instantiate the URL request interceptor.
     UrlRequestInterceptor *urlRequestInterceptorPointer = new UrlRequestInterceptor(this);
@@ -60,7 +61,7 @@ PrivacyWebEngineView::PrivacyWebEngineView(QWidget *parentWidgetPointer) : QWebE
     connect(urlRequestInterceptorPointer, SIGNAL(requestProcessed(RequestStruct*)), this, SLOT(storeRequest(RequestStruct*)));
 
     // Handle HTTP authentication requests.
-    connect(webEnginePagePointer, SIGNAL(authenticationRequired(const QUrl&, QAuthenticator*)), this, SLOT(handleAuthenticationRequest(const QUrl&, QAuthenticator*)));
+    connect(privacyWebEnginePagePointer, SIGNAL(authenticationRequired(const QUrl&, QAuthenticator*)), this, SLOT(handleAuthenticationRequest(const QUrl&, QAuthenticator*)));
 }
 
 void PrivacyWebEngineView::addCookieToList(const QNetworkCookie &cookie) const