Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/requestBlocker.js

Issue 29998582: Issue [TBD] - Update adblockpluscore dependency to [TBD] Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Reformat Created Feb. 5, 2019, 5:45 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/popupBlocker.js ('k') | lib/whitelisting.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/requestBlocker.js
===================================================================
--- a/lib/requestBlocker.js
+++ b/lib/requestBlocker.js
@@ -19,17 +19,16 @@
"use strict";
const {Filter, RegExpFilter, BlockingFilter} =
require("../adblockpluscore/lib/filterClasses");
const {Subscription} = require("../adblockpluscore/lib/subscriptionClasses");
const {defaultMatcher} = require("../adblockpluscore/lib/matcher");
const {filterNotifier} = require("../adblockpluscore/lib/filterNotifier");
-const {isThirdParty} = require("../adblockpluscore/lib/domain");
const {Prefs} = require("./prefs");
const {checkWhitelisted, getKey} = require("./whitelisting");
const {extractHostFromFrame} = require("./url");
const {port} = require("./messaging");
const {logRequest: hitLoggerLogRequest} = require("./hitLogger");
const extensionProtocol = new URL(browser.extension.getURL("")).protocol;
@@ -83,25 +82,16 @@
return [
extractHostFromFrame(frame, originUrl),
getKey(page, frame, originUrl),
!!checkWhitelisted(page, frame, originUrl,
RegExpFilter.typeMap.GENERICBLOCK)
];
}
-function matchRequest(url, type, docDomain, sitekey, specificOnly)
-{
- let thirdParty = isThirdParty(url, docDomain);
- let filter = defaultMatcher.matchesAny(url.href, RegExpFilter.typeMap[type],
- docDomain, thirdParty,
- sitekey, specificOnly);
- return [filter, thirdParty];
-}
-
function getRelatedTabIds(details)
{
// This is the common case, the request is associated with a single tab.
// If tabId is -1, its not (e.g. the request was sent by
// a Service/Shared Worker) and we have to identify the related tabs.
if (details.tabId != -1)
return Promise.resolve([details.tabId]);
@@ -183,18 +173,18 @@
return;
if (checkWhitelisted(page, frame, originUrl))
return;
let type = resourceTypes.get(details.type) || "OTHER";
let [docDomain, sitekey, specificOnly] = getDocumentInfo(page, frame,
originUrl);
- let [filter, thirdParty] = matchRequest(url, type, docDomain,
- sitekey, specificOnly);
+ let filter = defaultMatcher.matchesAny(url, RegExpFilter.typeMap[type],
+ docDomain, sitekey, specificOnly);
let result;
let rewrittenUrl;
if (filter instanceof BlockingFilter)
{
if (typeof filter.rewrite == "string")
{
@@ -208,17 +198,17 @@
result = {cancel: true};
}
getRelatedTabIds(details).then(tabIds =>
{
logRequest(
tabIds,
{
- url: details.url, type, docDomain, thirdParty,
+ url: details.url, type, docDomain,
sitekey, specificOnly, rewrittenUrl
},
filter
);
});
return result;
}, {urls: ["<all_urls>"]}, ["blocking"]);
@@ -230,19 +220,19 @@
if (checkWhitelisted(page, frame))
return false;
let blocked = false;
let [docDomain, sitekey, specificOnly] = getDocumentInfo(page, frame);
for (let url of message.urls)
{
- let [filter] = matchRequest(new URL(url, message.baseURL),
- message.mediatype, docDomain,
- sitekey, specificOnly);
+ let filter = defaultMatcher.matchesAny(new URL(url, message.baseURL),
+ RegExpFilter.typeMap[message.mediatype],
+ docDomain, sitekey, specificOnly);
if (filter instanceof BlockingFilter)
{
if (filter.collapse != null)
return filter.collapse;
blocked = true;
}
}
@@ -254,21 +244,22 @@
{
let {page, frame} = sender;
if (checkWhitelisted(page, frame))
return false;
let {url} = msg;
let [docDomain, sitekey, specificOnly] = getDocumentInfo(page, frame);
- let [filter, thirdParty] = matchRequest(new URL(url), "WEBRTC", docDomain,
- sitekey, specificOnly);
+ let filter = defaultMatcher.matchesAny(new URL(url),
+ RegExpFilter.typeMap.WEBRTC,
+ docDomain, sitekey, specificOnly);
logRequest(
[sender.page.id],
- {url, type: "WEBRTC", docDomain, thirdParty, sitekey, specificOnly},
+ {url, type: "WEBRTC", docDomain, sitekey, specificOnly},
filter
);
return filter instanceof BlockingFilter;
});
let ignoreFilterNotifications = false;
let handlerBehaviorChangedQuota =
« no previous file with comments | « lib/popupBlocker.js ('k') | lib/whitelisting.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld