Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 if (typeof ext == "undefined") | 21 if (typeof ext == "undefined") |
kzar
2017/02/08 08:39:24
(This change is required since we'll be using `let
| |
22 window.ext = require("ext_background"); | 22 window.ext = require("ext_background"); |
23 | 23 |
24 const {port} = require("messaging"); | 24 const {port} = require("messaging"); |
25 const {Prefs} = require("prefs"); | 25 const {Prefs} = require("prefs"); |
26 const {Utils} = require("utils"); | 26 const {Utils} = require("utils"); |
27 const {FilterStorage} = require("filterStorage"); | 27 const {FilterStorage} = require("filterStorage"); |
28 const {FilterNotifier} = require("filterNotifier"); | 28 const {FilterNotifier} = require("filterNotifier"); |
29 const {defaultMatcher} = require("matcher"); | 29 const {defaultMatcher} = require("matcher"); |
30 const {ElemHideEmulation} = require("elemHideEmulation"); | 30 const {ElemHideEmulation} = require("elemHideEmulation"); |
31 const {Notification: NotificationStorage} = require("notification"); | 31 const {Notification: NotificationStorage} = require("notification"); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 pref: "prefs.respond", | 84 pref: "prefs.respond", |
85 subscription: "subscriptions.respond" | 85 subscription: "subscriptions.respond" |
86 }; | 86 }; |
87 | 87 |
88 function sendMessage(type, action, ...args) | 88 function sendMessage(type, action, ...args) |
89 { | 89 { |
90 let pages = changeListeners.keys(); | 90 let pages = changeListeners.keys(); |
91 if (pages.length == 0) | 91 if (pages.length == 0) |
92 return; | 92 return; |
93 | 93 |
94 for (let i = 0; i < args.length; i++) | 94 for (let i = 0; i < args.length; i++) |
Thomas Greiner
2017/02/08 10:11:09
Why not use a for-of loop instead to simplify the
kzar
2017/02/08 10:27:24
Since we need to replace some arguments in place.
Thomas Greiner
2017/02/08 10:37:26
Ah, don't know how I overlooked that. :p You're of
| |
95 { | 95 { |
96 let arg = args[i]; | 96 let arg = args[i]; |
97 if (arg instanceof Subscription) | 97 if (arg instanceof Subscription) |
98 args[i] = convertSubscription(arg); | 98 args[i] = convertSubscription(arg); |
99 else if (arg instanceof Filter) | 99 else if (arg instanceof Filter) |
100 args[i] = convertFilter(arg); | 100 args[i] = convertFilter(arg); |
101 } | 101 } |
102 | 102 |
103 for (let page of pages) | 103 for (let page of pages) |
104 { | 104 { |
(...skipping 18 matching lines...) Expand all Loading... | |
123 if (type == "filter" && action == "loaded") | 123 if (type == "filter" && action == "loaded") |
124 name = "load"; | 124 name = "load"; |
125 else | 125 else |
126 name = type + "." + action; | 126 name = type + "." + action; |
127 | 127 |
128 if (!(name in listenedFilterChanges)) | 128 if (!(name in listenedFilterChanges)) |
129 { | 129 { |
130 listenedFilterChanges[name] = null; | 130 listenedFilterChanges[name] = null; |
131 FilterNotifier.on(name, () => | 131 FilterNotifier.on(name, () => |
132 { | 132 { |
133 sendMessage(...[type, action].concat(args)); | 133 sendMessage(type, action, ...args); |
Thomas Greiner
2017/02/08 10:11:09
Looks like a more complicated way of writing `send
kzar
2017/02/08 10:27:24
Good point, Done.
| |
134 }); | 134 }); |
135 } | 135 } |
136 } | 136 } |
137 } | 137 } |
138 | 138 |
139 function getListenerFilters(page) | 139 function getListenerFilters(page) |
140 { | 140 { |
141 let listenerFilters = changeListeners.get(page); | 141 let listenerFilters = changeListeners.get(page); |
142 if (!listenerFilters) | 142 if (!listenerFilters) |
143 { | 143 { |
(...skipping 15 matching lines...) Expand all Loading... | |
159 } | 159 } |
160 | 160 |
161 if (message.what == "doclink") | 161 if (message.what == "doclink") |
162 return Utils.getDocLink(message.link); | 162 return Utils.getDocLink(message.link); |
163 | 163 |
164 if (message.what == "localeInfo") | 164 if (message.what == "localeInfo") |
165 { | 165 { |
166 let bidiDir; | 166 let bidiDir; |
167 if ("chromeRegistry" in Utils) | 167 if ("chromeRegistry" in Utils) |
168 { | 168 { |
169 let rtl = Utils.chromeRegistry.isLocaleRTL("adblockplus"); | 169 let isRtl = Utils.chromeRegistry.isLocaleRTL("adblockplus"); |
Thomas Greiner
2017/02/08 10:11:09
Detail: It'd be great if the variable name would r
kzar
2017/02/08 10:27:24
Done.
| |
170 bidiDir = rtl ? "rtl" : "ltr"; | 170 bidiDir = isRtl ? "rtl" : "ltr"; |
171 } | 171 } |
172 else | 172 else |
173 { | 173 { |
174 bidiDir = ext.i18n.getMessage("@@bidi_dir"); | 174 bidiDir = ext.i18n.getMessage("@@bidi_dir"); |
175 } | 175 } |
176 | 176 |
177 return {locale: Utils.appLocale, bidiDir}; | 177 return {locale: Utils.appLocale, bidiDir}; |
178 } | 178 } |
179 | 179 |
180 if (message.what == "features") | 180 if (message.what == "features") |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
420 { | 420 { |
421 let subscriptions = message.url ? [Subscription.fromURL(message.url)] | 421 let subscriptions = message.url ? [Subscription.fromURL(message.url)] |
422 : FilterStorage.subscriptions; | 422 : FilterStorage.subscriptions; |
423 for (let subscription of subscriptions) | 423 for (let subscription of subscriptions) |
424 { | 424 { |
425 if (subscription instanceof DownloadableSubscription) | 425 if (subscription instanceof DownloadableSubscription) |
426 Synchronizer.execute(subscription, true); | 426 Synchronizer.execute(subscription, true); |
427 } | 427 } |
428 }); | 428 }); |
429 } | 429 } |
LEFT | RIGHT |