Chromium Code Reviews| 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 WebInspector.userMetrics.drawerShown(viewId); | |
|
dgozman
2016/08/03 19:18:18
Let's only do this when
location === "drawer-view"
pfeldman
2016/08/03 21:52:18
Done.
| |
| 86 var extensions = self.runtime.extensions("view").filter(extension => ext ension.descriptor()["id"] === viewId); | |
| 87 if (!extensions.length) { | |
| 88 console.error("Could not find view for id: '" + viewId + "'"); | |
| 89 return; | |
| 90 } | |
| 91 var extension = extensions[0]; | |
| 92 var location = extensions[0].descriptor()["location"]; | |
| 93 var resolverExtensions = self.runtime.extensions(WebInspector.ViewLocati onResolver).filter(extension => extension.descriptor()["name"] === location); | |
| 94 if (!resolverExtensions.length) | |
| 95 return; | |
| 96 var resolverExtension = resolverExtensions[0]; | |
| 97 resolverExtension.instance().then(this._resolveLocation.bind(this, viewI d, location)); | |
| 98 }, | |
| 99 | |
| 100 /** | |
| 101 * @param {string} viewId | |
| 102 * @param {string} location | |
| 103 * @param {!WebInspector.ViewLocationResolver} resolver | |
| 104 */ | |
| 105 _resolveLocation: function(viewId, location, resolver) | |
| 106 { | |
| 107 var viewLocation = resolver.resolveLocation(location); | |
| 108 if (viewLocation) | |
| 109 viewLocation.showView(viewId); | |
| 110 } | |
| 111 } | |
| 112 | |
| 113 WebInspector.viewManager = new WebInspector.ViewManager(); | |
| OLD | NEW |