Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/quick_open/CommandMenu.js

Issue 2815373003: DevTools: Add more views to command menu (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 * @unrestricted 5 * @unrestricted
6 */ 6 */
7 QuickOpen.CommandMenu = class { 7 QuickOpen.CommandMenu = class {
8 constructor() { 8 constructor() {
9 this._commands = []; 9 this._commands = [];
10 this._loadCommands(); 10 this._loadCommands();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 static createRevealPanelCommand(extension) { 64 static createRevealPanelCommand(extension) {
65 var panelId = extension.descriptor()['id']; 65 var panelId = extension.descriptor()['id'];
66 var executeHandler = UI.viewManager.showView.bind(UI.viewManager, panelId); 66 var executeHandler = UI.viewManager.showView.bind(UI.viewManager, panelId);
67 var tags = extension.descriptor()['tags'] || ''; 67 var tags = extension.descriptor()['tags'] || '';
68 return QuickOpen.CommandMenu.createCommand( 68 return QuickOpen.CommandMenu.createCommand(
69 Common.UIString('Panel'), tags, Common.UIString('Show %s', extension.tit le()), '', executeHandler); 69 Common.UIString('Panel'), tags, Common.UIString('Show %s', extension.tit le()), '', executeHandler);
70 } 70 }
71 71
72 /** 72 /**
73 * @param {!Runtime.Extension} extension 73 * @param {!Runtime.Extension} extension
74 * @param {string} category
74 * @return {!QuickOpen.CommandMenu.Command} 75 * @return {!QuickOpen.CommandMenu.Command}
75 */ 76 */
76 static createRevealDrawerCommand(extension) { 77 static createRevealViewCommand(extension, category) {
77 var drawerId = extension.descriptor()['id']; 78 var viewId = extension.descriptor()['id'];
78 var executeHandler = UI.viewManager.showView.bind(UI.viewManager, drawerId); 79 var executeHandler = UI.viewManager.showView.bind(UI.viewManager, viewId);
79 var tags = extension.descriptor()['tags'] || ''; 80 var tags = extension.descriptor()['tags'] || '';
80 return QuickOpen.CommandMenu.createCommand( 81 return QuickOpen.CommandMenu.createCommand(
81 Common.UIString('Drawer'), tags, Common.UIString('Show %s', extension.ti tle()), '', executeHandler); 82 category, tags, Common.UIString('Show %s', extension.title()), '', execu teHandler);
82 } 83 }
83 84
84 _loadCommands() { 85 _loadCommands() {
86 var locations = new Map();
87 self.runtime.extensions(UI.ViewLocationResolver).forEach(extension => {
88 var category = extension.descriptor()['category'];
89 var name = extension.descriptor()['name'];
90 if (category && name)
91 locations.set(name, category);
92 });
85 var viewExtensions = self.runtime.extensions('view'); 93 var viewExtensions = self.runtime.extensions('view');
86 for (var extension of viewExtensions) { 94 for (var extension of viewExtensions) {
87 if (extension.descriptor()['location'] === 'panel') 95 var location = extension.descriptor()['location'];
96 if (location === 'panel')
pfeldman 2017/04/17 23:15:54 We are missing a resolver for the panels, you shou
einbinder 2017/04/17 23:52:06 Done.
88 this._commands.push(QuickOpen.CommandMenu.createRevealPanelCommand(exten sion)); 97 this._commands.push(QuickOpen.CommandMenu.createRevealPanelCommand(exten sion));
89 else if (extension.descriptor()['location'] === 'drawer-view') 98 else if (locations.has(location))
90 this._commands.push(QuickOpen.CommandMenu.createRevealDrawerCommand(exte nsion)); 99 this._commands.push(QuickOpen.CommandMenu.createRevealViewCommand(extens ion, locations.get(location)));
91 } 100 }
92 101
93 // Populate whitelisted settings. 102 // Populate whitelisted settings.
94 var settingExtensions = self.runtime.extensions('setting'); 103 var settingExtensions = self.runtime.extensions('setting');
95 for (var extension of settingExtensions) { 104 for (var extension of settingExtensions) {
96 var options = extension.descriptor()['options']; 105 var options = extension.descriptor()['options'];
97 if (!options || !extension.descriptor()['category']) 106 if (!options || !extension.descriptor()['category'])
98 continue; 107 continue;
99 for (var pair of options) 108 for (var pair of options)
100 this._commands.push(QuickOpen.CommandMenu.createSettingCommand(extension , pair['title'], pair['value'])); 109 this._commands.push(QuickOpen.CommandMenu.createSettingCommand(extension , pair['title'], pair['value']));
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 * @override 323 * @override
315 * @param {!UI.Context} context 324 * @param {!UI.Context} context
316 * @param {string} actionId 325 * @param {string} actionId
317 * @return {boolean} 326 * @return {boolean}
318 */ 327 */
319 handleAction(context, actionId) { 328 handleAction(context, actionId) {
320 QuickOpen.QuickOpen.show('>'); 329 QuickOpen.QuickOpen.show('>');
321 return true; 330 return true;
322 } 331 }
323 }; 332 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698