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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 return browser.windows.create({ | 218 return browser.windows.create({ |
219 url: browser.extension.getURL("composer.html"), | 219 url: browser.extension.getURL("composer.html"), |
220 left: 50, | 220 left: 50, |
221 top: 50, | 221 top: 50, |
222 width: 420, | 222 width: 420, |
223 height: 200, | 223 height: 200, |
224 type: "popup" | 224 type: "popup" |
225 }).then(window => | 225 }).then(window => |
226 { | 226 { |
227 let popupPageId = window.tabs[0].id; | 227 let popupPageId = window.tabs[0].id; |
228 function onRemoved(removedPageId) | 228 |
229 let doInit = () => | |
229 { | 230 { |
230 if (popupPageId == removedPageId) | 231 browser.tabs.sendMessage(popupPageId, { |
232 type: "composer.dialog.init", | |
233 sender: sender.page.id, | |
234 filters: message.filters | |
235 }); | |
236 }; | |
237 if (window.tabs[0].status != "complete") | |
238 { | |
239 let updateListener = (tabId, changeInfo, tab) => | |
240 { | |
241 if (tabId == popupPageId && changeInfo.status == "complete") | |
242 { | |
243 browser.tabs.onUpdated.removeListener(updateListener); | |
244 doInit(); | |
245 } | |
246 }; | |
247 browser.tabs.onUpdated.addListener(updateListener); | |
248 } | |
249 else | |
250 doInit(); | |
251 | |
252 let onRemoved = removedTabId => | |
Wladimir Palant
2017/11/09 14:14:12
The changes after this line aren't strictly necess
kzar
2017/11/10 14:51:50
Acknowledged.
| |
253 { | |
254 if (removedTabId == popupPageId) | |
231 { | 255 { |
232 sender.page.sendMessage({ | 256 sender.page.sendMessage({ |
233 type: "composer.content.dialogClosed", | 257 type: "composer.content.dialogClosed", |
234 popupId: popupPageId | 258 popupId: popupPageId |
235 }); | 259 }); |
236 ext.pages.onRemoved.removeListener(onRemoved); | 260 browser.tabs.onRemoved.removeListener(onRemoved); |
237 } | 261 } |
238 } | 262 }; |
239 ext.pages.onRemoved.addListener(onRemoved); | 263 browser.tabs.onRemoved.addListener(onRemoved); |
240 | 264 |
241 if (require("info").application == "firefox" && | 265 if (require("info").application == "firefox" && |
242 navigator.oscpu.startsWith("Linux")) | 266 navigator.oscpu.startsWith("Linux")) |
243 { | 267 { |
244 // Work around https://bugzil.la/1408446 | 268 // Work around https://bugzil.la/1408446 |
245 browser.windows.update(window.id, {width: window.width + 1}); | 269 browser.windows.update(window.id, {width: window.width + 1}); |
246 } | 270 } |
247 return popupPageId; | 271 return popupPageId; |
248 }); | 272 }); |
249 }); | 273 }); |
(...skipping 18 matching lines...) Expand all Loading... | |
268 { | 292 { |
269 return quoteCSS(message.CSS); | 293 return quoteCSS(message.CSS); |
270 }); | 294 }); |
271 | 295 |
272 ext.pages.onLoading.addListener(page => | 296 ext.pages.onLoading.addListener(page => |
273 { | 297 { |
274 // A newly opened tab that is still loading has its URL set to about:blank | 298 // A newly opened tab that is still loading has its URL set to about:blank |
275 if (/^https?:/.test(page.url.protocol)) | 299 if (/^https?:/.test(page.url.protocol)) |
276 page.sendMessage({type: "composer.content.finished"}); | 300 page.sendMessage({type: "composer.content.finished"}); |
277 }); | 301 }); |
OLD | NEW |