diff --git a/src/lib/network/networkmanager.cpp b/src/lib/network/networkmanager.cpp index 0f1ca8295..4ffb3d55e 100644 --- a/src/lib/network/networkmanager.cpp +++ b/src/lib/network/networkmanager.cpp @@ -237,4 +237,6 @@ void NetworkManager::loadSettings() settings.endGroup(); mApp->webProfile()->setHttpAcceptLanguage(AcceptLanguage::generateHeader(langs)); + + m_urlInterceptor->loadSettings(); } diff --git a/src/lib/network/networkurlinterceptor.cpp b/src/lib/network/networkurlinterceptor.cpp index 475bb5f62..370da55a2 100644 --- a/src/lib/network/networkurlinterceptor.cpp +++ b/src/lib/network/networkurlinterceptor.cpp @@ -18,20 +18,29 @@ #include "networkurlinterceptor.h" #include "urlinterceptor.h" +#include "settings.h" NetworkUrlInterceptor::NetworkUrlInterceptor(QObject *parent) : QWebEngineUrlRequestInterceptor(parent) + , m_sendDNT(false) { } bool NetworkUrlInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info) { - foreach (UrlInterceptor *interceptor, m_interceptors) { - if (interceptor->interceptRequest(info)) - return true; + bool result = false; + + if (m_sendDNT) { + result = true; + info.setExtraHeader(QByteArrayLiteral("DNT"), QByteArrayLiteral("1")); } - return false; + foreach (UrlInterceptor *interceptor, m_interceptors) { + if (interceptor->interceptRequest(info)) + result = true; + } + + return result; } void NetworkUrlInterceptor::installUrlInterceptor(UrlInterceptor *interceptor) @@ -44,3 +53,11 @@ void NetworkUrlInterceptor::removeUrlInterceptor(UrlInterceptor *interceptor) { m_interceptors.removeOne(interceptor); } + +void NetworkUrlInterceptor::loadSettings() +{ + Settings settings; + settings.beginGroup("Web-Browser-Settings"); + m_sendDNT = settings.value("DoNotTrack", false).toBool(); + settings.endGroup(); +} diff --git a/src/lib/network/networkurlinterceptor.h b/src/lib/network/networkurlinterceptor.h index aeaf3e0df..03d6c666e 100644 --- a/src/lib/network/networkurlinterceptor.h +++ b/src/lib/network/networkurlinterceptor.h @@ -35,8 +35,11 @@ public: void installUrlInterceptor(UrlInterceptor *interceptor); void removeUrlInterceptor(UrlInterceptor *interceptor); + void loadSettings(); + private: QList m_interceptors; + bool m_sendDNT; }; #endif // NETWORKURLINTERCEPTOR_H