| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 /** | 4 /** |
| 5 * @implements {SDK.TargetManager.Observer} | 5 * @implements {SDK.TargetManager.Observer} |
| 6 * @unrestricted | 6 * @unrestricted |
| 7 */ | 7 */ |
| 8 Components.ExecutionContextSelector = class { | 8 Main.ExecutionContextSelector = class { |
| 9 /** | 9 /** |
| 10 * @param {!SDK.TargetManager} targetManager | 10 * @param {!SDK.TargetManager} targetManager |
| 11 * @param {!UI.Context} context | 11 * @param {!UI.Context} context |
| 12 */ | 12 */ |
| 13 constructor(targetManager, context) { | 13 constructor(targetManager, context) { |
| 14 targetManager.observeTargets(this, SDK.Target.Capability.JS); | 14 targetManager.observeTargets(this, SDK.Target.Capability.JS); |
| 15 context.addFlavorChangeListener(SDK.ExecutionContext, this._executionContext
Changed, this); | 15 context.addFlavorChangeListener(SDK.ExecutionContext, this._executionContext
Changed, this); |
| 16 context.addFlavorChangeListener(SDK.Target, this._targetChanged, this); | 16 context.addFlavorChangeListener(SDK.Target, this._targetChanged, this); |
| 17 | 17 |
| 18 targetManager.addModelListener( | 18 targetManager.addModelListener( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 29 /** | 29 /** |
| 30 * @override | 30 * @override |
| 31 * @param {!SDK.Target} target | 31 * @param {!SDK.Target} target |
| 32 */ | 32 */ |
| 33 targetAdded(target) { | 33 targetAdded(target) { |
| 34 // Defer selecting default target since we need all clients to get their | 34 // Defer selecting default target since we need all clients to get their |
| 35 // targetAdded notifications first. | 35 // targetAdded notifications first. |
| 36 setImmediate(deferred.bind(this)); | 36 setImmediate(deferred.bind(this)); |
| 37 | 37 |
| 38 /** | 38 /** |
| 39 * @this {Components.ExecutionContextSelector} | 39 * @this {Main.ExecutionContextSelector} |
| 40 */ | 40 */ |
| 41 function deferred() { | 41 function deferred() { |
| 42 // We always want the second context for the service worker targets. | 42 // We always want the second context for the service worker targets. |
| 43 if (!this._context.flavor(SDK.Target)) | 43 if (!this._context.flavor(SDK.Target)) |
| 44 this._context.setFlavor(SDK.Target, target); | 44 this._context.setFlavor(SDK.Target, target); |
| 45 } | 45 } |
| 46 } | 46 } |
| 47 | 47 |
| 48 /** | 48 /** |
| 49 * @override | 49 * @override |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 newContext = executionContexts[0]; | 196 newContext = executionContexts[0]; |
| 197 break; | 197 break; |
| 198 } | 198 } |
| 199 } | 199 } |
| 200 } | 200 } |
| 201 this._ignoreContextChanged = true; | 201 this._ignoreContextChanged = true; |
| 202 this._context.setFlavor(SDK.ExecutionContext, newContext); | 202 this._context.setFlavor(SDK.ExecutionContext, newContext); |
| 203 this._ignoreContextChanged = false; | 203 this._ignoreContextChanged = false; |
| 204 } | 204 } |
| 205 }; | 205 }; |
| OLD | NEW |