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

Delta Between Two Patch Sets: messageResponder.js

Issue 29370999: Issue 4783 - Use modern JavaScript syntax for the messageResponder (Closed)
Left Patch Set: Use destructuring + const, fix typo Created Jan. 18, 2017, 5:48 a.m.
Right Patch Set: Addressed further feedback Created Jan. 18, 2017, 11:51 a.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 | « no previous file | 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-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 "use strict"; 18 "use strict";
19 19
20 { 20 {
21 var ext = ext || require("ext_background"); 21 var ext = ext || require("ext_background");
22 22
23 const {port} = require("messaging"); 23 const {port} = require("messaging");
24 const {Prefs} = require("prefs"); 24 const {Prefs} = require("prefs");
25 const {Utils} = require("utils"); 25 const {Utils} = require("utils");
26 const {FilterStorage} = require("filterStorage"); 26 const {FilterStorage} = require("filterStorage");
27 const {FilterNotifier} = require("filterNotifier"); 27 const {FilterNotifier} = require("filterNotifier");
28 const {defaultMatcher} = require("matcher"); 28 const {defaultMatcher} = require("matcher");
29 const {ElemHideEmulation} = require("elemHideEmulation"); 29 const {ElemHideEmulation} = require("elemHideEmulation");
30 const {NotificationStorage} = require("notification"); 30 const {Notification: NotificationStorage} = require("notification");
Thomas Greiner 2017/01/18 11:40:09 This doesn't work. What you'd want to do is: cons
kzar 2017/01/18 11:54:41 Done.
31 31
32 const {Filter, BlockingFilter, RegExpFilter} = require("filterClasses"); 32 const {Filter, BlockingFilter, RegExpFilter} = require("filterClasses");
33 const {Synchronizer} = require("synchronizer"); 33 const {Synchronizer} = require("synchronizer");
34 34
35 const info = require("info"); 35 const info = require("info");
36 const {Subscription, 36 const {Subscription,
37 DownloadableSubscription, 37 DownloadableSubscription,
38 SpecialSubscription} = require("subscriptionClasses"); 38 SpecialSubscription} = require("subscriptionClasses");
39 39
40 // Some modules doesn't exist on Firefox. Moreover, 40 // Some modules doesn't exist on Firefox. Moreover,
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 { 131 {
132 listenedFilterChanges[name] = null; 132 listenedFilterChanges[name] = null;
133 FilterNotifier.on(name, function() 133 FilterNotifier.on(name, function()
134 { 134 {
135 let args = [type, action]; 135 let args = [type, action];
136 for (let arg of arguments) 136 for (let arg of arguments)
137 args.push(arg); 137 args.push(arg);
138 sendMessage.apply(null, args); 138 sendMessage.apply(null, args);
139 }); 139 });
140 } 140 }
141 }; 141 }
Thomas Greiner 2017/01/18 11:40:09 Detail: This semicolon is still left over from you
kzar 2017/01/18 11:54:41 Whoops, Done.
142 } 142 }
143 143
144 function getListenerFilters(page) 144 function getListenerFilters(page)
145 { 145 {
146 let listenerFilters = changeListeners.get(page); 146 let listenerFilters = changeListeners.get(page);
147 if (!listenerFilters) 147 if (!listenerFilters)
148 { 148 {
149 listenerFilters = Object.create(null); 149 listenerFilters = Object.create(null);
150 changeListeners.set(page, listenerFilters); 150 changeListeners.set(page, listenerFilters);
151 } 151 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 { 229 {
230 if (message.what == "elemhideemulation") 230 if (message.what == "elemhideemulation")
231 { 231 {
232 let filters = []; 232 let filters = [];
233 const {checkWhitelisted} = require("whitelisting"); 233 const {checkWhitelisted} = require("whitelisting");
234 234
235 if (Prefs.enabled && !checkWhitelisted(sender.page, sender.frame, 235 if (Prefs.enabled && !checkWhitelisted(sender.page, sender.frame,
236 RegExpFilter.typeMap.DOCUMENT | 236 RegExpFilter.typeMap.DOCUMENT |
237 RegExpFilter.typeMap.ELEMHIDE)) 237 RegExpFilter.typeMap.ELEMHIDE))
238 { 238 {
239 const hostname = sender.frame.url.hostname; 239 let hostname = sender.frame.url.hostname;
Thomas Greiner 2017/01/18 11:40:09 Detail: I don't see a compelling enough use-case f
kzar 2017/01/18 11:54:41 Done.
240 filters = ElemHideEmulation.getRulesForDomain(hostname); 240 filters = ElemHideEmulation.getRulesForDomain(hostname);
241 filters = filters.map(filter => 241 filters = filters.map(filter =>
242 { 242 {
243 return { 243 return {
244 selector: filter.selector, 244 selector: filter.selector,
245 text: filter.text 245 text: filter.text
246 }; 246 };
247 }); 247 });
248 } 248 }
249 return filters; 249 return filters;
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 { 425 {
426 let subscriptions = message.url ? [Subscription.fromURL(message.url)] : 426 let subscriptions = message.url ? [Subscription.fromURL(message.url)] :
427 FilterStorage.subscriptions; 427 FilterStorage.subscriptions;
428 for (let subscription of subscriptions) 428 for (let subscription of subscriptions)
429 { 429 {
430 if (subscription instanceof DownloadableSubscription) 430 if (subscription instanceof DownloadableSubscription)
431 Synchronizer.execute(subscription, true); 431 Synchronizer.execute(subscription, true);
432 } 432 }
433 }); 433 });
434 } 434 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld