X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserPC.git;a=blobdiff_plain;f=src%2Fwidgets%2FPrivacyWebEngineView.cpp;fp=src%2Fwidgets%2FPrivacyWebEngineView.cpp;h=6080288e4f5b4238404e8e13795e305f2fd9c65e;hp=05c765925d8aa6da639c4f4f019634ffc3d956f5;hb=3ea5ede1fd0721bea6813f36388ba6387bdbfcfe;hpb=f7522adfac888208a7006eb7e67a7173e995ec48 diff --git a/src/widgets/PrivacyWebEngineView.cpp b/src/widgets/PrivacyWebEngineView.cpp index 05c7659..6080288 100644 --- a/src/widgets/PrivacyWebEngineView.cpp +++ b/src/widgets/PrivacyWebEngineView.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2022-2023 Soren Stoutner . + * Copyright 2022-2024 Soren Stoutner . * * This file is part of Privacy Browser PC . * @@ -20,8 +20,10 @@ // Application headers. #include "PrivacyWebEngineView.h" #include "Settings.h" +#include "ui_HttpAuthenticationDialog.h" #include "databases/CookiesDatabase.h" #include "databases/DomainsDatabase.h" +#include "dialogs/HttpAuthenticationDialog.h" #include "interceptors/UrlRequestInterceptor.h" #include "windows/BrowserWindow.h" @@ -55,6 +57,9 @@ PrivacyWebEngineView::PrivacyWebEngineView(QWidget *parentWidgetPointer) : QWebE // Display HTTP Ping blocked dialogs. connect(urlRequestInterceptorPointer, SIGNAL(displayHttpPingDialog(const QString&)), this, SLOT(displayHttpPingDialog(const QString&))); + + // Handle HTTP authentication requests. + connect(webEnginePagePointer, SIGNAL(authenticationRequired(const QUrl&, QAuthenticator*)), this, SLOT(handleAuthenticationRequest(const QUrl&, QAuthenticator*))); } void PrivacyWebEngineView::addCookieToList(const QNetworkCookie &cookie) const @@ -298,6 +303,15 @@ void PrivacyWebEngineView::displayHttpPingDialog(const QString &httpPingUrl) con emit displayHttpPingBlockedDialog(httpPingUrl); } +void PrivacyWebEngineView::handleAuthenticationRequest(const QUrl &requestUrl, QAuthenticator *authenticatorPointer) +{ + // Instantiate an HTTP authentication dialog. + HttpAuthenticationDialog *httpAuthenticationDialogPointer = new HttpAuthenticationDialog(parentWidget(), requestUrl, authenticatorPointer); + + // Display the dialog. This must be `exec()` instead of `show()` so that the website doesn't proceed before populating the authentication pointer. + httpAuthenticationDialogPointer->exec(); +} + void PrivacyWebEngineView::removeCookieFromList(const QNetworkCookie &cookie) const { //qDebug() << "Remove cookie: " << cookie.toRawForm();