]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/commitdiff
Display a MessageBox when an HTTP Ping is blocked. https://redmine.stoutner.com/issue...
authorSoren Stoutner <soren@stoutner.com>
Fri, 10 Jun 2022 23:19:25 +0000 (16:19 -0700)
committerSoren Stoutner <soren@stoutner.com>
Fri, 10 Jun 2022 23:19:25 +0000 (16:19 -0700)
src/interceptors/UrlRequestInterceptor.cpp

index d4059285576e1c469ac76178fb50fcb912073e4a..634889867ad386464e5472b1d01c5ff1ccca6075 100644 (file)
 // Application headers.
 #include "UrlRequestInterceptor.h"
 
+// KDE Framework headers.
+#include <KLocalizedString>
+
+// Qt framework headers.
+#include <QMessageBox>
+
 // Construct the class.
 UrlRequestInterceptor::UrlRequestInterceptor(QObject *parentObjectPointer) : QWebEngineUrlRequestInterceptor(parentObjectPointer) {}
 
@@ -42,9 +48,7 @@ void UrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &urlReques
 
                 // Reapply the domain settings if the host is changing.
                 if (requestingHost != requestedHost)
-                {
                     emit applyDomainSettings(requestedHost);
-                }
             }
 
             break;
@@ -64,6 +68,25 @@ void UrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &urlReques
             // Block HTTP ping requests.
             urlRequestInfo.block(true);
 
+            // Instantiate an HTTP ping blocked message box.
+            QMessageBox httpPingBlockedMessageBox;
+
+            // Set the icon.
+            httpPingBlockedMessageBox.setIcon(QMessageBox::Information);
+
+            // Set the window title.
+            httpPingBlockedMessageBox.setWindowTitle(i18nc("HTTP Ping blocked dialog title", "HTTP Ping Blocked"));
+
+            // Set the text.
+            httpPingBlockedMessageBox.setText(i18nc("HTTP Ping blocked dialog text", "This request has been blocked because it sends a naughty HTTP ping to %1.",
+                                                    urlRequestInfo.requestUrl().toString()));
+
+            // Set the standard button.
+            httpPingBlockedMessageBox.setStandardButtons(QMessageBox::Ok);
+
+            // Display the message box.
+            httpPingBlockedMessageBox.exec();
+
             break;
         }