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: Wrap long line Created Nov. 4, 2016, 5:37 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
« background.js ('K') | « 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 features: filter.features,
237 suffix: filter.selectorSuffix, 238 selector: filter.selector,
238 regexp: filter.regexpString,
239 text: filter.text 239 text: filter.text
240 }; 240 };
241 }); 241 });
242 } 242 }
243 callback(filters); 243 callback(filters);
244 break; 244 break;
245 } 245 }
246 246
247 var subscription = Subscription.fromURL(message.subscriptionUrl); 247 var subscription = Subscription.fromURL(message.subscriptionUrl);
248 if (!subscription) 248 if (!subscription)
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 for (var i = 0; i < subscriptions.length; i++) 403 for (var i = 0; i < subscriptions.length; i++)
404 { 404 {
405 var subscription = subscriptions[i]; 405 var subscription = subscriptions[i];
406 if (subscription instanceof DownloadableSubscription) 406 if (subscription instanceof DownloadableSubscription)
407 Synchronizer.execute(subscription, true); 407 Synchronizer.execute(subscription, true);
408 } 408 }
409 break; 409 break;
410 } 410 }
411 }); 411 });
412 })(this); 412 })(this);
OLDNEW
« background.js ('K') | « background.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld