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

Unified Diff: messageResponder.js

Issue 29329677: Issue 2396 - Add CSS property filter message responder (Closed)
Patch Set: Ensure that the frame isn't whitelisted Created Nov. 3, 2015, 3:46 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: messageResponder.js
diff --git a/messageResponder.js b/messageResponder.js
index a6886cbbe74380c6901224cc87b8d405de5a8da8..88dafed727cc822d28df5da643e74fc4a66014a6 100644
--- a/messageResponder.js
+++ b/messageResponder.js
@@ -25,10 +25,12 @@
var FilterStorage = require("filterStorage").FilterStorage;
var FilterNotifier = require("filterNotifier").FilterNotifier;
var defaultMatcher = require("matcher").defaultMatcher;
-
+ var CSSRules = require("cssRules").CSSRules;
Thomas Greiner 2015/11/03 16:03:44 This breaks our test environment because there's n
kzar 2015/11/03 16:19:11 Stubbing out cssRules.CSSRules.getRulesForDomain()
+
var filterClasses = require("filterClasses");
var Filter = filterClasses.Filter;
var BlockingFilter = filterClasses.BlockingFilter;
+ var RegExpFilter = filterClasses.RegExpFilter;
var Synchronizer = require("synchronizer").Synchronizer;
var subscriptionClasses = require("subscriptionClasses");
@@ -194,13 +196,40 @@
callback(filter instanceof BlockingFilter);
break;
case "filters.get":
+ if (message.what == "cssproperties")
+ {
+ var filters = [];
+ var isFrameWhitelisted = require("whitelisting").isFrameWhitelisted;
+
+ if (message.domain &&
+ !isFrameWhitelisted(sender.page, sender.frame,
+ RegExpFilter.typeMap.DOCUMENT |
+ RegExpFilter.typeMap.ELEMHIDE))
+ {
+ var specificOnly = isFrameWhitelisted(
+ sender.page, sender.frame, RegExpFilter.typeMap.GENERICHIDE
+ );
+ filters = CSSRules.getRulesForDomain(message.domain, specificOnly);
+ filters = filters.map(function(filter)
+ {
+ return {
+ prefix: filter.selectorPrefix,
+ suffix: filter.selectorSuffix,
+ regexp: filter.regexpString
+ };
+ });
+ }
+ callback(filters);
+ break;
+ }
+
var subscription = Subscription.fromURL(message.subscriptionUrl);
if (!subscription)
{
callback([]);
break;
}
-
+
callback(subscription.filters.map(convertFilter));
break;
case "filters.importRaw":
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld