Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 /** | 5 /** |
| 6 * @interface | 6 * @interface |
| 7 */ | 7 */ |
| 8 WebInspector.View = function() | 8 WebInspector.View = function() |
| 9 { | 9 { |
| 10 } | 10 } |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 * @return {!Promise<!Array<!WebInspector.ToolbarItem>>} | 34 * @return {!Promise<!Array<!WebInspector.ToolbarItem>>} |
| 35 */ | 35 */ |
| 36 toolbarItems: function() { }, | 36 toolbarItems: function() { }, |
| 37 | 37 |
| 38 /** | 38 /** |
| 39 * @return {!Promise<!WebInspector.Widget>} | 39 * @return {!Promise<!WebInspector.Widget>} |
| 40 */ | 40 */ |
| 41 widget: function() { } | 41 widget: function() { } |
| 42 } | 42 } |
| 43 | 43 |
| 44 WebInspector.View._symbol = Symbol("view"); | |
| 45 | |
| 44 /** | 46 /** |
| 45 * @constructor | 47 * @constructor |
| 46 * @extends {WebInspector.VBox} | 48 * @extends {WebInspector.VBox} |
| 47 * @implements {WebInspector.View} | 49 * @implements {WebInspector.View} |
| 48 * @param {string} title | 50 * @param {string} title |
| 49 * @param {boolean=} isWebComponent | 51 * @param {boolean=} isWebComponent |
| 50 */ | 52 */ |
| 51 WebInspector.SimpleView = function(title, isWebComponent) | 53 WebInspector.SimpleView = function(title, isWebComponent) |
| 52 { | 54 { |
| 53 WebInspector.VBox.call(this, isWebComponent); | 55 WebInspector.VBox.call(this, isWebComponent); |
| 54 this._title = title; | 56 this._title = title; |
| 55 /** @type {!Array<!WebInspector.ToolbarItem>} */ | 57 /** @type {!Array<!WebInspector.ToolbarItem>} */ |
| 56 this._toolbarItems = []; | 58 this._toolbarItems = []; |
| 59 this[WebInspector.View._symbol] = this; | |
| 57 } | 60 } |
| 58 | 61 |
| 59 WebInspector.SimpleView.prototype = { | 62 WebInspector.SimpleView.prototype = { |
| 60 /** | 63 /** |
| 61 * @override | 64 * @override |
| 62 * @return {string} | 65 * @return {string} |
| 63 */ | 66 */ |
| 64 viewId: function() | 67 viewId: function() |
| 65 { | 68 { |
| 66 return this._title; | 69 return this._title; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 184 { | 187 { |
| 185 return this._extension.descriptor()["persistence"] === "transient"; | 188 return this._extension.descriptor()["persistence"] === "transient"; |
| 186 }, | 189 }, |
| 187 | 190 |
| 188 /** | 191 /** |
| 189 * @override | 192 * @override |
| 190 * @return {!Promise<!Array<!WebInspector.ToolbarItem>>} | 193 * @return {!Promise<!Array<!WebInspector.ToolbarItem>>} |
| 191 */ | 194 */ |
| 192 toolbarItems: function() | 195 toolbarItems: function() |
| 193 { | 196 { |
| 197 var actionIds = this._extension.descriptor()["actionIds"]; | |
| 198 if (actionIds) { | |
| 199 var result = [] | |
| 200 for (var id of actionIds.split(",")) { | |
| 201 var item = WebInspector.Toolbar.createActionButtonForId(id.trim( )); | |
| 202 if (item) | |
| 203 result.push(item); | |
| 204 } | |
| 205 return Promise.resolve(result); | |
| 206 } | |
| 207 | |
| 208 if (this._extension.descriptor()["hasToolbar"]) { | |
| 209 return this.widget().then(widget => { | |
| 210 return /** @type {!WebInspector.ToolbarItem.ItemsProvider} */ (w idget).toolbarItems(); | |
|
dgozman
2016/08/11 01:42:16
Drop { return }
| |
| 211 }); | |
| 212 } | |
| 194 return Promise.resolve([]); | 213 return Promise.resolve([]); |
| 195 }, | 214 }, |
| 196 | 215 |
| 197 /** | 216 /** |
| 198 * @override | 217 * @override |
| 199 * @return {!Promise<!WebInspector.Widget>} | 218 * @return {!Promise<!WebInspector.Widget>} |
| 200 */ | 219 */ |
| 201 widget: function() | 220 widget: function() |
| 202 { | 221 { |
| 203 return /** @type {!Promise<!WebInspector.Widget>} */ (this._extension.i nstance()); | 222 return this._extension.instance().then(widget => { |
| 223 if (!(widget instanceof WebInspector.Widget)) | |
| 224 throw new Error("view className should point to a WebInspector.W idget"); | |
| 225 widget[WebInspector.View._symbol] = this; | |
| 226 return /** @type {!WebInspector.Widget} */ (widget); | |
| 227 }); | |
| 204 } | 228 } |
| 205 } | 229 } |
| 206 | 230 |
| 207 /** | 231 /** |
| 208 * @interface | 232 * @interface |
| 209 */ | 233 */ |
| 210 WebInspector.ViewLocation = function() { } | 234 WebInspector.ViewLocation = function() { } |
| 211 | 235 |
| 212 WebInspector.ViewLocation.prototype = { | 236 WebInspector.ViewLocation.prototype = { |
| 213 /** | 237 /** |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 | 298 |
| 275 for (var extension of self.runtime.extensions("view")) { | 299 for (var extension of self.runtime.extensions("view")) { |
| 276 var descriptor = extension.descriptor(); | 300 var descriptor = extension.descriptor(); |
| 277 this._views.set(descriptor["id"], new WebInspector.ProvidedView(extensio n)); | 301 this._views.set(descriptor["id"], new WebInspector.ProvidedView(extensio n)); |
| 278 this._locationNameByViewId.set(descriptor["id"], descriptor["location"]) ; | 302 this._locationNameByViewId.set(descriptor["id"], descriptor["location"]) ; |
| 279 } | 303 } |
| 280 } | 304 } |
| 281 | 305 |
| 282 WebInspector.ViewManager.prototype = { | 306 WebInspector.ViewManager.prototype = { |
| 283 /** | 307 /** |
| 308 * @param {!WebInspector.Widget} widget | |
| 309 */ | |
| 310 revealViewWithWidget: function(widget) | |
| 311 { | |
| 312 var view = widget[WebInspector.View._symbol]; | |
| 313 if (view) | |
| 314 this.revealView(view); | |
| 315 }, | |
| 316 | |
| 317 /** | |
| 284 * @param {!WebInspector.View} view | 318 * @param {!WebInspector.View} view |
| 285 * @return {!Promise} | 319 * @return {!Promise} |
| 286 */ | 320 */ |
| 287 revealView: function(view) | 321 revealView: function(view) |
| 288 { | 322 { |
| 289 var location = /** @type {?WebInspector.ViewManager._Location} */ (view[ WebInspector.ViewManager._Location.symbol]); | 323 var location = /** @type {?WebInspector.ViewManager._Location} */ (view[ WebInspector.ViewManager._Location.symbol]); |
| 290 if (!location) | 324 if (!location) |
| 291 return Promise.resolve(); | 325 return Promise.resolve(); |
| 292 location._reveal(); | 326 location._reveal(); |
| 293 return location.showView(view); | 327 return location.showView(view); |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 775 this.appendView(view); | 809 this.appendView(view); |
| 776 }, | 810 }, |
| 777 | 811 |
| 778 __proto__: WebInspector.ViewManager._Location.prototype | 812 __proto__: WebInspector.ViewManager._Location.prototype |
| 779 } | 813 } |
| 780 | 814 |
| 781 /** | 815 /** |
| 782 * @type {!WebInspector.ViewManager} | 816 * @type {!WebInspector.ViewManager} |
| 783 */ | 817 */ |
| 784 WebInspector.viewManager; | 818 WebInspector.viewManager; |
| OLD | NEW |