Left: | ||
Right: |
OLD | NEW |
---|---|
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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 // We use a relative URL here because of this Edge issue: | 170 // We use a relative URL here because of this Edge issue: |
171 // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10 276332 | 171 // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10 276332 |
172 browser.tabs.create({url: optionsUrl}, () => | 172 browser.tabs.create({url: optionsUrl}, () => |
173 { | 173 { |
174 returnShowOptionsCall(optionsTab, callback); | 174 returnShowOptionsCall(optionsTab, callback); |
175 }); | 175 }); |
176 } | 176 } |
177 }); | 177 }); |
178 }; | 178 }; |
179 | 179 |
180 // 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 |
kzar
2018/05/24 12:09:01
This comment is pretty good at explaining how come
Sebastian Noack
2018/05/24 12:37:27
Well, setting it in the metadata.*/manifest.json f
kzar
2018/05/24 12:58:07
Yea fair enough. I drafted a possible improvement
| |
181 // 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] |
182 // 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 |
183 // 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 |
184 // non-mobile. | 184 // non-mobile. |
185 // [1] - https://bugzilla.mozilla.org/show_bug.cgi?id=1414613 | 185 // [1] - https://bugzilla.mozilla.org/show_bug.cgi?id=1414613 |
186 if ("getBrowserInfo" in browser.runtime) | 186 if ("getBrowserInfo" in browser.runtime) |
187 { | 187 { |
188 browser.runtime.getBrowserInfo().then(browserInfo => | 188 Promise.all([browser.browserAction.getPopup({}), |
189 { | 189 browser.runtime.getBrowserInfo()]).then( |
190 if (browserInfo.name == "Fennec") | 190 ([popup, browserInfo]) => |
191 browser.browserAction.setPopup({popup: ""}); | 191 { |
192 }); | 192 if (!popup && browserInfo.name != "Fennec") |
193 browser.browserAction.setPopup({popup: "popup.html"}); | |
194 } | |
195 ); | |
193 } | 196 } |
194 | 197 |
195 // On Firefox for Android, open the options page directly when the browser | 198 // On Firefox for Android, open the options page directly when the browser |
196 // action is clicked. | 199 // action is clicked. |
197 browser.browserAction.onClicked.addListener(() => | 200 browser.browserAction.onClicked.addListener(() => |
198 { | 201 { |
199 browser.tabs.query({active: true, lastFocusedWindow: true}, ([tab]) => | 202 browser.tabs.query({active: true, lastFocusedWindow: true}, ([tab]) => |
200 { | 203 { |
201 let currentPage = new ext.Page(tab); | 204 let currentPage = new ext.Page(tab); |
202 | 205 |
203 showOptions((optionsPage, port) => | 206 showOptions((optionsPage, port) => |
204 { | 207 { |
205 if (!/^https?:$/.test(currentPage.url.protocol)) | 208 if (!/^https?:$/.test(currentPage.url.protocol)) |
206 return; | 209 return; |
207 | 210 |
208 port.postMessage({ | 211 port.postMessage({ |
209 type: "app.respond", | 212 type: "app.respond", |
210 action: "showPageOptions", | 213 action: "showPageOptions", |
211 args: [ | 214 args: [ |
212 { | 215 { |
213 host: currentPage.url.hostname.replace(/^www\./, ""), | 216 host: currentPage.url.hostname.replace(/^www\./, ""), |
214 whitelisted: !!checkWhitelisted(currentPage) | 217 whitelisted: !!checkWhitelisted(currentPage) |
215 } | 218 } |
216 ] | 219 ] |
217 }); | 220 }); |
218 }); | 221 }); |
219 }); | 222 }); |
220 }); | 223 }); |
OLD | NEW |