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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 |
(...skipping 24 matching lines...) Expand all Loading... | |
35 const {Filter, BlockingFilter, RegExpFilter} = require("filterClasses"); | 35 const {Filter, BlockingFilter, RegExpFilter} = require("filterClasses"); |
36 const {Synchronizer} = require("synchronizer"); | 36 const {Synchronizer} = require("synchronizer"); |
37 | 37 |
38 const info = require("info"); | 38 const info = require("info"); |
39 const { | 39 const { |
40 Subscription, | 40 Subscription, |
41 DownloadableSubscription, | 41 DownloadableSubscription, |
42 SpecialSubscription | 42 SpecialSubscription |
43 } = require("subscriptionClasses"); | 43 } = require("subscriptionClasses"); |
44 | 44 |
45 // Some modules doesn't exist on Firefox. Moreover, | 45 port.on("types.get", (message, sender) => |
46 // require() throws an exception on Firefox in that case. | 46 { |
47 // However, try/catch causes the whole function to to be | 47 let filterTypes = Array.from(require("requestBlocker").filterTypes); |
48 // deoptimized on V8. So we wrap it into another function. | 48 filterTypes.push(...filterTypes.splice(filterTypes.indexOf("OTHER"), 1)); |
49 function tryRequire(module) | 49 return filterTypes; |
50 { | 50 }); |
51 try | |
52 { | |
53 return require(module); | |
54 } | |
55 catch (e) | |
56 { | |
57 return null; | |
58 } | |
59 } | |
60 | 51 |
61 function convertObject(keys, obj) | 52 function convertObject(keys, obj) |
62 { | 53 { |
63 let result = {}; | 54 let result = {}; |
64 for (let key of keys) | 55 for (let key of keys) |
65 { | 56 { |
66 if (key in obj) | 57 if (key in obj) |
67 result[key] = obj[key]; | 58 result[key] = obj[key]; |
68 } | 59 } |
69 return result; | 60 return result; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
152 listenerFilters = Object.create(null); | 143 listenerFilters = Object.create(null); |
153 changeListeners.set(page, listenerFilters); | 144 changeListeners.set(page, listenerFilters); |
154 } | 145 } |
155 return listenerFilters; | 146 return listenerFilters; |
156 } | 147 } |
157 | 148 |
158 port.on("app.get", (message, sender) => | 149 port.on("app.get", (message, sender) => |
159 { | 150 { |
160 if (message.what == "issues") | 151 if (message.what == "issues") |
161 { | 152 { |
162 let subscriptionInit = tryRequire("subscriptionInit"); | 153 let subscriptionInit = require("subscriptionInit"); |
163 let result = subscriptionInit ? subscriptionInit.reinitialized : false; | 154 let result = subscriptionInit ? subscriptionInit.reinitialized : false; |
164 return {filterlistsReinitialized: result}; | 155 return {filterlistsReinitialized: result}; |
165 } | 156 } |
166 | 157 |
167 if (message.what == "doclink") | 158 if (message.what == "doclink") |
168 return Utils.getDocLink(message.link); | 159 return Utils.getDocLink(message.link); |
169 | 160 |
170 if (message.what == "localeInfo") | 161 if (message.what == "localeInfo") |
171 { | 162 { |
172 let bidiDir; | 163 let bidiDir; |
173 if ("chromeRegistry" in Utils) | 164 if ("chromeRegistry" in Utils) |
174 { | 165 { |
175 let isRtl = Utils.chromeRegistry.isLocaleRTL("adblockplus"); | 166 let isRtl = Utils.chromeRegistry.isLocaleRTL("adblockplus"); |
176 bidiDir = isRtl ? "rtl" : "ltr"; | 167 bidiDir = isRtl ? "rtl" : "ltr"; |
177 } | 168 } |
178 else | 169 else |
179 bidiDir = Utils.readingDirection; | 170 bidiDir = Utils.readingDirection; |
180 | 171 |
181 return {locale: Utils.appLocale, bidiDir}; | 172 return {locale: Utils.appLocale, bidiDir}; |
182 } | 173 } |
183 | 174 |
184 if (message.what == "features") | 175 if (message.what == "features") |
185 { | 176 { |
186 return { | 177 return { |
187 devToolsPanel: info.platform == "chromium" || | 178 devToolsPanel: info.platform == "chromium" || |
188 info.application == "firefox" && | 179 info.application == "firefox" && |
Sebastian Noack
2017/09/14 23:30:49
I explicitly check for `application == "firefox" h
Manish Jethani
2017/09/15 11:37:14
Acknowledged.
Manish Jethani
2017/09/15 11:37:14
We'll have to use parseInt here since the applicat
Thomas Greiner
2017/09/15 12:20:04
Well spotted. Note that we usually use `Services.v
Sebastian Noack
2017/09/15 16:51:47
Done.
| |
189 info.applicationVersion >= 54 | 180 parseInt(info.applicationVersion, 10) >= 54 |
190 }; | 181 }; |
191 } | 182 } |
192 | 183 |
193 return info[message.what]; | 184 return info[message.what]; |
194 }); | 185 }); |
195 | 186 |
196 port.on("app.listen", (message, sender) => | 187 port.on("app.listen", (message, sender) => |
197 { | 188 { |
198 getListenerFilters(sender.page).app = message.filter; | 189 getListenerFilters(sender.page).app = message.filter; |
199 }); | 190 }); |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
436 if (message.url) | 427 if (message.url) |
437 subscriptions = [Subscription.fromURL(message.url)]; | 428 subscriptions = [Subscription.fromURL(message.url)]; |
438 | 429 |
439 for (let subscription of subscriptions) | 430 for (let subscription of subscriptions) |
440 { | 431 { |
441 if (subscription instanceof DownloadableSubscription) | 432 if (subscription instanceof DownloadableSubscription) |
442 Synchronizer.execute(subscription, true); | 433 Synchronizer.execute(subscription, true); |
443 } | 434 } |
444 }); | 435 }); |
445 })(this); | 436 })(this); |
LEFT | RIGHT |