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

Unified Diff: lib/requestBlocker.js

Issue 29711592: Issue 6424 - Use internal symbol in ext namespace (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Switch to internal methods everywhere Created March 1, 2018, 11:58 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
« ext/background.js ('K') | « ext/content.js ('k') | metadata.chrome » ('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
@@ -86,25 +86,24 @@
devtools.logRequest(
page, url, type, docDomain,
thirdParty, sitekey,
specificOnly, filter
);
}
}
-ext.webRequest.onBeforeRequest.addListener((url, type, page, frame) =>
+function shouldAllowRequest(url, type, page, frame)
{
let docDomain = null;
let sitekey = null;
let specificOnly = false;
let thirdParty = false;
let urlString = stringifyURL(url);
-
if (frame && page)
{
if (checkWhitelisted(page, frame))
return true;
docDomain = extractHostFromFrame(frame);
sitekey = getKey(page, frame);
thirdParty = isThirdParty(url, docDomain);
@@ -120,17 +119,19 @@
);
setTimeout(onBeforeRequestAsync, 0, page, urlString,
mappedType, docDomain,
thirdParty, sitekey,
specificOnly, filter);
return !(filter instanceof BlockingFilter);
-});
+}
+
+ext.webRequest.onBeforeRequest.addListener(shouldAllowRequest);
port.on("filters.collapse", (message, sender) =>
{
if (checkWhitelisted(sender.page, sender.frame))
return false;
let typeMask = RegExpFilter.typeMap[message.mediatype];
let documentHost = extractHostFromFrame(sender.frame);
@@ -213,15 +214,11 @@
// Edge supports neither webRequest.ResourceType nor WebSocket blocking yet:
// https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10297376/
if (browser.webRequest.ResourceType &&
(msg.requestType.toUpperCase() in browser.webRequest.ResourceType))
{
return false;
}
- return ext.webRequest.onBeforeRequest._dispatch(
- new URL(msg.url),
- msg.requestType,
- sender.page,
- sender.frame
- ).includes(false);
+ return !shouldAllowRequest(new URL(msg.url), msg.requestType, sender.page,
+ sender.frame);
});
« ext/background.js ('K') | « ext/content.js ('k') | metadata.chrome » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld