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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 style: message.style, | 305 style: message.style, |
306 classes: message.classes, | 306 classes: message.classes, |
307 urls: message.urls, | 307 urls: message.urls, |
308 type: message.mediatype, | 308 type: message.mediatype, |
309 baseURL: message.baseURL, | 309 baseURL: message.baseURL, |
310 page: sender.page, | 310 page: sender.page, |
311 frame: sender.frame | 311 frame: sender.frame |
312 }); | 312 }); |
313 }); | 313 }); |
314 | 314 |
| 315 port.on("forward", (msg, sender) => |
| 316 { |
| 317 let targetPage; |
| 318 if (msg.targetPageId) |
| 319 targetPage = ext.getPage(msg.targetPageId); |
| 320 else |
| 321 targetPage = sender.page; |
| 322 if (targetPage) |
| 323 { |
| 324 msg.payload.sender = sender.page.id; |
| 325 if (msg.expectsResponse) |
| 326 return new Promise(targetPage.sendMessage.bind(targetPage, msg.payload)); |
| 327 targetPage.sendMessage(msg.payload); |
| 328 } |
| 329 }); |
| 330 |
315 ext.pages.onLoading.addListener(page => | 331 ext.pages.onLoading.addListener(page => |
316 { | 332 { |
317 // When tabs start loading we send them a message to ensure that the state | 333 // When tabs start loading we send them a message to ensure that the state |
318 // of the "block element" tool is reset. This is necessary since Firefox will | 334 // of the "block element" tool is reset. This is necessary since Firefox will |
319 // sometimes cache the state of a tab when the user navigates back / forward, | 335 // sometimes cache the state of a tab when the user navigates back / forward, |
320 // which includes the state of the "block element" tool. | 336 // which includes the state of the "block element" tool. |
321 // Since sending this message will often fail (e.g. for new tabs which have | 337 // Since sending this message will often fail (e.g. for new tabs which have |
322 // just been opened) we catch and ignore any exception thrown. | 338 // just been opened) we catch and ignore any exception thrown. |
323 browser.tabs.sendMessage( | 339 browser.tabs.sendMessage( |
324 page.id, {type: "composer.content.finished"} | 340 page.id, {type: "composer.content.finished"} |
325 ).catch(() => {}); | 341 ).catch(() => {}); |
326 }); | 342 }); |
OLD | NEW |