1#include "DekkoWebEngineUrlRequestInterceptor.h"
2#include <QWebEngineUrlRequestInfo>
5DekkoWebEngineUrlRequestInterceptor::DekkoWebEngineUrlRequestInterceptor(QWebEngineUrlRequestInterceptor *parent) : QWebEngineUrlRequestInterceptor(parent),
6 remoteResourcesAreBlocked(true)
10void DekkoWebEngineUrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info)
12 auto requestUrl = info.requestUrl();
14 if (!this->hasAllowedScheme(requestUrl))
18 bool doBlock = this->remoteResourcesAreBlocked
19 && (info.resourceType() != QWebEngineUrlRequestInfo::ResourceTypeMainFrame);
21 emit interceptedRemoteRequest(doBlock);
25bool DekkoWebEngineUrlRequestInterceptor::hasAllowedScheme(
const QUrl &url)
27 return this->testScheme(
"cid", url) || this->testScheme(
"dekko-part", url) || this->testScheme(
"dekko-msg", url) || this->testScheme(
"blob", url);
30bool DekkoWebEngineUrlRequestInterceptor::testScheme(
const QString &scheme,
const QUrl &url)
32 return url.scheme() == scheme;
35void DekkoWebEngineUrlRequestInterceptor::setBlockRemoteResources(
bool doBlock)
37 this->remoteResourcesAreBlocked = doBlock;
40bool DekkoWebEngineUrlRequestInterceptor::areRemoteResourcesBlocked()
const
42 return this->remoteResourcesAreBlocked;