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: Rebase Created Sept. 15, 2017, 4:51 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
(...skipping 24 matching lines...) Expand all
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 const {Services} = Cu.import("resource://gre/modules/Services.jsm"); 45 port.on("types.get", (message, sender) =>
46 46 {
47 // Some modules doesn't exist on Firefox. Moreover, 47 let filterTypes = Array.from(require("requestBlocker").filterTypes);
48 // require() throws an exception on Firefox in that case. 48 filterTypes.push(...filterTypes.splice(filterTypes.indexOf("OTHER"), 1));
49 // However, try/catch causes the whole function to to be 49 return filterTypes;
50 // deoptimized on V8. So we wrap it into another function. 50 });
51 function tryRequire(module)
52 {
53 try
54 {
55 return require(module);
56 }
57 catch (e)
58 {
59 return null;
60 }
61 }
62 51
63 function convertObject(keys, obj) 52 function convertObject(keys, obj)
64 { 53 {
65 let result = {}; 54 let result = {};
66 for (let key of keys) 55 for (let key of keys)
67 { 56 {
68 if (key in obj) 57 if (key in obj)
69 result[key] = obj[key]; 58 result[key] = obj[key];
70 } 59 }
71 return result; 60 return result;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 listenerFilters = Object.create(null); 143 listenerFilters = Object.create(null);
155 changeListeners.set(page, listenerFilters); 144 changeListeners.set(page, listenerFilters);
156 } 145 }
157 return listenerFilters; 146 return listenerFilters;
158 } 147 }
159 148
160 port.on("app.get", (message, sender) => 149 port.on("app.get", (message, sender) =>
161 { 150 {
162 if (message.what == "issues") 151 if (message.what == "issues")
163 { 152 {
164 let subscriptionInit = tryRequire("subscriptionInit"); 153 let subscriptionInit = require("subscriptionInit");
165 let result = subscriptionInit ? subscriptionInit.reinitialized : false; 154 let result = subscriptionInit ? subscriptionInit.reinitialized : false;
166 return {filterlistsReinitialized: result}; 155 return {filterlistsReinitialized: result};
167 } 156 }
168 157
169 if (message.what == "doclink") 158 if (message.what == "doclink")
170 return Utils.getDocLink(message.link); 159 return Utils.getDocLink(message.link);
171 160
172 if (message.what == "localeInfo") 161 if (message.what == "localeInfo")
173 { 162 {
174 let bidiDir; 163 let bidiDir;
175 if ("chromeRegistry" in Utils) 164 if ("chromeRegistry" in Utils)
176 { 165 {
177 let isRtl = Utils.chromeRegistry.isLocaleRTL("adblockplus"); 166 let isRtl = Utils.chromeRegistry.isLocaleRTL("adblockplus");
178 bidiDir = isRtl ? "rtl" : "ltr"; 167 bidiDir = isRtl ? "rtl" : "ltr";
179 } 168 }
180 else 169 else
181 bidiDir = Utils.readingDirection; 170 bidiDir = Utils.readingDirection;
182 171
183 return {locale: Utils.appLocale, bidiDir}; 172 return {locale: Utils.appLocale, bidiDir};
184 } 173 }
185 174
186 if (message.what == "features") 175 if (message.what == "features")
187 { 176 {
188 return { 177 return {
189 devToolsPanel: info.platform == "chromium" || 178 devToolsPanel: info.platform == "chromium" ||
190 info.application == "firefox" && 179 info.application == "firefox" &&
191 Services.vc.compare(info.applicationVersion, "54") >= 0 180 parseInt(info.applicationVersion, 10) >= 54
192 }; 181 };
193 } 182 }
194 183
195 return info[message.what]; 184 return info[message.what];
196 }); 185 });
197 186
198 port.on("app.listen", (message, sender) => 187 port.on("app.listen", (message, sender) =>
199 { 188 {
200 getListenerFilters(sender.page).app = message.filter; 189 getListenerFilters(sender.page).app = message.filter;
201 }); 190 });
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 if (message.url) 427 if (message.url)
439 subscriptions = [Subscription.fromURL(message.url)]; 428 subscriptions = [Subscription.fromURL(message.url)];
440 429
441 for (let subscription of subscriptions) 430 for (let subscription of subscriptions)
442 { 431 {
443 if (subscription instanceof DownloadableSubscription) 432 if (subscription instanceof DownloadableSubscription)
444 Synchronizer.execute(subscription, true); 433 Synchronizer.execute(subscription, true);
445 } 434 }
446 }); 435 });
447 })(this); 436 })(this);
LEFTRIGHT

Powered by Google App Engine
This is Rietveld