OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. |
| 5 */ |
| 6 |
| 7 /** |
| 8 * @constructor |
| 9 * @extends {Protocol.Agents} |
| 10 * @param {!InspectorBackendClass.Connection} connection |
| 11 * @param {function(!WebInspector.Target)=} callback |
| 12 */ |
| 13 WebInspector.Target = function(connection, callback) |
| 14 { |
| 15 Protocol.Agents.call(this, connection.agentsMap()); |
| 16 this._connection = connection; |
| 17 this.canScreenCast = false; |
| 18 this.canInspectWorkers = false; |
| 19 |
| 20 this.pageAgent().canScreencast(this._initializeCapability.bind(this, "canScr
eencast", null)); |
| 21 this.workerAgent().canInspectWorkers(this._initializeCapability.bind(this, "
canInspectWorkers", this._loadedWithCapabilities.bind(this, callback))); |
| 22 |
| 23 // In case of loading as a web page with no bindings / harness, kick off ini
tialization manually. |
| 24 if (InspectorFrontendHost.isStub) { |
| 25 // give a chance to add listeners of WebInspector.Target.Events.TargetIs
Ready |
| 26 setTimeout(this._loadedWithCapabilities.bind(this, callback), 0); |
| 27 } |
| 28 } |
| 29 |
| 30 WebInspector.Target.prototype = { |
| 31 |
| 32 _initializeCapability: function(name, callback, error, result) |
| 33 { |
| 34 this[name] = result; |
| 35 if (callback) |
| 36 callback(); |
| 37 }, |
| 38 |
| 39 /** |
| 40 * @param {function(!WebInspector.Target)=} callback |
| 41 */ |
| 42 _loadedWithCapabilities: function(callback) |
| 43 { |
| 44 this.consoleModel = new WebInspector.ConsoleModel(); |
| 45 //This and similar lines are needed for compatibility |
| 46 WebInspector.console = this.consoleModel; |
| 47 this.networkManager = new WebInspector.NetworkManager(); |
| 48 WebInspector.networkManager = this.networkManager; |
| 49 this.resourceTreeModel = new WebInspector.ResourceTreeModel(this.network
Manager); |
| 50 WebInspector.resourceTreeModel = this.resourceTreeModel; |
| 51 this.debuggerModel = new WebInspector.DebuggerModel(); |
| 52 WebInspector.debuggerModel = this.debuggerModel; |
| 53 this.runtimeModel = new WebInspector.RuntimeModel(this.resourceTreeModel
); |
| 54 WebInspector.runtimeModel = this.runtimeModel; |
| 55 |
| 56 //we can't name it domAgent, because it clashes with function, WebInspec
tor.DOMAgent should be renamed to DOMModel |
| 57 this._domAgent = new WebInspector.DOMAgent(); |
| 58 WebInspector.domAgent = this._domAgent; |
| 59 this.workerManager = new WebInspector.WorkerManager(this.canInspectWorke
rs); |
| 60 WebInspector.workerManager = this.workerManager; |
| 61 |
| 62 if (callback) |
| 63 callback(this); |
| 64 }, |
| 65 |
| 66 __proto__: Protocol.Agents.prototype |
| 67 } |
| 68 |
| 69 /** |
| 70 * @constructor |
| 71 */ |
| 72 WebInspector.TargetManager = function() |
| 73 { |
| 74 /** @type {!Array.<!WebInspector.Target>} */ |
| 75 this._targets = []; |
| 76 } |
| 77 |
| 78 WebInspector.TargetManager.prototype = { |
| 79 |
| 80 /** |
| 81 * @param {!InspectorBackendClass.Connection} connection |
| 82 * @param {function(!WebInspector.Target)=} callback |
| 83 */ |
| 84 createTarget: function(connection, callback) |
| 85 { |
| 86 var newTarget = new WebInspector.Target(connection, callback); |
| 87 this._targets.push(newTarget); |
| 88 } |
| 89 |
| 90 } |
OLD | NEW |