requestStructPointer->urlString = urlRequestInfo.requestUrl().toString();
requestStructPointer->webPageUrlString = urlRequestInfo.firstPartyUrl().toString();
- // Check the filter lists.
- bool continueProcessing = globalFilterListHelperPointer->checkFilterLists(privacyWebEngineViewPointer, urlRequestInfo, requestStructPointer);
+ // Create a continue processing flag.
+ bool continueProcessing = true;
+
+ // Block certain resource types.
+ switch (urlRequestInfo.resourceType())
+ {
+ case QWebEngineUrlRequestInfo::ResourceTypeNavigationPreloadMainFrame:
+ case QWebEngineUrlRequestInfo::ResourceTypeNavigationPreloadSubFrame:
+ {
+ // Block the request.
+ urlRequestInfo.block(true);
+
+ // Mark the request struct as blocked.
+ requestStructPointer->dispositionInt = FilterListHelper::BLOCKED;
+
+ // Mark the preload request as blocked by the default behavior.
+ requestStructPointer->filterListTitle = i18nc("Default preload blocking", "Default blocking of all preload requests.");
+
+ // Set the continue processing flag.
+ continueProcessing = false;
+
+ break;
+ }
+
+ default:
+ {
+ // Do nothing.
+ break;
+ }
+ }
+
+ // Check the filter lists if it hasn't already been handled.
+ if (continueProcessing)
+ continueProcessing = globalFilterListHelperPointer->checkFilterLists(privacyWebEngineViewPointer, urlRequestInfo, requestStructPointer);
// Further process the request if it hasn't already been handled.
if (continueProcessing) {
// Mark the ping as blocked by the default behavior.
requestStructPointer->filterListTitle = i18nc("Default HTTP ping blocking", "Default blocking of all HTTP ping requests.");
+ // Set the continue processing flag.
+ continueProcessing = false;
+
// Display the HTTP Ping blocked dialog.
Q_EMIT displayHttpPingDialog(urlRequestInfo.requestUrl().toString());
}
}
- // Handle the request according to the navigation type.
- switch (urlRequestInfo.navigationType())
+ // Handle the request according to the navigation type if it hasn't already been handled.
+ if (continueProcessing)
{
- case QWebEngineUrlRequestInfo::NavigationTypeLink:
- case QWebEngineUrlRequestInfo::NavigationTypeTyped:
- case QWebEngineUrlRequestInfo::NavigationTypeFormSubmitted:
- case QWebEngineUrlRequestInfo::NavigationTypeRedirect:
- case QWebEngineUrlRequestInfo::NavigationTypeOther:
+ switch (urlRequestInfo.navigationType())
{
- // Only check the hosts if the main URL is changing.
- if (urlRequestInfo.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeMainFrame)
+ case QWebEngineUrlRequestInfo::NavigationTypeLink:
+ case QWebEngineUrlRequestInfo::NavigationTypeTyped:
+ case QWebEngineUrlRequestInfo::NavigationTypeFormSubmitted:
+ case QWebEngineUrlRequestInfo::NavigationTypeRedirect:
+ case QWebEngineUrlRequestInfo::NavigationTypeOther:
{
- // Get the request URL.
- QUrl requestUrl = urlRequestInfo.requestUrl();
-
- // Reapply the domain settings if the host is changing.
- if (privacyWebEngineViewPointer->currentHost != requestUrl.host())
+ // Only check the hosts if the main URL is changing.
+ if (urlRequestInfo.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeMainFrame)
{
- // Apply domain settings, after which the request will be loaded. `false` indicates that history is not being navigated.
- Q_EMIT applyDomainSettings(requestUrl, false);
-
- // Block this copy of the request.
- urlRequestInfo.block(true);
+ // Get the request URL.
+ QUrl requestUrl = urlRequestInfo.requestUrl();
+
+ // Reapply the domain settings if the host is changing.
+ if (privacyWebEngineViewPointer->currentHost != requestUrl.host())
+ {
+ // Apply domain settings, after which the request will be loaded. `false` indicates that history is not being navigated.
+ Q_EMIT applyDomainSettings(requestUrl, false);
+
+ // Block this copy of the request.
+ urlRequestInfo.block(true);
+ }
}
- }
- break;
- }
+ break;
+ }
- case QWebEngineUrlRequestInfo::NavigationTypeBackForward:
- {
- // Only check the hosts if the main URL is changing.
- if (urlRequestInfo.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeMainFrame)
+ case QWebEngineUrlRequestInfo::NavigationTypeBackForward:
{
- // Get the request URL.
- QUrl requestUrl = urlRequestInfo.requestUrl();
-
- // Reapply the domain settings if the host is changing.
- if (privacyWebEngineViewPointer->currentHost != requestUrl.host())
+ // Only check the hosts if the main URL is changing.
+ if (urlRequestInfo.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeMainFrame)
{
- // Apply domain settings, after which the request will be loaded. `true` indicates that history is being navigated.
- Q_EMIT applyDomainSettings(requestUrl, true);
+ // Get the request URL.
+ QUrl requestUrl = urlRequestInfo.requestUrl();
+
+ // Reapply the domain settings if the host is changing.
+ if (privacyWebEngineViewPointer->currentHost != requestUrl.host())
+ {
+ // Apply domain settings, after which the request will be loaded. `true` indicates that history is being navigated.
+ Q_EMIT applyDomainSettings(requestUrl, true);
+ }
}
+
+ break;
}
- break;
+ default:
+ {
+ // Do nothing.
+ break;
+ }
}
-
- default:
- // Do nothing.
- break;
}
// Send the request struct to the privacy WebEngine view.