mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
AdBlock: Don't block user triggered network requests
Disable AdBlock when user tries to load the url from locationbar, clicking on link, opening new tab, ... Only block web content not explicitly requested by user - images, scripts, redirects, ...
This commit is contained in:
parent
a61e3ff0ad
commit
26f466ed0d
@ -563,7 +563,10 @@ QNetworkReply* NetworkManager::createRequest(QNetworkAccessManager::Operation op
|
||||
return reply;
|
||||
}
|
||||
|
||||
if (req.rawHeader("X-QupZilla-UserLoadAction") == QByteArray("1")) {
|
||||
// Indicates whether the load action was triggered by user (eg. opening new tab, clicking on link, ...)
|
||||
bool userLoadAction = req.rawHeader("X-QupZilla-UserLoadAction") == QByteArray("1");
|
||||
|
||||
if (userLoadAction) {
|
||||
req.setRawHeader("X-QupZilla-UserLoadAction", QByteArray());
|
||||
req.setAttribute(QNetworkRequest::Attribute(QNetworkRequest::User + 151), QString());
|
||||
}
|
||||
@ -585,7 +588,7 @@ QNetworkReply* NetworkManager::createRequest(QNetworkAccessManager::Operation op
|
||||
//req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
|
||||
|
||||
// Adblock
|
||||
if (op == QNetworkAccessManager::GetOperation) {
|
||||
if (!userLoadAction && op == QNetworkAccessManager::GetOperation) {
|
||||
if (!m_adblockManager) {
|
||||
m_adblockManager = AdBlockManager::instance();
|
||||
}
|
||||
|
@ -587,7 +587,10 @@ void WebView::savePageAs()
|
||||
|
||||
void WebView::openUrlInNewTab(const QUrl &url, Qz::NewTabPositionFlags position)
|
||||
{
|
||||
loadInNewTab(url, position);
|
||||
QNetworkRequest request(url);
|
||||
request.setRawHeader("X-QupZilla-UserLoadAction", QByteArray("1"));
|
||||
|
||||
loadInNewTab(request, position);
|
||||
}
|
||||
|
||||
void WebView::downloadUrlToDisk()
|
||||
@ -711,7 +714,6 @@ void WebView::userDefinedOpenUrlInNewTab(const QUrl &url, bool invert)
|
||||
else {
|
||||
position &= ~Qz::NT_NotSelectedTab;
|
||||
position |= Qz::NT_SelectedTab;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user