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: Created Nov. 4, 2017, 11:22 a.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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // We use a relative URL here because of this Edge issue: 117 // We use a relative URL here because of this Edge issue:
118 // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10 276332 118 // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10 276332
119 browser.tabs.create({url: optionsUrl}, () => 119 browser.tabs.create({url: optionsUrl}, () =>
120 { 120 {
121 returnShowOptionsCall(optionsTab, callback); 121 returnShowOptionsCall(optionsTab, callback);
122 }); 122 });
123 } 123 }
124 }); 124 });
125 }; 125 };
126 126
127 // On Firefox we set the popup programmatically here rather than via 127 // We need to clear the popup URL on Firefox for Android in order for the
128 // manifest.json so we can open the options page directly on Android. 128 // options page to open instead of the bubble. Unfortunately there's a bug[1]
129 if ("getPopup" in browser.browserAction) 129 // which prevents us from doing that, so we must avoid setting the URL on
kzar 2017/11/04 16:17:26 The idea is that browser.browserAction.getPopup do
Wladimir Palant 2017/11/04 19:43:26 I think that the idea is rather introducing a dela
Manish Jethani 2017/11/05 11:35:00 The idea was that popup.html is set in manifest.js
Manish Jethani 2017/11/05 11:35:00 getPopup does exist on Firefox for Android v57, bu
kzar 2017/11/06 09:36:51 Right gotya.
130 // Firefox from the manifest at all, instead setting it here only for
131 // non-mobile.
132 // [1] - https://bugzilla.mozilla.org/show_bug.cgi?id=1414613
133 if ("getBrowserInfo" in browser.runtime)
130 { 134 {
131 browser.browserAction.getPopup({}).then(url => 135 browser.runtime.getBrowserInfo().then(browserInfo =>
132 { 136 {
133 if (!url && info.application != "fennec") 137 if (browserInfo.name != "Fennec")
Manish Jethani 2017/11/04 11:27:17 Note that we can't check for "fennec" in the initi
Wladimir Palant 2017/11/04 19:43:26 Can't we call getBrowserInfo explicitly here then?
kzar 2017/11/04 21:50:31 Oh yea, cool idea. By clearing the popup URL for F
Manish Jethani 2017/11/05 11:35:00 This does not work unfortunately due to a bug that
kzar 2017/11/06 09:36:51 Damn, that sucks. I guess we could at least get ri
Manish Jethani 2017/11/06 14:15:09 Done.
134 browser.browserAction.setPopup({popup: "popup.html"}); 138 browser.browserAction.setPopup({popup: "popup.html"});
135 }); 139 });
140 }
141 else
142 {
143 browser.browserAction.setPopup({popup: "popup.html"});
136 } 144 }
137 145
138 // 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
139 // action is clicked. 147 // action is clicked.
140 browser.browserAction.onClicked.addListener(() => 148 browser.browserAction.onClicked.addListener(() =>
141 { 149 {
142 browser.tabs.query({active: true, lastFocusedWindow: true}, ([tab]) => 150 browser.tabs.query({active: true, lastFocusedWindow: true}, ([tab]) =>
143 { 151 {
144 let currentPage = new ext.Page(tab); 152 let currentPage = new ext.Page(tab);
145 153
146 showOptions(optionsPage => 154 showOptions(optionsPage =>
147 { 155 {
148 if (!/^https?:$/.test(currentPage.url.protocol)) 156 if (!/^https?:$/.test(currentPage.url.protocol))
149 return; 157 return;
150 158
151 optionsPage.sendMessage({ 159 optionsPage.sendMessage({
152 type: "app.respond", 160 type: "app.respond",
153 action: "showPageOptions", 161 action: "showPageOptions",
154 args: [ 162 args: [
155 { 163 {
156 host: getDecodedHostname(currentPage.url).replace(/^www\./, ""), 164 host: getDecodedHostname(currentPage.url).replace(/^www\./, ""),
157 whitelisted: !!checkWhitelisted(currentPage) 165 whitelisted: !!checkWhitelisted(currentPage)
158 } 166 }
159 ] 167 ]
160 }); 168 });
161 }); 169 });
162 }); 170 });
163 }); 171 });
LEFTRIGHT

Powered by Google App Engine
This is Rietveld