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

Delta Between Two Patch Sets: lib/options.js

Issue 29782593: Noissue - Don't hard-code options and popup URL (Closed)
Left Patch Set: Created May 15, 2018, 1:22 p.m.
Right Patch Set: Use "" instead of null for compatiblity with older Firefox versions Created May 15, 2018, 2:19 p.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 | metadata.gecko » ('j') | 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 /** @module options */ 18 /** @module options */
19 19
20 "use strict"; 20 "use strict";
21 21
22 const {checkWhitelisted} = require("./whitelisting"); 22 const {checkWhitelisted} = require("./whitelisting");
23 const info = require("../buildtools/info"); 23 const info = require("../buildtools/info");
24 24
25 const manifest = browser.runtime.getManifest(); 25 const manifest = browser.runtime.getManifest();
26 const optionsUrl = manifest.options_page || manifest.options_ui.page; 26 const optionsUrl = manifest.options_page || manifest.options_ui.page;
kzar 2018/05/15 13:32:31 I trust you got it right, but i wonder where manif
Sebastian Noack 2018/05/15 14:17:15 That is correct, but there is also Microsoft Edge
27 const popupUrl = manifest.browser_action.default_popup;
kzar 2018/05/15 13:32:31 I don't see this one for gecko.
Sebastian Noack 2018/05/15 14:17:15 Argh, right. We removed the popup URL from the man
28 27
29 function findOptionsTab(callback) 28 function findOptionsTab(callback)
30 { 29 {
31 browser.tabs.query({}, tabs => 30 browser.tabs.query({}, tabs =>
32 { 31 {
33 // We find a tab ourselves because Edge has a bug when quering tabs with 32 // We find a tab ourselves because Edge has a bug when quering tabs with
34 // extension URL protocol: 33 // extension URL protocol:
35 // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8094 141/ 34 // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8094 141/
36 // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8604 703/ 35 // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8604 703/
37 // Firefox won't let us query for moz-extension:// pages either, though 36 // Firefox won't let us query for moz-extension:// pages either, though
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 // We need to clear the popup URL on Firefox for Android in order for the 180 // We need to clear the popup URL on Firefox for Android in order for the
182 // options page to open instead of the bubble. Unfortunately there's a bug[1] 181 // options page to open instead of the bubble. Unfortunately there's a bug[1]
183 // which prevents us from doing that, so we must avoid setting the URL on 182 // which prevents us from doing that, so we must avoid setting the URL on
184 // Firefox from the manifest at all, instead setting it here only for 183 // Firefox from the manifest at all, instead setting it here only for
185 // non-mobile. 184 // non-mobile.
186 // [1] - https://bugzilla.mozilla.org/show_bug.cgi?id=1414613 185 // [1] - https://bugzilla.mozilla.org/show_bug.cgi?id=1414613
187 if ("getBrowserInfo" in browser.runtime) 186 if ("getBrowserInfo" in browser.runtime)
188 { 187 {
189 browser.runtime.getBrowserInfo().then(browserInfo => 188 browser.runtime.getBrowserInfo().then(browserInfo =>
190 { 189 {
191 if (browserInfo.name != "Fennec") 190 if (browserInfo.name == "Fennec")
192 browser.browserAction.setPopup({popup: popupUrl}); 191 browser.browserAction.setPopup({popup: ""});
193 }); 192 });
194 }
195 else
196 {
197 browser.browserAction.setPopup({popup: popupUrl});
198 } 193 }
199 194
200 // On Firefox for Android, open the options page directly when the browser 195 // On Firefox for Android, open the options page directly when the browser
201 // action is clicked. 196 // action is clicked.
202 browser.browserAction.onClicked.addListener(() => 197 browser.browserAction.onClicked.addListener(() =>
203 { 198 {
204 browser.tabs.query({active: true, lastFocusedWindow: true}, ([tab]) => 199 browser.tabs.query({active: true, lastFocusedWindow: true}, ([tab]) =>
205 { 200 {
206 let currentPage = new ext.Page(tab); 201 let currentPage = new ext.Page(tab);
207 202
208 showOptions((optionsPage, port) => 203 showOptions((optionsPage, port) =>
209 { 204 {
210 if (!/^https?:$/.test(currentPage.url.protocol)) 205 if (!/^https?:$/.test(currentPage.url.protocol))
211 return; 206 return;
212 207
213 port.postMessage({ 208 port.postMessage({
214 type: "app.respond", 209 type: "app.respond",
215 action: "showPageOptions", 210 action: "showPageOptions",
216 args: [ 211 args: [
217 { 212 {
218 host: currentPage.url.hostname.replace(/^www\./, ""), 213 host: currentPage.url.hostname.replace(/^www\./, ""),
219 whitelisted: !!checkWhitelisted(currentPage) 214 whitelisted: !!checkWhitelisted(currentPage)
220 } 215 }
221 ] 216 ]
222 }); 217 });
223 }); 218 });
224 }); 219 });
225 }); 220 });
LEFTRIGHT
« no previous file | metadata.gecko » ('j') | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld