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

Unified Diff: background.js

Issue 5225119261655040: Issue 1282 - Don't generate filters conflicting with existing exception rules (Closed)
Patch Set: Created Dec. 15, 2014, 2:47 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.postload.js » ('j') | include.preload.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: background.js
===================================================================
--- a/background.js
+++ b/background.js
@@ -519,6 +519,50 @@
else
sendResponse(false);
break;
+ case "check-whitelisted-urls":
+ var documentHost = extractHostFromFrame(sender.frame);
+ var sitekey = getKey(sender.page, sender.frame);
+
+ var result = Object.create(null);
+ for (var i = 0; i < msg.urls.length; i++)
+ {
+ var requestUrl = msg.urls[i];
+ var requestHost = extractHostFromURL(requestUrl);
+
+ var filter = defaultMatcher.matchesAny(
+ requestUrl, msg.mediatype, documentHost,
+ isThirdParty(requestHost, documentHost),
+ sitekey
+ );
+
+ result[requestUrl] = filter instanceof WhitelistFilter;
+ }
+
+ sendResponse(result);
+ break;
+ case "get-filters-from-selectors":
+ var filters = [];
+ var selectors = [];
+
+ if (!isFrameWhitelisted(sender.page, sender.frame, "ELEMHIDE"))
+ {
+ var documentHost = extractHostFromFrame(sender.frame);
+
+ for (var i = 0; i < msg.selectors.length; i++)
+ {
+ var selector = msg.selectors[i];
+ var filter = documentHost + "##" + selector;
+
+ if (!ElemHide.getException(Filter.fromText(filter), documentHost))
+ {
+ filters.push(filter);
+ selectors.push(selector);
+ }
+ }
+ }
+
+ sendResponse({filters: filters, selectors: selectors});
+ break;
case "get-domain-enabled-state":
// Returns whether this domain is in the exclusion list.
// The browser action popup asks us this.
« no previous file with comments | « no previous file | include.postload.js » ('j') | include.preload.js » ('J')

Powered by Google App Engine
This is Rietveld