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

Side by Side Diff: messageResponder.js

Issue 29361722: Issue 4592 - Adapt messaging code for the new element hiding emulation filters (Closed) Base URL: https://bitbucket.org/fhd/adblockplusui
Patch Set: Remove features property Created Nov. 21, 2016, 5:31 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « background.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 ElemHideEmulation = require("elemHideEmulation").ElemHideEmulation;
29 var NotificationStorage = require("notification").Notification; 29 var NotificationStorage = require("notification").Notification;
30 30
31 var filterClasses = require("filterClasses"); 31 var filterClasses = require("filterClasses");
32 var Filter = filterClasses.Filter; 32 var Filter = filterClasses.Filter;
33 var BlockingFilter = filterClasses.BlockingFilter; 33 var BlockingFilter = filterClasses.BlockingFilter;
34 var RegExpFilter = filterClasses.RegExpFilter; 34 var RegExpFilter = filterClasses.RegExpFilter;
35 var Synchronizer = require("synchronizer").Synchronizer; 35 var Synchronizer = require("synchronizer").Synchronizer;
36 36
37 var info = require("info"); 37 var info = require("info");
38 var subscriptionClasses = require("subscriptionClasses"); 38 var subscriptionClasses = require("subscriptionClasses");
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 FilterStorage.addFilter(result.filter); 213 FilterStorage.addFilter(result.filter);
214 callback(errors); 214 callback(errors);
215 break; 215 break;
216 case "filters.blocked": 216 case "filters.blocked":
217 var filter = defaultMatcher.matchesAny(message.url, 217 var filter = defaultMatcher.matchesAny(message.url,
218 RegExpFilter.typeMap[message.requestType], message.docDomain, 218 RegExpFilter.typeMap[message.requestType], message.docDomain,
219 message.thirdParty); 219 message.thirdParty);
220 callback(filter instanceof BlockingFilter); 220 callback(filter instanceof BlockingFilter);
221 break; 221 break;
222 case "filters.get": 222 case "filters.get":
223 if (message.what == "cssproperties") 223 if (message.what == "elemhideemulation")
224 { 224 {
225 var filters = []; 225 var filters = [];
226 var checkWhitelisted = require("whitelisting").checkWhitelisted; 226 var checkWhitelisted = require("whitelisting").checkWhitelisted;
227 227
228 if (Prefs.enabled && !checkWhitelisted(sender.page, sender.frame, 228 if (Prefs.enabled && !checkWhitelisted(sender.page, sender.frame,
229 RegExpFilter.typeMap.DOCUMENT | 229 RegExpFilter.typeMap.DOCUMENT |
230 RegExpFilter.typeMap.ELEMHIDE)) 230 RegExpFilter.typeMap.ELEMHIDE))
231 { 231 {
232 filters = CSSRules.getRulesForDomain(sender.frame.url.hostname); 232 var hostname = sender.frame.url.hostname;
233 filters = ElemHideEmulation.getRulesForDomain(hostname);
233 filters = filters.map(function(filter) 234 filters = filters.map(function(filter)
234 { 235 {
235 return { 236 return {
236 prefix: filter.selectorPrefix, 237 selector: filter.selector,
237 suffix: filter.selectorSuffix,
238 regexp: filter.regexpString,
239 text: filter.text 238 text: filter.text
240 }; 239 };
241 }); 240 });
242 } 241 }
243 callback(filters); 242 callback(filters);
244 break; 243 break;
245 } 244 }
246 245
247 var subscription = Subscription.fromURL(message.subscriptionUrl); 246 var subscription = Subscription.fromURL(message.subscriptionUrl);
248 if (!subscription) 247 if (!subscription)
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 for (var i = 0; i < subscriptions.length; i++) 402 for (var i = 0; i < subscriptions.length; i++)
404 { 403 {
405 var subscription = subscriptions[i]; 404 var subscription = subscriptions[i];
406 if (subscription instanceof DownloadableSubscription) 405 if (subscription instanceof DownloadableSubscription)
407 Synchronizer.execute(subscription, true); 406 Synchronizer.execute(subscription, true);
408 } 407 }
409 break; 408 break;
410 } 409 }
411 }); 410 });
412 })(this); 411 })(this);
OLDNEW
« no previous file with comments | « background.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld