Index: Source/devtools/front_end/Target.js |
diff --git a/Source/devtools/front_end/Target.js b/Source/devtools/front_end/Target.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..cb6a7668f32f33eef1bfacb9aed25b98f27ee87d |
--- /dev/null |
+++ b/Source/devtools/front_end/Target.js |
@@ -0,0 +1,102 @@ |
+/** |
+ * Copyright 2014 The Chromium Authors. All rights reserved. |
+ * Use of this source code is governed by a BSD-style license that can be |
+ * found in the LICENSE file. |
+ */ |
+ |
+/** |
+ * @constructor |
+ * @extends {WebInspector.Object} |
+ * @param {!InspectorBackendClass.Connection} connection |
+ */ |
+WebInspector.Target = function(connection) |
+{ |
+ WebInspector.Object.call(this); |
+ this._connection = connection; |
+ this.canScreenCast = false; |
+ this.canInspectWorkers = false; |
+ |
+ connection.agent("Page").canScreencast(this._initializeCapability.bind(this, "canScreencast", null)); |
+ connection.agent("Worker").canInspectWorkers(this._initializeCapability.bind(this, "canInspectWorkers", this._loadedWithCapabilities.bind(this))); |
+ |
+ // In case of loading as a web page with no bindings / harness, kick off initialization manually. |
+ if (InspectorFrontendHost.isStub) { |
+ // give a chance to add listeners of WebInspector.Target.Events.TargetIsReady |
+ setTimeout(this._loadedWithCapabilities.bind(this), 0); |
+ } |
+} |
+ |
+WebInspector.Target.Events = { |
+ TargetIsReady: "TargetIsReady" |
+} |
+ |
+WebInspector.Target.prototype = { |
+ |
+ _initializeCapability: function(name, callback, error, result) |
+ { |
+ this[name] = result; |
+ if (callback) |
+ callback(); |
+ }, |
+ |
+ _loadedWithCapabilities: function() |
+ { |
+ this.consoleModel = new WebInspector.ConsoleModel(this); |
+ this.networkManager = new WebInspector.NetworkManager(this); |
+ this.resourceTreeModel = new WebInspector.ResourceTreeModel(this); |
+ this.debuggerModel = new WebInspector.DebuggerModel(); |
+ this.runtimeModel = new WebInspector.RuntimeModel(this); |
+ |
+ this.dispatchEventToListeners(WebInspector.Target.Events.TargetIsReady); |
+ }, |
+ |
+ /** |
+ * @param {string} domain |
+ * @param {!Object} dispatcher |
+ */ |
+ registerDispatcher: function(domain, dispatcher) |
+ { |
+ this._connection.registerDispatcher(domain, dispatcher); |
+ }, |
+ |
+ /** |
+ * @param {string} domain |
+ * @return {!InspectorBackendClass.AgentPrototype} |
+ */ |
+ agent: function(domain) |
+ { |
+ return this._connection.agent(domain); |
+ }, |
+ |
+ __proto__: WebInspector.Object.prototype |
+} |
+ |
+/** |
+ * @constructor |
+ * @extends {WebInspector.Object} |
+ */ |
+WebInspector.TargetManager = function() |
+{ |
+ /** @type {!Array.<!WebInspector.Target>} */ |
+ this._targets = []; |
+} |
+ |
+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.
|
+ TargetSwitched: "TargetSwitched" |
+} |
+ |
+WebInspector.TargetManager.prototype = { |
+ |
+ /** |
+ * @param {!InspectorBackendClass.Connection} connection |
+ * @return {!WebInspector.Target} |
+ */ |
+ newConnectionAvailable: function(connection) |
vsevik
2014/03/05 12:34:49
How about createTarget(connection, callback) where
sergeyv
2014/03/05 15:02:51
Done.
|
+ { |
+ var newTarget = new WebInspector.Target(connection); |
+ this._targets.push(newTarget); |
+ return newTarget; |
+ }, |
+ |
+ __proto__: WebInspector.Object.prototype |
+} |