| Index: chrome/ext/background.js |
| =================================================================== |
| --- a/chrome/ext/background.js |
| +++ b/chrome/ext/background.js |
| @@ -496,6 +496,7 @@ |
| // If sent by popup or the background page itself, there is no "tab". |
| if ("tab" in rawSender) |
| { |
| + console.log(rawSender.url); |
| sender.page = new Page(rawSender.tab); |
| sender.frame = { |
| url: new URL(rawSender.url), |
| @@ -591,4 +592,41 @@ |
| }); |
| }); |
| }; |
| + |
| + |
| + /* Devtools panel */ |
| + |
| + var Panel = function(inspectedTabId, port) |
| + { |
| + this.inspectedTabId = inspectedTabId; |
| + this._port = port; |
| + }; |
| + Panel.prototype = { |
| + sendMessage: function(message) |
| + { |
| + this._port.postMessage(message); |
| + }, |
| + get onRemoved() |
| + { |
| + return this._port.onDisconnect; |
| + } |
| + }; |
| + |
| + ext.devtools = { |
| + onCreated: new ext._EventTarget() |
| + }; |
| + |
| + // If this code should ever be removed, note that we still have to |
| + // ensure that there is at least one listener for the onConnect event. |
| + // Otherwise we can't connect a port later, in order to detect when |
| + // the extension is reloaded,disabled or uninstalled. |
| + chrome.runtime.onConnect.addListener(function(port) |
| + { |
| + var match = port.name.match(/^devtools-(\d+)$/); |
| + if (match) |
| + { |
| + var panel = new Panel(parseInt(match[1], 10), port); |
| + ext.devtools.onCreated._dispatch(panel); |
| + } |
| + }); |
| })(); |