OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * @constructor |
| 7 * @implements {InspectorAppHostAPI} |
| 8 */ |
| 9 WebInspector.DevToolsApp = function() |
| 10 { |
| 11 window.InspectorAppHost = this; |
| 12 |
| 13 // FIXME: These methods are invoked from the backend and should be removed |
| 14 // once we migrate to the "pull" model for extensions retrieval. |
| 15 WebInspector.addExtensions = this._wrapInvocation.bind(this, "addExtensions"
); |
| 16 WebInspector.setInspectedTabId = this._wrapInvocation.bind(this, "setInspect
edTabId"); |
| 17 this._invokeOnWebInspectorOnceLoaded = []; |
| 18 |
| 19 /** |
| 20 * @type {?Window} |
| 21 */ |
| 22 this._inspectorWindow = null; |
| 23 } |
| 24 |
| 25 WebInspector.DevToolsApp.prototype = { |
| 26 /** |
| 27 * @param {!Window} inspectorWindow |
| 28 * @override |
| 29 */ |
| 30 inspectorAppWindowLoaded: function(inspectorWindow) |
| 31 { |
| 32 this._inspectorWindow = inspectorWindow; |
| 33 if (window.domAutomationController) |
| 34 this._inspectorWindow.domAutomationController = window.domAutomation
Controller; |
| 35 }, |
| 36 |
| 37 /** |
| 38 * @override |
| 39 */ |
| 40 beforeInspectorAppLoad: function() |
| 41 { |
| 42 if (this._inspectorWindow.uiTests) { |
| 43 // FIXME: move Tests to the host or teach browser counterpart about
iframe. |
| 44 window.uiTests = this._inspectorWindow.uiTests; |
| 45 } |
| 46 }, |
| 47 |
| 48 /** |
| 49 * @override |
| 50 */ |
| 51 afterInspectorAppLoad: function() |
| 52 { |
| 53 while (this._invokeOnWebInspectorOnceLoaded.length) { |
| 54 var methodAndParams = this._invokeOnWebInspectorOnceLoaded.shift(); |
| 55 this._invokeOnWebInspector(methodAndParams[0], methodAndParams[1]); |
| 56 } |
| 57 }, |
| 58 |
| 59 /** |
| 60 * @param {string} method |
| 61 */ |
| 62 _wrapInvocation: function(method) |
| 63 { |
| 64 var params = Array.prototype.slice.call(arguments, 1); |
| 65 if (this._inspectorWindow) { |
| 66 this._invokeOnWebInspector(method, params); |
| 67 } else { |
| 68 this._invokeOnWebInspectorOnceLoaded.push([method, params]); |
| 69 } |
| 70 }, |
| 71 |
| 72 /** |
| 73 * @param {string} method |
| 74 * @param {!Array.<*>} params |
| 75 */ |
| 76 _invokeOnWebInspector: function(method, params) |
| 77 { |
| 78 var webInspector = this._inspectorWindow["WebInspector"]; |
| 79 webInspector[method].apply(webInspector, params); |
| 80 } |
| 81 } |
| 82 |
| 83 new WebInspector.DevToolsApp(); |
OLD | NEW |