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

Delta Between Two Patch Sets: messageResponder.js

Issue 29544706: Noissue - Adapt check for devtools panel support for Firefox (Closed)
Left Patch Set: Use compareVersion from coreUtils Created Sept. 18, 2017, 6:20 p.m.
Right Patch Set: Use parseInt() Created Sept. 23, 2017, 12:42 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 | « background.js ('k') | 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-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
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 /* globals require */ 18 /* globals require */
19 19
20 "use strict"; 20 "use strict";
21 21
22 (function(global) 22 (function(global)
23 { 23 {
24 let ext = global.ext || require("ext_background"); 24 let ext = global.ext || require("ext_background");
25 25
26 const {port} = require("messaging"); 26 const {port} = require("messaging");
27 const {Prefs} = require("prefs"); 27 const {Prefs} = require("prefs");
28 const {compareVersion} = require("coreUtils");
29 const {Utils} = require("utils"); 28 const {Utils} = require("utils");
30 const {FilterStorage} = require("filterStorage"); 29 const {FilterStorage} = require("filterStorage");
31 const {FilterNotifier} = require("filterNotifier"); 30 const {FilterNotifier} = require("filterNotifier");
32 const {defaultMatcher} = require("matcher"); 31 const {defaultMatcher} = require("matcher");
33 const {ElemHideEmulation} = require("elemHideEmulation"); 32 const {ElemHideEmulation} = require("elemHideEmulation");
34 const {Notification: NotificationStorage} = require("notification"); 33 const {Notification: NotificationStorage} = require("notification");
35 34
36 const {Filter, BlockingFilter, RegExpFilter} = require("filterClasses"); 35 const {Filter, BlockingFilter, RegExpFilter} = require("filterClasses");
37 const {Synchronizer} = require("synchronizer"); 36 const {Synchronizer} = require("synchronizer");
38 37
39 const info = require("info"); 38 const info = require("info");
40 const { 39 const {
41 Subscription, 40 Subscription,
42 DownloadableSubscription, 41 DownloadableSubscription,
43 SpecialSubscription 42 SpecialSubscription
44 } = require("subscriptionClasses"); 43 } = require("subscriptionClasses");
45 44
46 // Some modules doesn't exist on Firefox. Moreover, 45 port.on("types.get", (message, sender) =>
47 // require() throws an exception on Firefox in that case. 46 {
48 // However, try/catch causes the whole function to to be 47 let filterTypes = Array.from(require("requestBlocker").filterTypes);
49 // deoptimized on V8. So we wrap it into another function. 48 filterTypes.push(...filterTypes.splice(filterTypes.indexOf("OTHER"), 1));
50 function tryRequire(module) 49 return filterTypes;
51 { 50 });
52 try
53 {
54 return require(module);
55 }
56 catch (e)
57 {
58 return null;
59 }
60 }
61 51
62 function convertObject(keys, obj) 52 function convertObject(keys, obj)
63 { 53 {
64 let result = {}; 54 let result = {};
65 for (let key of keys) 55 for (let key of keys)
66 { 56 {
67 if (key in obj) 57 if (key in obj)
68 result[key] = obj[key]; 58 result[key] = obj[key];
69 } 59 }
70 return result; 60 return result;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 listenerFilters = Object.create(null); 143 listenerFilters = Object.create(null);
154 changeListeners.set(page, listenerFilters); 144 changeListeners.set(page, listenerFilters);
155 } 145 }
156 return listenerFilters; 146 return listenerFilters;
157 } 147 }
158 148
159 port.on("app.get", (message, sender) => 149 port.on("app.get", (message, sender) =>
160 { 150 {
161 if (message.what == "issues") 151 if (message.what == "issues")
162 { 152 {
163 let subscriptionInit = tryRequire("subscriptionInit"); 153 let subscriptionInit = require("subscriptionInit");
164 let result = subscriptionInit ? subscriptionInit.reinitialized : false; 154 let result = subscriptionInit ? subscriptionInit.reinitialized : false;
165 return {filterlistsReinitialized: result}; 155 return {filterlistsReinitialized: result};
166 } 156 }
167 157
168 if (message.what == "doclink") 158 if (message.what == "doclink")
169 return Utils.getDocLink(message.link); 159 return Utils.getDocLink(message.link);
170 160
171 if (message.what == "localeInfo") 161 if (message.what == "localeInfo")
172 { 162 {
173 let bidiDir; 163 let bidiDir;
174 if ("chromeRegistry" in Utils) 164 if ("chromeRegistry" in Utils)
175 { 165 {
176 let isRtl = Utils.chromeRegistry.isLocaleRTL("adblockplus"); 166 let isRtl = Utils.chromeRegistry.isLocaleRTL("adblockplus");
177 bidiDir = isRtl ? "rtl" : "ltr"; 167 bidiDir = isRtl ? "rtl" : "ltr";
178 } 168 }
179 else 169 else
180 bidiDir = Utils.readingDirection; 170 bidiDir = Utils.readingDirection;
181 171
182 return {locale: Utils.appLocale, bidiDir}; 172 return {locale: Utils.appLocale, bidiDir};
183 } 173 }
184 174
185 if (message.what == "features") 175 if (message.what == "features")
186 { 176 {
187 return { 177 return {
188 devToolsPanel: info.platform == "chromium" || 178 devToolsPanel: info.platform == "chromium" ||
189 info.application == "firefox" && 179 info.application == "firefox" &&
190 compareVersion(info.applicationVersion, "54") >= 0 180 parseInt(info.applicationVersion, 10) >= 54
191 }; 181 };
192 } 182 }
193 183
194 return info[message.what]; 184 return info[message.what];
195 }); 185 });
196 186
197 port.on("app.listen", (message, sender) => 187 port.on("app.listen", (message, sender) =>
198 { 188 {
199 getListenerFilters(sender.page).app = message.filter; 189 getListenerFilters(sender.page).app = message.filter;
200 }); 190 });
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 if (message.url) 427 if (message.url)
438 subscriptions = [Subscription.fromURL(message.url)]; 428 subscriptions = [Subscription.fromURL(message.url)];
439 429
440 for (let subscription of subscriptions) 430 for (let subscription of subscriptions)
441 { 431 {
442 if (subscription instanceof DownloadableSubscription) 432 if (subscription instanceof DownloadableSubscription)
443 Synchronizer.execute(subscription, true); 433 Synchronizer.execute(subscription, true);
444 } 434 }
445 }); 435 });
446 })(this); 436 })(this);
LEFTRIGHT

Powered by Google App Engine
This is Rietveld