Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: chrome/ext/background.js

Issue 6393086494113792: Issue 154 - Added devtools panel showing blocked and blockable items (Closed)
Patch Set: Fixed issues in content script breaking element hide tracing Created Jan. 30, 2016, 6:19 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/ext/background.js
===================================================================
--- a/chrome/ext/background.js
+++ b/chrome/ext/background.js
@@ -591,4 +591,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);
kzar 2016/01/31 13:33:51 Nit: Maybe should use let instead of var for these
Sebastian Noack 2016/02/02 10:39:51 I'd rather keep things conistent. (Except for one
+ ext.devtools.onCreated._dispatch(panel);
+ }
+ });
})();

Powered by Google App Engine
This is Rietveld