Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 Console.ConsoleContextSelector = class { | 8 Console.ConsoleContextSelector = class { |
| 9 /** | 9 /** |
| 10 * @param {!Element} selectElement | 10 * @param {!Element} selectElement |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 | 26 |
| 27 this._selectElement.addEventListener('change', this._executionContextChanged .bind(this), false); | 27 this._selectElement.addEventListener('change', this._executionContextChanged .bind(this), false); |
| 28 UI.context.addFlavorChangeListener(SDK.ExecutionContext, this._executionCont extChangedExternally, this); | 28 UI.context.addFlavorChangeListener(SDK.ExecutionContext, this._executionCont extChangedExternally, this); |
| 29 } | 29 } |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @param {!SDK.ExecutionContext} executionContext | 32 * @param {!SDK.ExecutionContext} executionContext |
| 33 * @return {string} | 33 * @return {string} |
| 34 */ | 34 */ |
| 35 _titleFor(executionContext) { | 35 _titleFor(executionContext) { |
| 36 var result; | 36 var target = executionContext.target(); |
|
pfeldman
2017/01/21 02:21:24
According to the new guidelines, you should use co
pfeldman
2017/01/21 02:22:49
My bad, it should be let.
| |
| 37 if (executionContext.isDefault) { | 37 var depth = 0; |
| 38 if (executionContext.frameId) { | 38 var label = executionContext.label() ? target.decorateLabel(executionContext .label()) : ''; |
| 39 var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(executionContex t.target()); | 39 if (!executionContext.isDefault) |
| 40 var frame = resourceTreeModel && resourceTreeModel.frameForId(executionC ontext.frameId); | 40 depth++; |
| 41 result = frame ? frame.displayName() : executionContext.label(); | 41 if (executionContext.frameId) { |
| 42 } else { | 42 var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(target); |
| 43 result = executionContext.target().decorateLabel(executionContext.label( )); | 43 var frame = resourceTreeModel && resourceTreeModel.frameForId(executionCon text.frameId); |
| 44 if (frame) { | |
| 45 label = label || frame.displayName(); | |
| 46 while (frame.parentFrame) { | |
| 47 depth++; | |
| 48 frame = frame.parentFrame; | |
| 49 } | |
| 44 } | 50 } |
| 45 } else { | 51 } |
| 46 result = '\u00a0\u00a0\u00a0\u00a0' + (executionContext.label() || executi onContext.origin); | 52 label = label || executionContext.origin; |
| 53 while (target.parentTarget()) { | |
| 54 if (target.parentTarget().hasJSCapability()) | |
|
pfeldman
2017/01/21 02:27:31
Special case service workers?
dgozman
2017/01/23 19:20:35
Done.
| |
| 55 depth++; | |
| 56 target = target.parentTarget(); | |
| 47 } | 57 } |
| 48 | 58 |
| 59 var prefix = new Array(4 * depth + 1).join('\u00a0'); | |
| 49 var maxLength = 50; | 60 var maxLength = 50; |
| 50 return result.trimMiddle(maxLength); | 61 return (prefix + label).trimMiddle(maxLength); |
| 51 } | 62 } |
| 52 | 63 |
| 53 /** | 64 /** |
| 54 * @param {!SDK.ExecutionContext} executionContext | 65 * @param {!SDK.ExecutionContext} executionContext |
| 55 */ | 66 */ |
| 56 _executionContextCreated(executionContext) { | 67 _executionContextCreated(executionContext) { |
| 57 // FIXME(413886): We never want to show execution context for the main threa d of shadow page in service/shared worker frontend. | 68 // FIXME(413886): We never want to show execution context for the main threa d of shadow page in service/shared worker frontend. |
| 58 // This check could be removed once we do not send this context to frontend. | 69 // This check could be removed once we do not send this context to frontend. |
| 59 if (!executionContext.target().hasJSCapability()) | 70 if (!executionContext.target().hasJSCapability()) |
| 60 return; | 71 return; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 201 | 212 |
| 202 /** | 213 /** |
| 203 * @return {?Element} | 214 * @return {?Element} |
| 204 */ | 215 */ |
| 205 _selectedOption() { | 216 _selectedOption() { |
| 206 if (this._selectElement.selectedIndex >= 0) | 217 if (this._selectElement.selectedIndex >= 0) |
| 207 return this._selectElement[this._selectElement.selectedIndex]; | 218 return this._selectElement[this._selectElement.selectedIndex]; |
| 208 return null; | 219 return null; |
| 209 } | 220 } |
| 210 }; | 221 }; |
| OLD | NEW |