| 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 }); | 208 }); |
| 209 | 209 |
| 210 port.on("composer.ready", (message, sender) => | 210 port.on("composer.ready", (message, sender) => |
| 211 { | 211 { |
| 212 readyPages.set(sender.page, null); | 212 readyPages.set(sender.page, null); |
| 213 updateContextMenu(sender.page); | 213 updateContextMenu(sender.page); |
| 214 }); | 214 }); |
| 215 | 215 |
| 216 port.on("composer.openDialog", (message, sender) => | 216 port.on("composer.openDialog", (message, sender) => |
| 217 { | 217 { |
| 218 return new Promise(resolve => | 218 return browser.windows.create({ |
| 219 url: browser.extension.getURL("composer.html"), | |
| 220 left: 50, | |
| 221 top: 50, | |
| 222 width: 420, | |
| 223 height: 200, | |
| 224 type: "popup" | |
| 225 }).then(window => | |
| 219 { | 226 { |
| 220 ext.windows.create({ | 227 let popupPageId = window.tabs[0].id; |
|
kzar
2017/11/03 13:24:06
I think we can remove ext.windows from ext/backgro
Wladimir Palant
2017/11/03 13:49:05
Sure - after the release.
kzar
2017/11/03 13:57:06
Well if we're only doing the bare minimum for the
Wladimir Palant
2017/11/03 13:59:37
Because the ext API only gives us a tab ID but not
kzar
2017/11/03 14:00:56
Ah, OK.
| |
| 221 url: browser.extension.getURL("composer.html"), | 228 function onRemoved(removedPageId) |
| 222 left: 50, | |
| 223 top: 50, | |
| 224 width: 420, | |
| 225 height: 200, | |
| 226 type: "popup" | |
| 227 }, | |
| 228 popupPage => | |
| 229 { | 229 { |
| 230 let popupPageId = popupPage.id; | 230 if (popupPageId == removedPageId) |
| 231 function onRemoved(removedPageId) | |
| 232 { | 231 { |
| 233 if (popupPageId == removedPageId) | 232 sender.page.sendMessage({ |
| 234 { | 233 type: "composer.content.dialogClosed", |
| 235 sender.page.sendMessage({ | 234 popupId: popupPageId |
| 236 type: "composer.content.dialogClosed", | 235 }); |
| 237 popupId: popupPageId | 236 ext.pages.onRemoved.removeListener(onRemoved); |
| 238 }); | |
| 239 ext.pages.onRemoved.removeListener(onRemoved); | |
| 240 } | |
| 241 } | 237 } |
| 242 ext.pages.onRemoved.addListener(onRemoved); | 238 } |
| 243 resolve(popupPageId); | 239 ext.pages.onRemoved.addListener(onRemoved); |
| 244 }); | 240 |
| 241 if (require("info").application == "firefox" && | |
| 242 navigator.oscpu.startsWith("Linux")) | |
|
kzar
2017/11/03 13:24:06
(I'll take your word for it that this is the best
Wladimir Palant
2017/11/03 13:49:05
It's not a great way, but it's worse than any othe
kzar
2017/11/03 13:57:06
Acknowledged.
| |
| 243 { | |
| 244 // Work around https://bugzil.la/1408446 | |
| 245 browser.windows.update(window.id, {width: window.width + 1}); | |
| 246 } | |
| 247 return popupPageId; | |
| 245 }); | 248 }); |
| 246 }); | 249 }); |
| 247 | 250 |
| 248 port.on("composer.getFilters", (message, sender) => | 251 port.on("composer.getFilters", (message, sender) => |
| 249 { | 252 { |
| 250 return composeFilters({ | 253 return composeFilters({ |
| 251 tagName: message.tagName, | 254 tagName: message.tagName, |
| 252 id: message.id, | 255 id: message.id, |
| 253 src: message.src, | 256 src: message.src, |
| 254 style: message.style, | 257 style: message.style, |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 265 { | 268 { |
| 266 return quoteCSS(message.CSS); | 269 return quoteCSS(message.CSS); |
| 267 }); | 270 }); |
| 268 | 271 |
| 269 ext.pages.onLoading.addListener(page => | 272 ext.pages.onLoading.addListener(page => |
| 270 { | 273 { |
| 271 // A newly opened tab that is still loading has its URL set to about:blank | 274 // A newly opened tab that is still loading has its URL set to about:blank |
| 272 if (/^https?:/.test(page.url.protocol)) | 275 if (/^https?:/.test(page.url.protocol)) |
| 273 page.sendMessage({type: "composer.content.finished"}); | 276 page.sendMessage({type: "composer.content.finished"}); |
| 274 }); | 277 }); |
| OLD | NEW |