Index: Source/devtools/front_end/devtools_bootstrap/DevToolsApp.js |
diff --git a/Source/devtools/front_end/devtools_bootstrap/DevToolsApp.js b/Source/devtools/front_end/devtools_bootstrap/DevToolsApp.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7b42708e4061aca02bcf81c75f2bb15d1333c4cc |
--- /dev/null |
+++ b/Source/devtools/front_end/devtools_bootstrap/DevToolsApp.js |
@@ -0,0 +1,89 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+/** |
+ * @constructor |
+ * @implements {InspectorAppHostAPI} |
+ */ |
+WebInspector.DevToolsApp = function() |
+{ |
+ window.InspectorAppHost = this; |
+ |
+ // FIXME: These methods are invoked from the backend and should be removed |
+ // once we migrate to the "pull" model for extensions retrieval. |
+ WebInspector.addExtensions = this._wrapInvocation.bind(this, "addExtensions"); |
pfeldman
2014/11/10 15:48:36
We should reverse the direction of these and make
dgozman
2014/11/10 18:19:42
We'll have to keep pushing model for old frontends
|
+ WebInspector.setInspectedTabId = this._wrapInvocation.bind(this, "setInspectedTabId"); |
+ this._invokeOnWebInspectorOnceLoaded = []; |
+ |
+ /** |
+ * @type {?Window} |
+ */ |
+ this._inspectorWindow = null; |
+ this._loadInspectorAppInIframe(); |
+} |
+ |
+WebInspector.DevToolsApp.prototype = { |
+ /** |
+ * @param {!Window} window |
+ * @override |
+ */ |
+ inspectorAppWindowLoaded: function(window) |
+ { |
+ this._inspectorWindow = window; |
+ }, |
+ |
+ /** |
+ * @override |
+ */ |
+ beforeInspectorAppLoad: function() |
+ { |
+ }, |
+ |
+ /** |
+ * @override |
+ */ |
+ afterInspectorAppLoad: function() |
+ { |
+ while (this._invokeOnWebInspectorOnceLoaded.length) { |
+ var methodAndParams = this._invokeOnWebInspectorOnceLoaded.shift(); |
+ this._invokeOnWebInspector(methodAndParams[0], methodAndParams[1]); |
+ } |
+ }, |
+ |
+ /** |
+ * @param {string} method |
+ */ |
+ _wrapInvocation: function(method) |
+ { |
+ var params = Array.prototype.slice.call(arguments, 1); |
+ if (this._inspectorWindow) { |
+ this._invokeOnWebInspector(method, params); |
+ } else { |
+ this._invokeOnWebInspectorOnceLoaded.push([method, params]); |
+ } |
+ }, |
+ |
+ /** |
+ * @param {string} method |
+ * @param {!Array.<*>} params |
+ */ |
+ _invokeOnWebInspector: function(method, params) |
+ { |
+ var webInspector = this._inspectorWindow["WebInspector"]; |
+ webInspector[method].apply(webInspector, params); |
+ }, |
+ |
+ /** |
+ * @suppressGlobalPropertiesCheck |
+ */ |
+ _loadInspectorAppInIframe: function() |
+ { |
+ this._iframe = document.body.createChild("iframe", "inspector-app-iframe"); |
+ var url = window.location.href; |
+ url = url.replace("devtools.html", "inspector.html"); |
+ this._iframe.setAttribute("src", url); |
+ } |
+} |
+ |
+runOnWindowLoad(function() { new WebInspector.DevToolsApp(); }); |