X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=src%2Fwidgets%2FPrivacyWebEngineView.cpp;fp=src%2Fwidgets%2FPrivacyWebEngineView.cpp;h=15ee508b74eeaac03ad3d3e7c4e4c894b516edb6;hb=a44e607fb5398c80c5de2629017865ae749e8fbf;hp=42c331fec5340447ed05da6433a6475db30f7de4;hpb=c5706a6ff3fbc42418e60b79fbe3f5c19396f7d2;p=PrivacyBrowserPC.git diff --git a/src/widgets/PrivacyWebEngineView.cpp b/src/widgets/PrivacyWebEngineView.cpp index 42c331f..15ee508 100644 --- a/src/widgets/PrivacyWebEngineView.cpp +++ b/src/widgets/PrivacyWebEngineView.cpp @@ -1,7 +1,7 @@ /* * Copyright 2022-2024 Soren Stoutner . * - * This file is part of Privacy Browser PC . + * This file is part of Privacy Browser PC . * * Privacy Browser PC is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,6 +24,7 @@ #include "databases/CookiesDatabase.h" #include "databases/DomainsDatabase.h" #include "dialogs/HttpAuthenticationDialog.h" +#include "helpers/FilterListHelper.h" #include "interceptors/UrlRequestInterceptor.h" #include "windows/BrowserWindow.h" @@ -52,11 +53,11 @@ PrivacyWebEngineView::PrivacyWebEngineView(QWidget *parentWidgetPointer) : QWebE // Set the URL request interceptor. webEngineProfilePointer->setUrlRequestInterceptor(urlRequestInterceptorPointer); - // Reapply the domain settings when the host changes. + // Connect the URL request interceptor signals. connect(urlRequestInterceptorPointer, SIGNAL(applyDomainSettings(const QString&)), this, SLOT(applyDomainSettingsWithoutReloading(const QString&))); - - // Display HTTP Ping blocked dialogs. + connect(urlRequestInterceptorPointer, SIGNAL(newMainFrameResource()), this, SLOT(clearRequestsList())); connect(urlRequestInterceptorPointer, SIGNAL(displayHttpPingDialog(const QString&)), this, SLOT(displayHttpPingDialog(const QString&))); + connect(urlRequestInterceptorPointer, SIGNAL(requestProcessed(RequestStruct*)), this, SLOT(storeRequest(RequestStruct*))); // Handle HTTP authentication requests. connect(webEnginePagePointer, SIGNAL(authenticationRequired(const QUrl&, QAuthenticator*)), this, SLOT(handleAuthenticationRequest(const QUrl&, QAuthenticator*))); @@ -74,7 +75,7 @@ void PrivacyWebEngineView::addCookieToList(const QNetworkCookie &cookie) const CookiesDatabase::updateCookie(cookie); // Update the cookies action. - emit updateCookiesAction(cookieListPointer->size()); + emit numberOfCookiesChanged(cookieListPointer->size()); } void PrivacyWebEngineView::applyDomainSettingsWithoutReloading(const QString &hostname) @@ -228,6 +229,18 @@ void PrivacyWebEngineView::applyDomainSettings(const QString &hostname, const bo emit updateUi(this); } +void PrivacyWebEngineView::clearRequestsList() +{ + // Reset the number of blocked requests. + blockedRequests = 0; + + // Clear the requests list. + requestsListPointer->clear(); + + // Update the blocked requests action. + emit(requestBlocked(blockedRequests)); +} + void PrivacyWebEngineView::contextMenuEvent(QContextMenuEvent *contextMenuEvent) { // Get a handle for the QWebEnginePage *webEnginePagePointer = page(); @@ -329,5 +342,21 @@ void PrivacyWebEngineView::removeCookieFromList(const QNetworkCookie &cookie) co cookieListPointer->remove(cookie); // Update the cookies action. - emit updateCookiesAction(cookieListPointer->size()); + emit numberOfCookiesChanged(cookieListPointer->size()); +} + +void PrivacyWebEngineView::storeRequest(RequestStruct *requestStructPointer) +{ + // Store the request struct in the list. + requestsListPointer->append(requestStructPointer); + + // Track blocked requests. + if (requestStructPointer->dispositionInt == FilterListHelper::BLOCKED) + { + // Update the blocked requests counter. + ++blockedRequests; + + // Update the blocked requests action. + emit(requestBlocked(blockedRequests)); + } }