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) => | 315 port.on("composer.forward", (msg, sender) => |
316 { | 316 { |
317 let targetPage; | 317 let targetPage; |
318 if (msg.targetPageId) | 318 if (msg.targetPageId) |
319 targetPage = ext.getPage(msg.targetPageId); | 319 targetPage = ext.getPage(msg.targetPageId); |
320 else | 320 else |
321 targetPage = sender.page; | 321 targetPage = sender.page; |
322 if (targetPage) | 322 if (targetPage) |
323 { | 323 { |
324 msg.payload.sender = sender.page.id; | 324 msg.payload.sender = sender.page.id; |
325 if (msg.expectsResponse) | 325 if (msg.expectsResponse) |
326 return new Promise(targetPage.sendMessage.bind(targetPage, msg.payload)); | 326 return new Promise(targetPage.sendMessage.bind(targetPage, msg.payload)); |
327 targetPage.sendMessage(msg.payload); | 327 targetPage.sendMessage(msg.payload); |
328 } | 328 } |
329 }); | 329 }); |
330 | 330 |
331 ext.pages.onLoading.addListener(page => | 331 ext.pages.onLoading.addListener(page => |
332 { | 332 { |
333 // 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 |
334 // 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 |
335 // 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, |
336 // which includes the state of the "block element" tool. | 336 // which includes the state of the "block element" tool. |
337 // 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 |
338 // just been opened) we catch and ignore any exception thrown. | 338 // just been opened) we catch and ignore any exception thrown. |
339 browser.tabs.sendMessage( | 339 browser.tabs.sendMessage( |
340 page.id, {type: "composer.content.finished"} | 340 page.id, {type: "composer.content.finished"} |
341 ).catch(() => {}); | 341 ).catch(() => {}); |
342 }); | 342 }); |
OLD | NEW |