Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(766)

Unified Diff: Source/devtools/front_end/components/ExecutionContextSelector.js

Issue 338283004: DevTools: Use TargetsToolbar instead of ThreadToolbar (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address vsevik's comments Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/devtools/devtools.gypi ('k') | Source/devtools/front_end/console/ConsoleView.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/components/ExecutionContextSelector.js
diff --git a/Source/devtools/front_end/components/ExecutionContextSelector.js b/Source/devtools/front_end/components/ExecutionContextSelector.js
index 51967919cd27f3a9b6ae3fd44ade4f099ae3f0a4..b9c7773696f1d18c478c9704d1d1a13d380d9999 100644
--- a/Source/devtools/front_end/components/ExecutionContextSelector.js
+++ b/Source/devtools/front_end/components/ExecutionContextSelector.js
@@ -6,8 +6,11 @@
* @constructor
* @implements {WebInspector.TargetManager.Observer}
*/
-WebInspector.ExecutionContextSelector = function() {
+WebInspector.ExecutionContextSelector = function()
+{
WebInspector.targetManager.observeTargets(this);
+ WebInspector.context.addFlavorChangeListener(WebInspector.ExecutionContext, this._executionContextChanged, this);
+ WebInspector.context.addFlavorChangeListener(WebInspector.Target, this._targetChanged, this);
}
WebInspector.ExecutionContextSelector.prototype = {
@@ -17,6 +20,9 @@ WebInspector.ExecutionContextSelector.prototype = {
*/
targetAdded: function(target)
{
+ if (!WebInspector.context.flavor(WebInspector.Target))
+ WebInspector.context.setFlavor(WebInspector.Target, target);
+
target.runtimeModel.addEventListener(WebInspector.RuntimeModel.Events.ExecutionContextCreated, this._onExecutionContextCreated, this);
target.runtimeModel.addEventListener(WebInspector.RuntimeModel.Events.ExecutionContextDestroyed, this._onExecutionContextDestroyed, this);
},
@@ -28,8 +34,46 @@ WebInspector.ExecutionContextSelector.prototype = {
{
target.runtimeModel.removeEventListener(WebInspector.RuntimeModel.Events.ExecutionContextCreated, this._onExecutionContextCreated, this);
target.runtimeModel.removeEventListener(WebInspector.RuntimeModel.Events.ExecutionContextDestroyed, this._onExecutionContextDestroyed, this);
- if (WebInspector.context.flavor(WebInspector.ExecutionContext).target() === target)
+ var currentExecutionContext = WebInspector.context.flavor(WebInspector.Target);
+ if (currentExecutionContext && currentExecutionContext.target() === target)
this._currentExecutionContextGone();
+
+ var targets = WebInspector.targetManager.targets();
+ if (WebInspector.context.flavor(WebInspector.Target) === target && targets.length)
+ WebInspector.context.setFlavor(WebInspector.Target, targets[0]);
+ },
+
+ /**
+ * @param {!WebInspector.Event} event
+ */
+ _executionContextChanged: function(event)
+ {
+ var newContext = /** @type {?WebInspector.ExecutionContext} */ (event.data);
+ if (newContext)
+ WebInspector.context.setFlavor(WebInspector.Target, newContext.target());
+ },
+
+ /**
+ * @param {!WebInspector.Event} event
+ */
+ _targetChanged: function(event)
+ {
+ var newTarget = /** @type {?WebInspector.Target} */(event.data);
+ var currentContext = WebInspector.context.flavor(WebInspector.ExecutionContext);
+
+ if (!newTarget || (currentContext && currentContext.target() === newTarget))
+ return;
+
+ var executionContexts = newTarget.runtimeModel.executionContexts();
+ if (!executionContexts.length)
+ return;
+
+ var newContext = executionContexts[0];
+ for (var i = 1; i < executionContexts.length; ++i) {
+ if (executionContexts[i].isMainWorldContext)
+ newContext = executionContexts[i];
+ }
+ WebInspector.context.setFlavor(WebInspector.ExecutionContext, newContext);
},
/**
« no previous file with comments | « Source/devtools/devtools.gypi ('k') | Source/devtools/front_end/console/ConsoleView.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698