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

Unified Diff: background.js

Issue 29338962: Issue 3860 - Move request blocking logic to a seperate module (Closed)
Patch Set: Created March 23, 2016, 1:55 p.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 | « no previous file | include.preload.js » ('j') | lib/requestBlocker.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: background.js
===================================================================
--- a/background.js
+++ b/background.js
@@ -17,26 +17,14 @@
with(require("filterClasses"))
{
- this.BlockingFilter = BlockingFilter;
+ this.RegExpFilter = RegExpFilter;
this.WhitelistFilter = WhitelistFilter;
- this.RegExpFilter = RegExpFilter;
-}
-with(require("whitelisting"))
-{
- this.checkWhitelisted = checkWhitelisted;
- this.getKey = getKey;
-}
-with(require("url"))
-{
- this.stringifyURL = stringifyURL;
- this.isThirdParty = isThirdParty;
- this.extractHostFromFrame = extractHostFromFrame;
}
var FilterStorage = require("filterStorage").FilterStorage;
var SpecialSubscription = require("subscriptionClasses").SpecialSubscription;
var ElemHide = require("elemHide").ElemHide;
-var defaultMatcher = require("matcher").defaultMatcher;
-var Prefs = require("prefs").Prefs;
+var checkWhitelisted = require("whitelisting").checkWhitelisted;
+var extractHostFromFrame = require("url").extractHostFromFrame;
var port = require("messaging").port;
var devtools = require("devtools");
@@ -86,42 +74,6 @@
return {selectors: selectors, trace: trace};
});
-port.on("should-collapse", function(msg, sender)
-{
- if (checkWhitelisted(sender.page, sender.frame))
- return false;
-
- var typeMask = RegExpFilter.typeMap[msg.mediatype];
- var documentHost = extractHostFromFrame(sender.frame);
- var sitekey = getKey(sender.page, sender.frame);
- var blocked = false;
-
- var specificOnly = checkWhitelisted(
- sender.page, sender.frame,
- RegExpFilter.typeMap.GENERICBLOCK
- );
-
- for (var i = 0; i < msg.urls.length; i++)
- {
- var url = new URL(msg.urls[i], msg.baseURL);
- var filter = defaultMatcher.matchesAny(
- stringifyURL(url), typeMask,
- documentHost, isThirdParty(url, documentHost),
- sitekey, specificOnly
- );
-
- if (filter instanceof BlockingFilter)
- {
- if (filter.collapse != null)
- return filter.collapse;
-
- blocked = true;
- }
- }
-
- return blocked && Prefs.hidePlaceholders;
-});
-
port.on("forward", function(msg, sender)
{
var targetPage;
« no previous file with comments | « no previous file | include.preload.js » ('j') | lib/requestBlocker.js » ('J')

Powered by Google App Engine
This is Rietveld