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

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

Issue 2793873002: DevTools: Update CommandMenuProvider on attach instead of construction (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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 */ 106 */
107 commands() { 107 commands() {
108 return this._commands; 108 return this._commands;
109 } 109 }
110 }; 110 };
111 111
112 QuickOpen.CommandMenuProvider = class extends QuickOpen.FilteredListWidget.Provi der { 112 QuickOpen.CommandMenuProvider = class extends QuickOpen.FilteredListWidget.Provi der {
113 constructor() { 113 constructor() {
114 super(); 114 super();
115 this._commands = []; 115 this._commands = [];
116 this._appendAvailableCommands();
117 } 116 }
118 117
119 _appendAvailableCommands() { 118 /**
119 * @override
120 */
121 attach() {
120 var allCommands = QuickOpen.commandMenu.commands(); 122 var allCommands = QuickOpen.commandMenu.commands();
121 123
122 // Populate whitelisted actions. 124 // Populate whitelisted actions.
123 var actions = UI.actionRegistry.availableActions(); 125 var actions = UI.actionRegistry.availableActions();
124 for (var action of actions) { 126 for (var action of actions) {
125 if (action.category()) 127 if (action.category())
126 this._commands.push(QuickOpen.CommandMenu.createActionCommand(action)); 128 this._commands.push(QuickOpen.CommandMenu.createActionCommand(action));
127 } 129 }
128 130
129 for (var command of allCommands) { 131 for (var command of allCommands) {
130 if (command.available()) 132 if (command.available())
131 this._commands.push(command); 133 this._commands.push(command);
132 } 134 }
133 135
134 this._commands = this._commands.sort(commandComparator); 136 this._commands = this._commands.sort(commandComparator);
135 137
136 /** 138 /**
137 * @param {!QuickOpen.CommandMenu.Command} left 139 * @param {!QuickOpen.CommandMenu.Command} left
138 * @param {!QuickOpen.CommandMenu.Command} right 140 * @param {!QuickOpen.CommandMenu.Command} right
139 * @return {number} 141 * @return {number}
140 */ 142 */
141 function commandComparator(left, right) { 143 function commandComparator(left, right) {
142 var cats = left.category().compareTo(right.category()); 144 var cats = left.category().compareTo(right.category());
143 return cats ? cats : left.title().compareTo(right.title()); 145 return cats ? cats : left.title().compareTo(right.title());
144 } 146 }
145 } 147 }
146 148
147 /** 149 /**
148 * @override 150 * @override
151 */
152 detach() {
153 this._commands = [];
154 }
155
156 /**
157 * @override
149 * @return {number} 158 * @return {number}
150 */ 159 */
151 itemCount() { 160 itemCount() {
152 return this._commands.length; 161 return this._commands.length;
153 } 162 }
154 163
155 /** 164 /**
156 * @override 165 * @override
157 * @param {number} itemIndex 166 * @param {number} itemIndex
158 * @return {string} 167 * @return {string}
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 * @override 314 * @override
306 * @param {!UI.Context} context 315 * @param {!UI.Context} context
307 * @param {string} actionId 316 * @param {string} actionId
308 * @return {boolean} 317 * @return {boolean}
309 */ 318 */
310 handleAction(context, actionId) { 319 handleAction(context, actionId) {
311 QuickOpen.QuickOpen.show('>'); 320 QuickOpen.QuickOpen.show('>');
312 return true; 321 return true;
313 } 322 }
314 }; 323 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698