X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=src%2Fviews%2FBrowserView.cpp;h=6bdbda6536cc2dcea6f421267ccc8a5781860959;hb=823acbeb2cc27030857f249ab7157d8562e7b7fe;hp=591e16aa3ae44361e6f43c70d40b20d51af406fe;hpb=cd1c3d0483b9026736fdcb151d90dda872d8a400;p=PrivacyBrowserPC.git diff --git a/src/views/BrowserView.cpp b/src/views/BrowserView.cpp index 591e16a..6bdbda6 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; @@ -187,7 +210,7 @@ void BrowserView::applyApplicationSettings() searchEngineUrl = SearchEngineHelper::getSearchUrl(Settings::searchEngine()); // Emit the update search engine actions signal. - emit updateSearchEngineActions(Settings::searchEngine()); + emit updateSearchEngineActions(Settings::searchEngine(), true); } // This exists as a separate function from `applyDomainSettings()` so it can be listed as a slot and function without the need for a boolean argument. @@ -351,14 +374,12 @@ void BrowserView::applyDomainSettings(const QString &hostname, const bool reload emit updateJavaScriptAction(webEngineSettingsPointer->testAttribute(QWebEngineSettings::JavascriptEnabled)); emit updateLocalStorageAction(currentPrivacyWebEnginePointer->localStorageEnabled); emit updateDomStorageAction(webEngineSettingsPointer->testAttribute(QWebEngineSettings::LocalStorageEnabled)); - emit updateUserAgentActions(webEngineProfilePointer->httpUserAgent()); + emit updateUserAgentActions(webEngineProfilePointer->httpUserAgent(), true); emit updateZoomFactorAction(webEngineViewPointer->zoomFactor()); // Reload the website if requested. if (reloadWebsite) - { webEngineViewPointer->reload(); - } } void BrowserView::applyOnTheFlySearchEngine(QAction *searchEngineActionPointer) @@ -371,6 +392,9 @@ void BrowserView::applyOnTheFlySearchEngine(QAction *searchEngineActionPointer) // Store the search engine string. searchEngineUrl = SearchEngineHelper::getSearchUrl(searchEngineName); + + // Update the search engine actionas. + emit updateSearchEngineActions(searchEngineName, false); } void BrowserView::applyOnTheFlyUserAgent(QAction *userAgentActionPointer) const @@ -384,6 +408,9 @@ void BrowserView::applyOnTheFlyUserAgent(QAction *userAgentActionPointer) const // Apply the user agent. webEngineProfilePointer->setHttpUserAgent(UserAgentHelper::getUserAgentFromTranslatedName(userAgentName)); + // Update the user agent actions. + emit updateUserAgentActions(webEngineProfilePointer->httpUserAgent(), false); + // Reload the website. webEngineViewPointer->reload(); } @@ -509,7 +536,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 +549,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();