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

Delta Between Two Patch Sets: lib/options.js

Issue 29597555: Issue 5977 - Set popup programmatically on Firefox (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Left Patch Set: Revert changes to polyfill.js Created Nov. 6, 2017, 2:16 p.m.
Right Patch Set: Update buildtools dependency Created Nov. 17, 2017, 3:08 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 | « dependencies ('k') | 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
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 } 123 }
124 }); 124 });
125 }; 125 };
126 126
127 // We need to clear the popup URL on Firefox for Android in order for the 127 // We need to clear the popup URL on Firefox for Android in order for the
128 // options page to open instead of the bubble. Unfortunately there's a bug[1] 128 // options page to open instead of the bubble. Unfortunately there's a bug[1]
129 // which prevents us from doing that, so we must avoid setting the URL on 129 // which prevents us from doing that, so we must avoid setting the URL on
130 // Firefox from the manifest at all, instead setting it here only for 130 // Firefox from the manifest at all, instead setting it here only for
131 // non-mobile. 131 // non-mobile.
132 // [1] - https://bugzilla.mozilla.org/show_bug.cgi?id=1414613 132 // [1] - https://bugzilla.mozilla.org/show_bug.cgi?id=1414613
133 if (info.application == "firefox") 133 if ("getBrowserInfo" in browser.runtime)
134 {
135 browser.browserAction.setPopup({popup: "popup.html"});
136 }
137 else if (info.platform == "gecko")
138 { 134 {
139 browser.runtime.getBrowserInfo().then(browserInfo => 135 browser.runtime.getBrowserInfo().then(browserInfo =>
140 { 136 {
141 if (browserInfo.name != "Fennec") 137 if (browserInfo.name != "Fennec")
142 browser.browserAction.setPopup({popup: "popup.html"}); 138 browser.browserAction.setPopup({popup: "popup.html"});
143 }); 139 });
140 }
141 else
142 {
143 browser.browserAction.setPopup({popup: "popup.html"});
144 } 144 }
Wladimir Palant 2017/11/06 15:04:31 If we are choosing that approach, I wonder whether
Manish Jethani 2017/11/13 10:42:13 I was hoping to restrict this to Gecko only to avo
145 145
146 // On Firefox for Android, open the options page directly when the browser 146 // On Firefox for Android, open the options page directly when the browser
147 // action is clicked. 147 // action is clicked.
148 browser.browserAction.onClicked.addListener(() => 148 browser.browserAction.onClicked.addListener(() =>
149 { 149 {
150 browser.tabs.query({active: true, lastFocusedWindow: true}, ([tab]) => 150 browser.tabs.query({active: true, lastFocusedWindow: true}, ([tab]) =>
151 { 151 {
152 let currentPage = new ext.Page(tab); 152 let currentPage = new ext.Page(tab);
153 153
154 showOptions(optionsPage => 154 showOptions(optionsPage =>
155 { 155 {
156 if (!/^https?:$/.test(currentPage.url.protocol)) 156 if (!/^https?:$/.test(currentPage.url.protocol))
157 return; 157 return;
158 158
159 optionsPage.sendMessage({ 159 optionsPage.sendMessage({
160 type: "app.respond", 160 type: "app.respond",
161 action: "showPageOptions", 161 action: "showPageOptions",
162 args: [ 162 args: [
163 { 163 {
164 host: getDecodedHostname(currentPage.url).replace(/^www\./, ""), 164 host: getDecodedHostname(currentPage.url).replace(/^www\./, ""),
165 whitelisted: !!checkWhitelisted(currentPage) 165 whitelisted: !!checkWhitelisted(currentPage)
166 } 166 }
167 ] 167 ]
168 }); 168 });
169 }); 169 });
170 }); 170 });
171 }); 171 });
LEFTRIGHT

Powered by Google App Engine
This is Rietveld