+ // Initialize the current privacy web engine pointer.
+ currentPrivacyWebEnginePointer = new PrivacyWebEngine(webEngineViewPointer);
+
+ // Populate the privacy web engine list.
+ privacyWebEngineListPointer->append(currentPrivacyWebEnginePointer);
+
+ // Set the cookie filter.
+ webEngineCookieStorePointer->setCookieFilter([this](const QWebEngineCookieStore::FilterRequest &filterRequest)
+ {
+ // qDebug() << "Cookie page URL: " << filterRequest.firstPartyUrl << ", Cookie 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("")))
+ return false;
+
+ // Check each tab to see if this local storage request should be allowed.
+ for (PrivacyWebEngine *privacyWebEnginePointer : *privacyWebEngineListPointer)
+ {
+ // Allow this local storage request if it comes from a tab with local storage enabled.
+ if (privacyWebEnginePointer->cookiesEnabled && (webEngineViewPointer->url().host() == filterRequest.firstPartyUrl.host()))
+ return true;
+ }
+
+ // Block any remaining local storage requests.
+ return false;
+ });
+