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 {WebInspector.Object} | |
10 * @param {!InspectorBackendClass.Connection} connection | |
11 */ | |
12 WebInspector.Target = function(connection) | |
13 { | |
14 WebInspector.Object.call(this); | |
15 this._connection = connection; | |
16 this.canScreenCast = false; | |
17 this.canInspectWorkers = false; | |
18 | |
19 connection.agent("Page").canScreencast(this._initializeCapability.bind(this, "canScreencast", null)); | |
20 connection.agent("Worker").canInspectWorkers(this._initializeCapability.bind (this, "canInspectWorkers", this._loadedWithCapabilities.bind(this))); | |
21 | |
22 // In case of loading as a web page with no bindings / harness, kick off ini tialization manually. | |
23 if (InspectorFrontendHost.isStub) { | |
24 // give a chance to add listeners of WebInspector.Target.Events.TargetIs Ready | |
25 setTimeout(this._loadedWithCapabilities.bind(this), 0); | |
26 } | |
27 } | |
28 | |
29 WebInspector.Target.Events = { | |
30 TargetIsReady: "TargetIsReady" | |
31 } | |
32 | |
33 WebInspector.Target.prototype = { | |
34 | |
35 _initializeCapability: function(name, callback, error, result) | |
36 { | |
37 this[name] = result; | |
38 if (callback) | |
39 callback(); | |
40 }, | |
41 | |
42 _loadedWithCapabilities: function() | |
43 { | |
44 this.consoleModel = new WebInspector.ConsoleModel(this); | |
45 this.networkManager = new WebInspector.NetworkManager(this); | |
46 this.resourceTreeModel = new WebInspector.ResourceTreeModel(this); | |
47 this.debuggerModel = new WebInspector.DebuggerModel(); | |
48 this.runtimeModel = new WebInspector.RuntimeModel(this); | |
49 | |
50 this.dispatchEventToListeners(WebInspector.Target.Events.TargetIsReady); | |
51 }, | |
52 | |
53 /** | |
54 * @param {string} domain | |
55 * @param {!Object} dispatcher | |
56 */ | |
57 registerDispatcher: function(domain, dispatcher) | |
58 { | |
59 this._connection.registerDispatcher(domain, dispatcher); | |
60 }, | |
61 | |
62 /** | |
63 * @param {string} domain | |
64 * @return {!InspectorBackendClass.AgentPrototype} | |
65 */ | |
66 agent: function(domain) | |
67 { | |
68 return this._connection.agent(domain); | |
69 }, | |
70 | |
71 __proto__: WebInspector.Object.prototype | |
72 } | |
73 | |
74 /** | |
75 * @constructor | |
76 * @extends {WebInspector.Object} | |
77 */ | |
78 WebInspector.TargetManager = function() | |
79 { | |
80 /** @type {!Array.<!WebInspector.Target>} */ | |
81 this._targets = []; | |
82 } | |
83 | |
84 WebInspector.TargetManager.Events = { | |
vsevik
2014/03/05 12:34:49
Let's add this event once it is at least dispatche
sergeyv
2014/03/05 15:02:51
Done.
| |
85 TargetSwitched: "TargetSwitched" | |
86 } | |
87 | |
88 WebInspector.TargetManager.prototype = { | |
89 | |
90 /** | |
91 * @param {!InspectorBackendClass.Connection} connection | |
92 * @return {!WebInspector.Target} | |
93 */ | |
94 newConnectionAvailable: function(connection) | |
vsevik
2014/03/05 12:34:49
How about createTarget(connection, callback) where
sergeyv
2014/03/05 15:02:51
Done.
| |
95 { | |
96 var newTarget = new WebInspector.Target(connection); | |
97 this._targets.push(newTarget); | |
98 return newTarget; | |
99 }, | |
100 | |
101 __proto__: WebInspector.Object.prototype | |
102 } | |
OLD | NEW |