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..1dc4c70318e28d6386b7f2e20710e2192ad73245 |
--- /dev/null |
+++ b/Source/devtools/front_end/Target.js |
@@ -0,0 +1,90 @@ |
+/* |
+ * 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 {Protocol.Agents} |
+ * @param {!InspectorBackendClass.Connection} connection |
+ * @param {function(!WebInspector.Target)=} callback |
+ */ |
+WebInspector.Target = function(connection, callback) |
+{ |
+ Protocol.Agents.call(this, connection.agentsMap()); |
+ this._connection = connection; |
+ this.canInspectWorkers = false; |
+ |
+ this.pageAgent().canScreencast(this._initializeCapability.bind(this, "canScreencast", null)); |
+ this.workerAgent().canInspectWorkers(this._initializeCapability.bind(this, "canInspectWorkers", this._loadedWithCapabilities.bind(this, callback))); |
+ |
+ // 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, callback), 0); |
pfeldman
2014/03/08 16:07:17
This kills hosted mode - everything is initialized
|
+ } |
+} |
+ |
+WebInspector.Target.prototype = { |
+ |
+ _initializeCapability: function(name, callback, error, result) |
+ { |
+ this[name] = result; |
+ Capabilities[name] = result; |
+ if (callback) |
+ callback(); |
+ }, |
+ |
+ /** |
+ * @param {function(!WebInspector.Target)=} callback |
+ */ |
+ _loadedWithCapabilities: function(callback) |
+ { |
+ this.consoleModel = new WebInspector.ConsoleModel(); |
+ //This and similar lines are needed for compatibility |
+ WebInspector.console = this.consoleModel; |
+ this.networkManager = new WebInspector.NetworkManager(); |
+ WebInspector.networkManager = this.networkManager; |
+ this.resourceTreeModel = new WebInspector.ResourceTreeModel(this.networkManager); |
+ WebInspector.resourceTreeModel = this.resourceTreeModel; |
+ this.debuggerModel = new WebInspector.DebuggerModel(); |
+ WebInspector.debuggerModel = this.debuggerModel; |
+ this.runtimeModel = new WebInspector.RuntimeModel(this.resourceTreeModel); |
+ WebInspector.runtimeModel = this.runtimeModel; |
+ |
+ //we can't name it domAgent, because it clashes with function, WebInspector.DOMAgent should be renamed to DOMModel |
+ this._domAgent = new WebInspector.DOMAgent(); |
+ WebInspector.domAgent = this._domAgent; |
+ this.workerManager = new WebInspector.WorkerManager(this.canInspectWorkers); |
+ WebInspector.workerManager = this.workerManager; |
+ |
+ if (callback) |
+ callback(this); |
+ }, |
+ |
+ __proto__: Protocol.Agents.prototype |
+} |
+ |
+/** |
+ * @constructor |
+ */ |
+WebInspector.TargetManager = function() |
+{ |
+ /** @type {!Array.<!WebInspector.Target>} */ |
+ this._targets = []; |
+} |
+ |
+WebInspector.TargetManager.prototype = { |
+ |
+ /** |
+ * @param {!InspectorBackendClass.Connection} connection |
+ * @param {function(!WebInspector.Target)=} callback |
+ */ |
+ createTarget: function(connection, callback) |
+ { |
+ var newTarget = new WebInspector.Target(connection, callback); |
+ this._targets.push(newTarget); |
+ } |
+ |
+} |