Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4082)

Unified Diff: Source/devtools/front_end/extensions/ExtensionServer.js

Issue 712403002: [DevTools] Move extension embedder message to InspectorFrontentAPI. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/devtools/front_end/extensions/ExtensionServer.js
diff --git a/Source/devtools/front_end/extensions/ExtensionServer.js b/Source/devtools/front_end/extensions/ExtensionServer.js
index feeeb00306c84c3bb2ba5e836d45d3d9ed52b0e8..883018a117488299b75331271c07086b3dd898e9 100644
--- a/Source/devtools/front_end/extensions/ExtensionServer.js
+++ b/Source/devtools/front_end/extensions/ExtensionServer.js
@@ -82,6 +82,9 @@ WebInspector.ExtensionServer = function()
this._registerHandler(commands.UpdateAuditProgress, this._onUpdateAuditProgress.bind(this));
window.addEventListener("message", this._onWindowMessage.bind(this), false); // Only for main window.
+ InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Events.AddExtensions, this._addExtensions, this);
+ InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Events.SetInspectedTabId, this._setInspectedTabId, this);
+
this._initExtensions();
}
@@ -95,7 +98,7 @@ WebInspector.ExtensionServer.prototype = {
{
this._initializeCommandIssued = true;
if (this._pendingExtensionInfos) {
- this._addExtensions(this._pendingExtensionInfos);
+ this._pendingExtensionInfos.forEach(this._addExtension, this);
delete this._pendingExtensionInfos;
}
},
@@ -797,10 +800,14 @@ WebInspector.ExtensionServer.prototype = {
},
/**
- * @param {!Array.<!ExtensionDescriptor>} extensionInfos
+ * @param {!WebInspector.Event} event
*/
- _addExtensions: function(extensionInfos)
+ _addExtensions: function(event)
{
+ if (WebInspector.extensionServer._overridePlatformExtensionAPIForTest)
+ window.buildPlatformExtensionAPI = WebInspector.extensionServer._overridePlatformExtensionAPIForTest;
+
+ var extensionInfos = /** @type {!Array.<!ExtensionDescriptor>} */ (event.data);
if (this._initializeCommandIssued)
extensionInfos.forEach(this._addExtension, this);
else
@@ -808,6 +815,14 @@ WebInspector.ExtensionServer.prototype = {
},
/**
+ * @param {!WebInspector.Event} event
+ */
+ _setInspectedTabId: function(event)
+ {
+ this._inspectedTabId = /** @type {string} */ (event.data);
+ },
+
+ /**
* @param {!ExtensionDescriptor} extensionInfo
* @suppressGlobalPropertiesCheck
*/
@@ -826,7 +841,7 @@ WebInspector.ExtensionServer.prototype = {
var extensionOrigin = originMatch[1];
if (!this._registeredExtensions[extensionOrigin]) {
// See ExtensionAPI.js for details.
- InspectorFrontendHost.setInjectedScriptForOrigin(extensionOrigin, buildExtensionAPIInjectedScript(extensionInfo));
+ InspectorFrontendHost.setInjectedScriptForOrigin(extensionOrigin, buildExtensionAPIInjectedScript(extensionInfo, this._inspectedTabId));
this._registeredExtensions[extensionOrigin] = { name: name };
}
var iframe = createElement("iframe");
@@ -1116,15 +1131,3 @@ WebInspector.ExtensionStatus.Record;
WebInspector.extensionAPI = {};
defineCommonExtensionSymbols(WebInspector.extensionAPI);
-
-WebInspector.addExtensions = function(extensions)
-{
- if (WebInspector.extensionServer._overridePlatformExtensionAPIForTest)
- window.buildPlatformExtensionAPI = WebInspector.extensionServer._overridePlatformExtensionAPIForTest;
- WebInspector.extensionServer._addExtensions(extensions);
-}
-
-WebInspector.setInspectedTabId = function(tabId)
-{
- WebInspector._inspectedTabId = tabId;
-}
« no previous file with comments | « Source/devtools/front_end/extensions/ExtensionAPI.js ('k') | Source/devtools/front_end/host/InspectorFrontendHost.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698