]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blobdiff - src/MainView.cpp
Reapply domain settings when the host changes.
[PrivacyBrowserPC.git] / src / MainView.cpp
index 9ddf1fb4524177e07627da213c047bb9d7b6354e..3bef1040a88bb160939b685cd2fbf10635f69844 100644 (file)
@@ -23,6 +23,7 @@
 #include "MouseEventFilter.h"
 #include "Settings.h"
 #include "ui_MainView.h"
+#include "UrlRequestInterceptor.h"
 #include "helpers/SearchEngineHelper.h"
 #include "helpers/UserAgentHelper.h"
 
@@ -76,6 +77,15 @@ MainView::MainView(QWidget *parent) : QWidget(parent)
     // Listen for hovered link URLs.
     connect(webEnginePagePointer, SIGNAL(linkHovered(const QString)), this, SLOT(pageLinkHovered(const QString)));
 
+    // Instantiate the URL request interceptor.
+    UrlRequestInterceptor *urlRequestInterceptorPointer = new UrlRequestInterceptor();
+
+    // Set the URL request interceptor.
+    webEngineProfilePointer->setUrlRequestInterceptor(urlRequestInterceptorPointer);
+
+    // Reapply the domain settings when the host changes.
+    connect(urlRequestInterceptorPointer, SIGNAL(applyDomainSettings()), this, SLOT(applyDomainSettingsWithoutReloading()));
+
     // Disable the cache.
     webEngineProfilePointer->setHttpCacheType(QWebEngineProfile::NoCache);
 
@@ -118,10 +128,17 @@ void MainView::applyApplicationSettings() const
 // This exists as a separate function from `applyDomainSettings()` so it can be listed as a slot and function without the need for a boolean argument.
 void MainView::applyDomainSettingsAndReload() const
 {
-    // Apply the domain setings.  `true` reloads the website.
+    // Apply the domain settings.  `true` reloads the website.
     applyDomainSettings(true);
 }
 
+// This exists as a separate function from `applyDomainSettings()` so it can be listed as a slot and function without the need for a boolean argument.
+void MainView::applyDomainSettingsWithoutReloading() const
+{
+    // Apply the domain settings  `false` does not reload the website.
+    applyDomainSettings(false);
+}
+
 void MainView::applyDomainSettings(bool reloadWebsite) const
 {
     // Set the JavaScript status.