Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/ui/View.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/ui/View.js b/third_party/WebKit/Source/devtools/front_end/ui/View.js |
| index 8add5559f968f22a6cf94312fbbddf7f6db85288..20b1cc0554be722e547c0bb29cf01de03e9a1a3d 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/ui/View.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/ui/View.js |
| @@ -41,6 +41,8 @@ WebInspector.View.prototype = { |
| widget: function() { } |
| } |
| +WebInspector.View._symbol = Symbol("view"); |
| + |
| /** |
| * @constructor |
| * @extends {WebInspector.VBox} |
| @@ -54,6 +56,7 @@ WebInspector.SimpleView = function(title, isWebComponent) |
| this._title = title; |
| /** @type {!Array<!WebInspector.ToolbarItem>} */ |
| this._toolbarItems = []; |
| + this[WebInspector.View._symbol] = this; |
| } |
| WebInspector.SimpleView.prototype = { |
| @@ -191,6 +194,22 @@ WebInspector.ProvidedView.prototype = { |
| */ |
| toolbarItems: function() |
| { |
| + var actionIds = this._extension.descriptor()["actionIds"]; |
| + if (actionIds) { |
| + var result = [] |
| + for (var id of actionIds.split(",")) { |
| + var item = WebInspector.Toolbar.createActionButtonForId(id.trim()); |
| + if (item) |
| + result.push(item); |
| + } |
| + return Promise.resolve(result); |
| + } |
| + |
| + if (this._extension.descriptor()["hasToolbar"]) { |
| + return this.widget().then(widget => { |
| + return /** @type {!WebInspector.ToolbarItem.ItemsProvider} */ (widget).toolbarItems(); |
|
dgozman
2016/08/11 01:42:16
Drop { return }
|
| + }); |
| + } |
| return Promise.resolve([]); |
| }, |
| @@ -200,7 +219,12 @@ WebInspector.ProvidedView.prototype = { |
| */ |
| widget: function() |
| { |
| - return /** @type {!Promise<!WebInspector.Widget>} */ (this._extension.instance()); |
| + return this._extension.instance().then(widget => { |
| + if (!(widget instanceof WebInspector.Widget)) |
| + throw new Error("view className should point to a WebInspector.Widget"); |
| + widget[WebInspector.View._symbol] = this; |
| + return /** @type {!WebInspector.Widget} */ (widget); |
| + }); |
| } |
| } |
| @@ -281,6 +305,16 @@ WebInspector.ViewManager = function() |
| WebInspector.ViewManager.prototype = { |
| /** |
| + * @param {!WebInspector.Widget} widget |
| + */ |
| + revealViewWithWidget: function(widget) |
| + { |
| + var view = widget[WebInspector.View._symbol]; |
| + if (view) |
| + this.revealView(view); |
| + }, |
| + |
| + /** |
| * @param {!WebInspector.View} view |
| * @return {!Promise} |
| */ |