Index: third_party/WebKit/Source/devtools/front_end/console/ConsoleContextSelector.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/console/ConsoleContextSelector.js b/third_party/WebKit/Source/devtools/front_end/console/ConsoleContextSelector.js |
index a7436d5c505ba9c66b9712175e72f9dd6e057f53..c6c0d3fbee6436d88c7ac4a7bb54bbb5ea6fa3d8 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/console/ConsoleContextSelector.js |
+++ b/third_party/WebKit/Source/devtools/front_end/console/ConsoleContextSelector.js |
@@ -7,6 +7,28 @@ |
*/ |
Console.ConsoleContextSelector = class { |
/** |
+ * @param {!SDK.ExecutionContext} executionContext |
+ * @param {boolean} formatForSelector |
+ * @return {string} |
+ */ |
+ static titleForContext(executionContext, formatForSelector) { |
+ var result = executionContext.label(formatForSelector /* showStatus */) || executionContext.origin; |
+ if (executionContext.isDefault && executionContext.frameId) { |
+ var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(executionContext.target()); |
+ var frame = resourceTreeModel && resourceTreeModel.frameForId(executionContext.frameId); |
+ result = frame ? frame.displayName() : result; |
+ } |
+ result = executionContext.target().decorateLabel(result); |
luoe
2017/01/19 23:22:59
It turns out that browser extensions can load dedi
|
+ |
+ if (formatForSelector) { |
+ if (!executionContext.isDefault) |
+ result = '\u00a0\u00a0\u00a0\u00a0' + result; |
+ result = result.trimMiddle(50); |
+ } |
luoe
2017/01/19 23:22:59
Since the presentation logic for titles in the sel
|
+ return result; |
+ } |
+ |
+ /** |
* @param {!Element} selectElement |
*/ |
constructor(selectElement) { |
@@ -30,28 +52,6 @@ Console.ConsoleContextSelector = class { |
/** |
* @param {!SDK.ExecutionContext} executionContext |
- * @return {string} |
- */ |
- _titleFor(executionContext) { |
- var result; |
- if (executionContext.isDefault) { |
- if (executionContext.frameId) { |
- var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(executionContext.target()); |
- var frame = resourceTreeModel && resourceTreeModel.frameForId(executionContext.frameId); |
- result = frame ? frame.displayName() : executionContext.label(); |
- } else { |
- result = executionContext.target().decorateLabel(executionContext.label()); |
- } |
- } else { |
- result = '\u00a0\u00a0\u00a0\u00a0' + (executionContext.label() || executionContext.origin); |
- } |
- |
- var maxLength = 50; |
- return result.trimMiddle(maxLength); |
- } |
- |
- /** |
- * @param {!SDK.ExecutionContext} executionContext |
*/ |
_executionContextCreated(executionContext) { |
// FIXME(413886): We never want to show execution context for the main thread of shadow page in service/shared worker frontend. |
@@ -61,7 +61,7 @@ Console.ConsoleContextSelector = class { |
var newOption = createElement('option'); |
newOption.__executionContext = executionContext; |
- newOption.text = this._titleFor(executionContext); |
+ newOption.text = Console.ConsoleContextSelector.titleForContext(executionContext, true /* formatForSelector */); |
this._optionByExecutionContext.set(executionContext, newOption); |
var options = this._selectElement.options; |
var contexts = Array.prototype.map.call(options, mapping); |
@@ -96,7 +96,7 @@ Console.ConsoleContextSelector = class { |
var executionContext = /** @type {!SDK.ExecutionContext} */ (event.data); |
var option = this._optionByExecutionContext.get(executionContext); |
if (option) |
- option.text = this._titleFor(executionContext); |
+ option.text = Console.ConsoleContextSelector.titleForContext(executionContext, true /* formatForSelector */); |
this._updateSelectionWarning(); |
} |