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

Delta Between Two Patch Sets: messageResponder.js

Issue 29329677: Issue 2396 - Add CSS property filter message responder (Closed)
Left Patch Set: Ensure that the frame isn't whitelisted Created Nov. 3, 2015, 3:46 p.m.
Right Patch Set: Remove specificOnly parameter from getRulesForDomain stub Created Nov. 5, 2015, 3:54 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « background.js ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 (function(global) 18 (function(global)
19 { 19 {
20 if (!global.ext) 20 if (!global.ext)
21 global.ext = require("ext_background"); 21 global.ext = require("ext_background");
22 22
23 var Prefs = require("prefs").Prefs; 23 var Prefs = require("prefs").Prefs;
24 var Utils = require("utils").Utils; 24 var Utils = require("utils").Utils;
25 var FilterStorage = require("filterStorage").FilterStorage; 25 var FilterStorage = require("filterStorage").FilterStorage;
26 var FilterNotifier = require("filterNotifier").FilterNotifier; 26 var FilterNotifier = require("filterNotifier").FilterNotifier;
27 var defaultMatcher = require("matcher").defaultMatcher; 27 var defaultMatcher = require("matcher").defaultMatcher;
28 var CSSRules = require("cssRules").CSSRules; 28 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()
29 29
30 var filterClasses = require("filterClasses"); 30 var filterClasses = require("filterClasses");
31 var Filter = filterClasses.Filter; 31 var Filter = filterClasses.Filter;
32 var BlockingFilter = filterClasses.BlockingFilter; 32 var BlockingFilter = filterClasses.BlockingFilter;
33 var RegExpFilter = filterClasses.RegExpFilter; 33 var RegExpFilter = filterClasses.RegExpFilter;
34 var Synchronizer = require("synchronizer").Synchronizer; 34 var Synchronizer = require("synchronizer").Synchronizer;
35 35
36 var subscriptionClasses = require("subscriptionClasses"); 36 var subscriptionClasses = require("subscriptionClasses");
37 var Subscription = subscriptionClasses.Subscription; 37 var Subscription = subscriptionClasses.Subscription;
38 var DownloadableSubscription = subscriptionClasses.DownloadableSubscription; 38 var DownloadableSubscription = subscriptionClasses.DownloadableSubscription;
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 var filter = defaultMatcher.matchesAny(message.url, message.requestType, 194 var filter = defaultMatcher.matchesAny(message.url, message.requestType,
195 message.docDomain, message.thirdParty); 195 message.docDomain, message.thirdParty);
196 callback(filter instanceof BlockingFilter); 196 callback(filter instanceof BlockingFilter);
197 break; 197 break;
198 case "filters.get": 198 case "filters.get":
199 if (message.what == "cssproperties") 199 if (message.what == "cssproperties")
200 { 200 {
201 var filters = []; 201 var filters = [];
202 var isFrameWhitelisted = require("whitelisting").isFrameWhitelisted; 202 var isFrameWhitelisted = require("whitelisting").isFrameWhitelisted;
203 203
204 if (message.domain && 204 if (!isFrameWhitelisted(sender.page, sender.frame,
205 !isFrameWhitelisted(sender.page, sender.frame,
206 RegExpFilter.typeMap.DOCUMENT | 205 RegExpFilter.typeMap.DOCUMENT |
207 RegExpFilter.typeMap.ELEMHIDE)) 206 RegExpFilter.typeMap.ELEMHIDE))
208 { 207 {
209 var specificOnly = isFrameWhitelisted( 208 filters = CSSRules.getRulesForDomain(sender.frame.url.hostname);
210 sender.page, sender.frame, RegExpFilter.typeMap.GENERICHIDE
211 );
212 filters = CSSRules.getRulesForDomain(message.domain, specificOnly);
213 filters = filters.map(function(filter) 209 filters = filters.map(function(filter)
214 { 210 {
215 return { 211 return {
216 prefix: filter.selectorPrefix, 212 prefix: filter.selectorPrefix,
217 suffix: filter.selectorSuffix, 213 suffix: filter.selectorSuffix,
218 regexp: filter.regexpString 214 regexp: filter.regexpString
219 }; 215 };
220 }); 216 });
221 } 217 }
222 callback(filters); 218 callback(filters);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 subscription.title = message.title; 341 subscription.title = message.title;
346 subscription.homepage = message.homepage; 342 subscription.homepage = message.homepage;
347 FilterStorage.addSubscription(subscription); 343 FilterStorage.addSubscription(subscription);
348 if (!subscription.lastDownload) 344 if (!subscription.lastDownload)
349 Synchronizer.execute(subscription); 345 Synchronizer.execute(subscription);
350 } 346 }
351 break; 347 break;
352 } 348 }
353 }); 349 });
354 })(this); 350 })(this);
LEFTRIGHT

Powered by Google App Engine
This is Rietveld