Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 /** | |
| 6 * @constructor | |
| 7 * @implements {WebInspector.TargetManager.Observer} | |
| 8 */ | |
| 9 WebInspector.TargetsToolbar = function() | |
| 10 { | |
| 11 this.element = document.createElement("div"); | |
| 12 this.element.className = "status-bar scripts-debug-toolbar threads-toolbar h idden"; | |
|
vsevik
2014/06/18 12:41:32
targets-toolbar
sergeyv
2014/06/18 16:50:08
Done.
| |
| 13 this._comboBox = new WebInspector.StatusBarComboBox(this._onComboBoxSelectio nChange.bind(this)); | |
| 14 this.element.appendChild(this._comboBox.element); | |
| 15 | |
| 16 /** @type {!Map.<!WebInspector.Target, !Element>} */ | |
| 17 this._targetToOption = new Map(); | |
| 18 if (!WebInspector.experimentsSettings.workersInMainWindow.isEnabled()) | |
| 19 return; | |
| 20 | |
| 21 WebInspector.executionContextSelector.addTargetChangeListener(this._targetCh angedExternally, this); | |
| 22 WebInspector.targetManager.observeTargets(this); | |
| 23 } | |
| 24 | |
| 25 WebInspector.TargetsToolbar.prototype = { | |
| 26 | |
| 27 /** | |
| 28 * @param {!WebInspector.Target} target | |
| 29 */ | |
| 30 targetAdded: function(target) | |
| 31 { | |
| 32 var option = this._comboBox.createOption(target.name()); | |
| 33 option.__target = target; | |
| 34 this._targetToOption.put(target, option); | |
| 35 if (WebInspector.executionContextSelector.currentTarget() === target) | |
| 36 this._comboBox.select(option); | |
| 37 | |
| 38 this._alterVisibility(); | |
| 39 }, | |
| 40 | |
| 41 /** | |
| 42 * @param {!WebInspector.Target} target | |
| 43 */ | |
| 44 targetRemoved: function(target) | |
| 45 { | |
| 46 var option = this._targetToOption.remove(target); | |
| 47 this._comboBox.removeOption(option); | |
| 48 this._alterVisibility(); | |
| 49 }, | |
| 50 | |
| 51 _onComboBoxSelectionChange: function() | |
| 52 { | |
| 53 var selectedOption = this._comboBox.selectedOption(); | |
| 54 if (!selectedOption) | |
| 55 return; | |
| 56 | |
| 57 WebInspector.executionContextSelector.setCurrentTarget(selectedOption.__ target); | |
| 58 }, | |
| 59 | |
| 60 _alterVisibility: function() | |
| 61 { | |
| 62 var hidden = this._comboBox.size() === 1; | |
| 63 this.element.classList.toggle("hidden", hidden); | |
| 64 }, | |
| 65 | |
| 66 /** | |
| 67 * @param {?WebInspector.Target} target | |
| 68 */ | |
| 69 _targetChangedExternally: function(target) | |
| 70 { | |
| 71 if (target) { | |
| 72 var option = /** @type {!Element} */ (this._targetToOption.get(targe t)) | |
| 73 this._comboBox.select(option); | |
| 74 } | |
| 75 } | |
| 76 | |
| 77 } | |
| OLD | NEW |