| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * @constructor |
| 7 * @extends {WebInspector.VBox} |
| 8 * @param {string} title |
| 9 * @param {boolean=} isWebComponent |
| 10 */ |
| 11 WebInspector.View = function(title, isWebComponent) |
| 12 { |
| 13 WebInspector.VBox.call(this, isWebComponent); |
| 14 this._title = title; |
| 15 /** @type {!Array<!WebInspector.ToolbarItem>} */ |
| 16 this._toolbarItems = []; |
| 17 } |
| 18 |
| 19 WebInspector.View.prototype = { |
| 20 /** |
| 21 * @return {string} |
| 22 */ |
| 23 title: function() |
| 24 { |
| 25 return this._title; |
| 26 }, |
| 27 |
| 28 /** |
| 29 * @param {!WebInspector.ToolbarItem} item |
| 30 */ |
| 31 addToolbarItem: function(item) |
| 32 { |
| 33 this._toolbarItems.push(item); |
| 34 }, |
| 35 |
| 36 /** |
| 37 * @return {!Array<!WebInspector.ToolbarItem>} |
| 38 */ |
| 39 toolbarItems: function() |
| 40 { |
| 41 return this._toolbarItems; |
| 42 }, |
| 43 |
| 44 __proto__: WebInspector.VBox.prototype |
| 45 } |
| 46 |
| 47 /** |
| 48 * @interface |
| 49 */ |
| 50 WebInspector.ViewLocation = function() { } |
| 51 |
| 52 WebInspector.ViewLocation.prototype = { |
| 53 /** |
| 54 * @param {string} viewId |
| 55 */ |
| 56 showView: function(viewId) { } |
| 57 } |
| 58 |
| 59 /** |
| 60 * @interface |
| 61 */ |
| 62 WebInspector.ViewLocationResolver = function() { } |
| 63 |
| 64 WebInspector.ViewLocationResolver.prototype = { |
| 65 /** |
| 66 * @param {string} locationName |
| 67 * @return {?WebInspector.ViewLocation} |
| 68 */ |
| 69 resolveLocation: function(locationName) { } |
| 70 } |
| 71 |
| 72 /** |
| 73 * @constructor |
| 74 */ |
| 75 WebInspector.ViewManager = function() |
| 76 { |
| 77 } |
| 78 |
| 79 WebInspector.ViewManager.prototype = { |
| 80 /** |
| 81 * @param {string} viewId |
| 82 */ |
| 83 showView: function(viewId) |
| 84 { |
| 85 var extensions = self.runtime.extensions("view").filter(extension => ext
ension.descriptor()["id"] === viewId); |
| 86 if (!extensions.length) { |
| 87 console.error("Could not find view for id: '" + viewId + "'"); |
| 88 return; |
| 89 } |
| 90 var extension = extensions[0]; |
| 91 var location = extensions[0].descriptor()["location"]; |
| 92 if (location === "drawer-view") |
| 93 WebInspector.userMetrics.drawerShown(viewId); |
| 94 var resolverExtensions = self.runtime.extensions(WebInspector.ViewLocati
onResolver).filter(extension => extension.descriptor()["name"] === location); |
| 95 if (!resolverExtensions.length) |
| 96 return; |
| 97 var resolverExtension = resolverExtensions[0]; |
| 98 resolverExtension.instance().then(this._resolveLocation.bind(this, viewI
d, location)); |
| 99 }, |
| 100 |
| 101 /** |
| 102 * @param {string} viewId |
| 103 * @param {string} location |
| 104 * @param {!WebInspector.ViewLocationResolver} resolver |
| 105 */ |
| 106 _resolveLocation: function(viewId, location, resolver) |
| 107 { |
| 108 var viewLocation = resolver.resolveLocation(location); |
| 109 if (viewLocation) |
| 110 viewLocation.showView(viewId); |
| 111 } |
| 112 } |
| 113 |
| 114 WebInspector.viewManager = new WebInspector.ViewManager(); |
| OLD | NEW |