/*
- * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
*
// 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"
// 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
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();