| 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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 /* Message passing */ | 489 /* Message passing */ |
| 490 | 490 |
| 491 chrome.runtime.onMessage.addListener(function(message, rawSender, sendResponse
) | 491 chrome.runtime.onMessage.addListener(function(message, rawSender, sendResponse
) |
| 492 { | 492 { |
| 493 var sender = {}; | 493 var sender = {}; |
| 494 | 494 |
| 495 // Add "page" and "frame" if the message was sent by a content script. | 495 // Add "page" and "frame" if the message was sent by a content script. |
| 496 // If sent by popup or the background page itself, there is no "tab". | 496 // If sent by popup or the background page itself, there is no "tab". |
| 497 if ("tab" in rawSender) | 497 if ("tab" in rawSender) |
| 498 { | 498 { |
| 499 console.log(rawSender.url); |
| 499 sender.page = new Page(rawSender.tab); | 500 sender.page = new Page(rawSender.tab); |
| 500 sender.frame = { | 501 sender.frame = { |
| 501 url: new URL(rawSender.url), | 502 url: new URL(rawSender.url), |
| 502 get parent() | 503 get parent() |
| 503 { | 504 { |
| 504 var frames = framesOfTabs[rawSender.tab.id]; | 505 var frames = framesOfTabs[rawSender.tab.id]; |
| 505 | 506 |
| 506 if (!frames) | 507 if (!frames) |
| 507 return null; | 508 return null; |
| 508 | 509 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 if (callback) | 585 if (callback) |
| 585 callback(new Page(tab)); | 586 callback(new Page(tab)); |
| 586 } | 587 } |
| 587 else | 588 else |
| 588 { | 589 { |
| 589 ext.pages.open(optionsUrl, callback); | 590 ext.pages.open(optionsUrl, callback); |
| 590 } | 591 } |
| 591 }); | 592 }); |
| 592 }); | 593 }); |
| 593 }; | 594 }; |
| 595 |
| 596 |
| 597 /* Devtools panel */ |
| 598 |
| 599 var Panel = function(inspectedTabId, port) |
| 600 { |
| 601 this.inspectedTabId = inspectedTabId; |
| 602 this._port = port; |
| 603 }; |
| 604 Panel.prototype = { |
| 605 sendMessage: function(message) |
| 606 { |
| 607 this._port.postMessage(message); |
| 608 }, |
| 609 get onRemoved() |
| 610 { |
| 611 return this._port.onDisconnect; |
| 612 } |
| 613 }; |
| 614 |
| 615 ext.devtools = { |
| 616 onCreated: new ext._EventTarget() |
| 617 }; |
| 618 |
| 619 // If this code should ever be removed, note that we still have to |
| 620 // ensure that there is at least one listener for the onConnect event. |
| 621 // Otherwise we can't connect a port later, in order to detect when |
| 622 // the extension is reloaded,disabled or uninstalled. |
| 623 chrome.runtime.onConnect.addListener(function(port) |
| 624 { |
| 625 var match = port.name.match(/^devtools-(\d+)$/); |
| 626 if (match) |
| 627 { |
| 628 var panel = new Panel(parseInt(match[1], 10), port); |
| 629 ext.devtools.onCreated._dispatch(panel); |
| 630 } |
| 631 }); |
| 594 })(); | 632 })(); |
| OLD | NEW |