Index: chrome/ext/background.js |
=================================================================== |
--- a/chrome/ext/background.js |
+++ b/chrome/ext/background.js |
@@ -536,4 +536,37 @@ |
}); |
}); |
}; |
+ |
+ |
+ /* 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() |
+ }; |
+ |
+ 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); |
+ } |
+ }); |
})(); |