| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @implements {InspectorAppHostAPI} | 7 * @implements {InspectorAppHostAPI} |
| 8 */ | 8 */ |
| 9 WebInspector.DevToolsApp = function() | 9 WebInspector.DevToolsApp = function() |
| 10 { | 10 { |
| 11 window.InspectorAppHost = this; | 11 window.InspectorAppHost = this; |
| 12 | 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 /** | 13 /** |
| 20 * @type {?Window} | 14 * @type {?Window} |
| 21 */ | 15 */ |
| 22 this._inspectorWindow = null; | 16 this._inspectorWindow = null; |
| 23 } | 17 } |
| 24 | 18 |
| 25 WebInspector.DevToolsApp.prototype = { | 19 WebInspector.DevToolsApp.prototype = { |
| 26 /** | 20 /** |
| 27 * @param {!Window} inspectorWindow | 21 * @param {!Window} inspectorWindow |
| 28 * @override | 22 * @override |
| (...skipping 14 matching lines...) Expand all Loading... |
| 43 // FIXME: move Tests to the host or teach browser counterpart about
iframe. | 37 // FIXME: move Tests to the host or teach browser counterpart about
iframe. |
| 44 window.uiTests = this._inspectorWindow.uiTests; | 38 window.uiTests = this._inspectorWindow.uiTests; |
| 45 } | 39 } |
| 46 }, | 40 }, |
| 47 | 41 |
| 48 /** | 42 /** |
| 49 * @override | 43 * @override |
| 50 */ | 44 */ |
| 51 afterInspectorAppLoad: function() | 45 afterInspectorAppLoad: function() |
| 52 { | 46 { |
| 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 } | 47 } |
| 81 } | 48 } |
| 82 | 49 |
| 83 new WebInspector.DevToolsApp(); | 50 new WebInspector.DevToolsApp(); |
| OLD | NEW |