+ // Initialize the current privacy web engine pointer.
+ currentPrivacyWebEnginePointer = new PrivacyWebEngine(webEngineViewPointer);
+
+ // Populate the privacy web engine list.
+ privacyWebEngineListPointer->append(currentPrivacyWebEnginePointer);
+
+ // Set the local storage filter.
+ webEngineCookieStorePointer->setCookieFilter([this](const QWebEngineCookieStore::FilterRequest &filterRequest)
+ {
+ //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 <https://redmine.stoutner.com/issues/857>.
+ // 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;
+ });
+
+ // Process cookie changes.
+ connect(webEngineCookieStorePointer, SIGNAL(cookieAdded(QNetworkCookie)), this, SLOT(cookieAdded(QNetworkCookie)));
+ connect(webEngineCookieStorePointer, SIGNAL(cookieRemoved(QNetworkCookie)), this, SLOT(cookieRemoved(QNetworkCookie)));
+
+ // Get a list of durable cookies.
+ QList<QNetworkCookie*> *durableCookiesListPointer = CookiesDatabase::getCookies();
+
+ // Add the durable cookies to the store.
+ for (QNetworkCookie *cookiePointer : *durableCookiesListPointer)
+ addCookieToStore(*cookiePointer);
+
+ // Store a copy of the WebEngine default user agent.
+ webEngineDefaultUserAgent = webEngineProfilePointer->httpUserAgent();
+
+ // Update the URL line edit when the URL changes.
+ connect(webEngineViewPointer, SIGNAL(urlChanged(const QUrl)), this, SLOT(updateUrl(const QUrl)));
+
+ // Update the progress bar.
+ connect(webEngineViewPointer, SIGNAL(loadStarted()), this, SLOT(loadStarted()));
+ connect(webEngineViewPointer, SIGNAL(loadProgress(const int)), this, SLOT(loadProgress(const int)));
+ connect(webEngineViewPointer, SIGNAL(loadFinished(const bool)), this, SLOT(loadFinished()));