From: Soren Stoutner Date: Mon, 6 Jun 2022 15:38:46 +0000 (-0700) Subject: Disable forward and back mouse buttons when a dialog is displayed. https://redmine... X-Git-Tag: v0.1~31 X-Git-Url: https://gitweb.stoutner.com/?a=commitdiff_plain;h=10f39f4db8275d73df3cd2e501de054622adfe58;p=PrivacyBrowserPC.git Disable forward and back mouse buttons when a dialog is displayed. https://redmine.stoutner.com/issues/856 --- diff --git a/src/views/BrowserView.cpp b/src/views/BrowserView.cpp index 591e16a..ef69db4 100644 --- a/src/views/BrowserView.cpp +++ b/src/views/BrowserView.cpp @@ -73,19 +73,42 @@ BrowserView::BrowserView(QWidget *parent) : QWidget(parent) // Set the local storage filter. webEngineCookieStorePointer->setCookieFilter([this](const QWebEngineCookieStore::FilterRequest &filterRequest) { - // qDebug() << "Page URL: " << filterRequest.firstPartyUrl << ", Local storage URL: " << filterRequest.origin << ", Is third-party: " << filterRequest.thirdParty; + //qDebug().noquote().nospace() << "Page URL: " << filterRequest.firstPartyUrl << ", Local storage URL: " << filterRequest.origin << ", Is third-party: " << filterRequest.thirdParty; // Block all third party local storage requests, including the sneaky ones that don't register a first party URL. if (filterRequest.thirdParty || (filterRequest.firstPartyUrl == QStringLiteral(""))) + { + //qDebug() << "Request blocked."; + + // Return false. return false; + } + /* TODO. Waiting for a solution to . // Check each tab to see if this local storage request should be allowed. for (PrivacyWebEngine *privacyWebEnginePointer : *privacyWebEngineListPointer) { + //qDebug().noquote().nospace() << "Local storage: " << privacyWebEnginePointer->localStorageEnabled << ". WebEngine URL: " << webEngineViewPointer->url().host() << ". Request Host: " << filterRequest.firstPartyUrl.host(); + // Allow this local storage request if it comes from a tab with local storage enabled. if (privacyWebEnginePointer->localStorageEnabled && (webEngineViewPointer->url().host() == filterRequest.firstPartyUrl.host())) + { + //qDebug() << "Request allowed."; + + // Return true. return true; + } } + */ + + // Allow the request if it is first party and local storage is enabled. + if (!filterRequest.thirdParty && currentPrivacyWebEnginePointer->localStorageEnabled) + { + // Return true. + return true; + } + + //qDebug() << "Request blocked."; // Block any remaining local storage requests. return false; @@ -509,7 +532,7 @@ void BrowserView::loadUrlFromLineEdit(QString url) const void BrowserView::mouseBack() const { // Go back if possible. - if (webEngineHistoryPointer->canGoBack()) + if (webEngineViewPointer->isActiveWindow() && webEngineHistoryPointer->canGoBack()) { // Clear the URL line edit focus. emit clearUrlLineEditFocus(); @@ -522,7 +545,7 @@ void BrowserView::mouseBack() const void BrowserView::mouseForward() const { // Go forward if possible. - if (webEngineHistoryPointer->canGoForward()) + if (webEngineViewPointer->isActiveWindow() && webEngineHistoryPointer->canGoForward()) { // Clear the URL line edit focus. emit clearUrlLineEditFocus();