From b105f2cce889a132faa9d7a5cdc8505b75965321 Mon Sep 17 00:00:00 2001 From: Soren Stoutner Date: Fri, 10 Jun 2022 16:19:25 -0700 Subject: [PATCH] Display a MessageBox when an HTTP Ping is blocked. https://redmine.stoutner.com/issues/853 --- src/interceptors/UrlRequestInterceptor.cpp | 27 ++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/interceptors/UrlRequestInterceptor.cpp b/src/interceptors/UrlRequestInterceptor.cpp index d405928..6348898 100644 --- a/src/interceptors/UrlRequestInterceptor.cpp +++ b/src/interceptors/UrlRequestInterceptor.cpp @@ -20,6 +20,12 @@ // Application headers. #include "UrlRequestInterceptor.h" +// KDE Framework headers. +#include + +// Qt framework headers. +#include + // 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; } -- 2.43.0