OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 /** | 7 /** |
8 * @constructor | 8 * @constructor |
9 * @extends {Protocol.Agents} | 9 * @extends {Protocol.Agents} |
10 * @param {string} name | 10 * @param {string} name |
11 * @param {!InspectorBackendClass.Connection} connection | 11 * @param {!InspectorBackendClass.Connection} connection |
12 * @param {function(?WebInspector.Target)=} callback | 12 * @param {function(?WebInspector.Target)=} callback |
| 13 * @param {string=} url |
13 */ | 14 */ |
14 WebInspector.Target = function(name, connection, callback) | 15 WebInspector.Target = function(name, connection, callback, url) |
15 { | 16 { |
16 Protocol.Agents.call(this, connection.agentsMap()); | 17 Protocol.Agents.call(this, connection.agentsMap()); |
17 this._name = name; | 18 this._name = name; |
| 19 this._url = url; |
18 this._connection = connection; | 20 this._connection = connection; |
19 connection.addEventListener(InspectorBackendClass.Connection.Events.Disconne
cted, this._onDisconnect, this); | 21 connection.addEventListener(InspectorBackendClass.Connection.Events.Disconne
cted, this._onDisconnect, this); |
20 this._id = WebInspector.Target._nextId++; | 22 this._id = WebInspector.Target._nextId++; |
21 | 23 |
22 /** @type {!Map.<!Function, !WebInspector.SDKModel>} */ | 24 /** @type {!Map.<!Function, !WebInspector.SDKModel>} */ |
23 this._modelByConstructor = new Map(); | 25 this._modelByConstructor = new Map(); |
24 | 26 |
25 /** @type {!Object.<string, boolean>} */ | 27 /** @type {!Object.<string, boolean>} */ |
26 this._capabilities = {}; | 28 this._capabilities = {}; |
27 this.pageAgent().canScreencast(this._initializeCapability.bind(this, WebInsp
ector.Target.Capabilities.CanScreencast, null)); | 29 this.pageAgent().canScreencast(this._initializeCapability.bind(this, WebInsp
ector.Target.Capabilities.CanScreencast, null)); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 /** | 82 /** |
81 * | 83 * |
82 * @return {string} | 84 * @return {string} |
83 */ | 85 */ |
84 name: function() | 86 name: function() |
85 { | 87 { |
86 return this._name; | 88 return this._name; |
87 }, | 89 }, |
88 | 90 |
89 /** | 91 /** |
| 92 * |
| 93 * @return {string} |
| 94 */ |
| 95 url: function() |
| 96 { |
| 97 return this._url ? this._url : this.resourceTreeModel.inspectedPageURL()
; |
| 98 }, |
| 99 |
| 100 /** |
90 * @param {string} name | 101 * @param {string} name |
91 * @param {function()|null} callback | 102 * @param {function()|null} callback |
92 * @param {?Protocol.Error} error | 103 * @param {?Protocol.Error} error |
93 * @param {boolean} result | 104 * @param {boolean} result |
94 */ | 105 */ |
95 _initializeCapability: function(name, callback, error, result) | 106 _initializeCapability: function(name, callback, error, result) |
96 { | 107 { |
97 this._capabilities[name] = result; | 108 this._capabilities[name] = result; |
98 if (callback) | 109 if (callback) |
99 callback(); | 110 callback(); |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 */ | 449 */ |
439 unobserveTargets: function(targetObserver) | 450 unobserveTargets: function(targetObserver) |
440 { | 451 { |
441 this._observers.remove(targetObserver); | 452 this._observers.remove(targetObserver); |
442 }, | 453 }, |
443 | 454 |
444 /** | 455 /** |
445 * @param {string} name | 456 * @param {string} name |
446 * @param {!InspectorBackendClass.Connection} connection | 457 * @param {!InspectorBackendClass.Connection} connection |
447 * @param {function(?WebInspector.Target)=} callback | 458 * @param {function(?WebInspector.Target)=} callback |
| 459 * @param {string=} url |
448 */ | 460 */ |
449 createTarget: function(name, connection, callback) | 461 createTarget: function(name, connection, callback, url) |
450 { | 462 { |
451 var target = new WebInspector.Target(name, connection, callbackWrapper.b
ind(this)); | 463 var target = new WebInspector.Target(name, connection, callbackWrapper.b
ind(this), url); |
452 | 464 |
453 /** | 465 /** |
454 * @this {WebInspector.TargetManager} | 466 * @this {WebInspector.TargetManager} |
455 * @param {?WebInspector.Target} newTarget | 467 * @param {?WebInspector.Target} newTarget |
456 */ | 468 */ |
457 function callbackWrapper(newTarget) | 469 function callbackWrapper(newTarget) |
458 { | 470 { |
459 if (newTarget) | 471 if (newTarget) |
460 this.addTarget(newTarget); | 472 this.addTarget(newTarget); |
461 if (callback) | 473 if (callback) |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 /** | 568 /** |
557 * @param {!WebInspector.Target} target | 569 * @param {!WebInspector.Target} target |
558 */ | 570 */ |
559 targetRemoved: function(target) { }, | 571 targetRemoved: function(target) { }, |
560 } | 572 } |
561 | 573 |
562 /** | 574 /** |
563 * @type {!WebInspector.TargetManager} | 575 * @type {!WebInspector.TargetManager} |
564 */ | 576 */ |
565 WebInspector.targetManager = new WebInspector.TargetManager(); | 577 WebInspector.targetManager = new WebInspector.TargetManager(); |
OLD | NEW |