| 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 | |
| 5 /** | 4 /** |
| 6 * @constructor | 5 * @unrestricted |
| 7 */ | 6 */ |
| 8 WebInspector.CommandMenu = function() | 7 WebInspector.CommandMenu = class { |
| 9 { | 8 constructor() { |
| 10 this._commands = []; | 9 this._commands = []; |
| 11 this._loadCommands(); | 10 this._loadCommands(); |
| 11 } |
| 12 |
| 13 /** |
| 14 * @param {string} category |
| 15 * @param {string} keys |
| 16 * @param {string} title |
| 17 * @param {string} shortcut |
| 18 * @param {function()} executeHandler |
| 19 * @param {function()=} availableHandler |
| 20 * @return {!WebInspector.CommandMenu.Command} |
| 21 */ |
| 22 static createCommand(category, keys, title, shortcut, executeHandler, availabl
eHandler) { |
| 23 // Separate keys by null character, to prevent fuzzy matching from matching
across them. |
| 24 var key = keys.replace(/,/g, '\0'); |
| 25 return new WebInspector.CommandMenu.Command(category, title, key, shortcut,
executeHandler, availableHandler); |
| 26 } |
| 27 |
| 28 /** |
| 29 * @param {!Runtime.Extension} extension |
| 30 * @param {string} title |
| 31 * @param {V} value |
| 32 * @return {!WebInspector.CommandMenu.Command} |
| 33 * @template V |
| 34 */ |
| 35 static createSettingCommand(extension, title, value) { |
| 36 var category = extension.descriptor()['category'] || ''; |
| 37 var tags = extension.descriptor()['tags'] || ''; |
| 38 var setting = WebInspector.settings.moduleSetting(extension.descriptor()['se
ttingName']); |
| 39 return WebInspector.CommandMenu.createCommand( |
| 40 category, tags, title, '', setting.set.bind(setting, value), availableHa
ndler); |
| 41 |
| 42 /** |
| 43 * @return {boolean} |
| 44 */ |
| 45 function availableHandler() { |
| 46 return setting.get() !== value; |
| 47 } |
| 48 } |
| 49 |
| 50 /** |
| 51 * @param {!WebInspector.Action} action |
| 52 * @return {!WebInspector.CommandMenu.Command} |
| 53 */ |
| 54 static createActionCommand(action) { |
| 55 var shortcut = WebInspector.shortcutRegistry.shortcutTitleForAction(action.i
d()) || ''; |
| 56 return WebInspector.CommandMenu.createCommand( |
| 57 action.category(), action.tags(), action.title(), shortcut, action.execu
te.bind(action)); |
| 58 } |
| 59 |
| 60 /** |
| 61 * @param {!Runtime.Extension} extension |
| 62 * @return {!WebInspector.CommandMenu.Command} |
| 63 */ |
| 64 static createRevealPanelCommand(extension) { |
| 65 var panelName = extension.descriptor()['name']; |
| 66 var tags = extension.descriptor()['tags'] || ''; |
| 67 return WebInspector.CommandMenu.createCommand( |
| 68 WebInspector.UIString('Panel'), tags, WebInspector.UIString('Show %s', e
xtension.title()), '', executeHandler, |
| 69 availableHandler); |
| 70 |
| 71 /** |
| 72 * @return {boolean} |
| 73 */ |
| 74 function availableHandler() { |
| 75 return true; |
| 76 } |
| 77 |
| 78 function executeHandler() { |
| 79 WebInspector.viewManager.showView(panelName); |
| 80 } |
| 81 } |
| 82 |
| 83 /** |
| 84 * @param {!Runtime.Extension} extension |
| 85 * @return {!WebInspector.CommandMenu.Command} |
| 86 */ |
| 87 static createRevealDrawerCommand(extension) { |
| 88 var drawerId = extension.descriptor()['id']; |
| 89 var executeHandler = WebInspector.viewManager.showView.bind(WebInspector.vie
wManager, drawerId); |
| 90 var tags = extension.descriptor()['tags'] || ''; |
| 91 return WebInspector.CommandMenu.createCommand( |
| 92 WebInspector.UIString('Drawer'), tags, WebInspector.UIString('Show %s',
extension.title()), '', executeHandler); |
| 93 } |
| 94 |
| 95 _loadCommands() { |
| 96 // Populate panels. |
| 97 var panelExtensions = self.runtime.extensions(WebInspector.Panel); |
| 98 for (var extension of panelExtensions) |
| 99 this._commands.push(WebInspector.CommandMenu.createRevealPanelCommand(exte
nsion)); |
| 100 |
| 101 // Populate drawers. |
| 102 var drawerExtensions = self.runtime.extensions('view'); |
| 103 for (var extension of drawerExtensions) { |
| 104 if (extension.descriptor()['location'] !== 'drawer-view') |
| 105 continue; |
| 106 this._commands.push(WebInspector.CommandMenu.createRevealDrawerCommand(ext
ension)); |
| 107 } |
| 108 |
| 109 // Populate whitelisted settings. |
| 110 var settingExtensions = self.runtime.extensions('setting'); |
| 111 for (var extension of settingExtensions) { |
| 112 var options = extension.descriptor()['options']; |
| 113 if (!options || !extension.descriptor()['category']) |
| 114 continue; |
| 115 for (var pair of options) |
| 116 this._commands.push(WebInspector.CommandMenu.createSettingCommand(extens
ion, pair['title'], pair['value'])); |
| 117 } |
| 118 } |
| 119 |
| 120 /** |
| 121 * @return {!Array.<!WebInspector.CommandMenu.Command>} |
| 122 */ |
| 123 commands() { |
| 124 return this._commands; |
| 125 } |
| 12 }; | 126 }; |
| 13 | 127 |
| 14 WebInspector.CommandMenu.prototype = { | |
| 15 _loadCommands: function() | |
| 16 { | |
| 17 // Populate panels. | |
| 18 var panelExtensions = self.runtime.extensions(WebInspector.Panel); | |
| 19 for (var extension of panelExtensions) | |
| 20 this._commands.push(WebInspector.CommandMenu.createRevealPanelComman
d(extension)); | |
| 21 | |
| 22 // Populate drawers. | |
| 23 var drawerExtensions = self.runtime.extensions("view"); | |
| 24 for (var extension of drawerExtensions) { | |
| 25 if (extension.descriptor()["location"] !== "drawer-view") | |
| 26 continue; | |
| 27 this._commands.push(WebInspector.CommandMenu.createRevealDrawerComma
nd(extension)); | |
| 28 } | |
| 29 | |
| 30 // Populate whitelisted settings. | |
| 31 var settingExtensions = self.runtime.extensions("setting"); | |
| 32 for (var extension of settingExtensions) { | |
| 33 var options = extension.descriptor()["options"]; | |
| 34 if (!options || !extension.descriptor()["category"]) | |
| 35 continue; | |
| 36 for (var pair of options) | |
| 37 this._commands.push(WebInspector.CommandMenu.createSettingComman
d(extension, pair["title"], pair["value"])); | |
| 38 } | |
| 39 }, | |
| 40 | |
| 41 /** | |
| 42 * @return {!Array.<!WebInspector.CommandMenu.Command>} | |
| 43 */ | |
| 44 commands: function() | |
| 45 { | |
| 46 return this._commands; | |
| 47 } | |
| 48 }; | |
| 49 | |
| 50 /** | 128 /** |
| 51 * @constructor | 129 * @unrestricted |
| 52 * @extends {WebInspector.FilteredListWidget.Delegate} | |
| 53 */ | 130 */ |
| 54 WebInspector.CommandMenuDelegate = function() | 131 WebInspector.CommandMenuDelegate = class extends WebInspector.FilteredListWidget
.Delegate { |
| 55 { | 132 constructor() { |
| 56 WebInspector.FilteredListWidget.Delegate.call(this, []); | 133 super([]); |
| 57 this._commands = []; | 134 this._commands = []; |
| 58 this._appendAvailableCommands(); | 135 this._appendAvailableCommands(); |
| 59 }; | 136 } |
| 60 | 137 |
| 61 WebInspector.CommandMenuDelegate.MaterialPaletteColors = ["#F44336", "#E91E63",
"#9C27B0", "#673AB7", "#3F51B5", "#03A9F4", "#00BCD4", "#009688", "#4CAF50", "#8
BC34A", "#CDDC39", "#FFC107", "#FF9800", "#FF5722", "#795548", "#9E9E9E", "#607D
8B"]; | 138 _appendAvailableCommands() { |
| 62 | 139 var allCommands = WebInspector.commandMenu.commands(); |
| 63 WebInspector.CommandMenuDelegate.prototype = { | 140 |
| 64 _appendAvailableCommands: function() | 141 // Populate whitelisted actions. |
| 65 { | 142 var actions = WebInspector.actionRegistry.availableActions(); |
| 66 var allCommands = WebInspector.commandMenu.commands(); | 143 for (var action of actions) { |
| 67 | 144 if (action.category()) |
| 68 // Populate whitelisted actions. | 145 this._commands.push(WebInspector.CommandMenu.createActionCommand(action)
); |
| 69 var actions = WebInspector.actionRegistry.availableActions(); | 146 } |
| 70 for (var action of actions) { | 147 |
| 71 if (action.category()) | 148 for (var command of allCommands) { |
| 72 this._commands.push(WebInspector.CommandMenu.createActionCommand
(action)); | 149 if (command.available()) |
| 73 } | 150 this._commands.push(command); |
| 74 | 151 } |
| 75 for (var command of allCommands) { | 152 |
| 76 if (command.available()) | 153 this._commands = this._commands.sort(commandComparator); |
| 77 this._commands.push(command); | |
| 78 } | |
| 79 | |
| 80 this._commands = this._commands.sort(commandComparator); | |
| 81 | |
| 82 /** | |
| 83 * @param {!WebInspector.CommandMenu.Command} left | |
| 84 * @param {!WebInspector.CommandMenu.Command} right | |
| 85 * @return {number} | |
| 86 */ | |
| 87 function commandComparator(left, right) | |
| 88 { | |
| 89 var cats = left.category().compareTo(right.category()); | |
| 90 return cats ? cats : left.title().compareTo(right.title()); | |
| 91 } | |
| 92 }, | |
| 93 | 154 |
| 94 /** | 155 /** |
| 95 * @override | 156 * @param {!WebInspector.CommandMenu.Command} left |
| 157 * @param {!WebInspector.CommandMenu.Command} right |
| 96 * @return {number} | 158 * @return {number} |
| 97 */ | 159 */ |
| 98 itemCount: function() | 160 function commandComparator(left, right) { |
| 99 { | 161 var cats = left.category().compareTo(right.category()); |
| 100 return this._commands.length; | 162 return cats ? cats : left.title().compareTo(right.title()); |
| 101 }, | 163 } |
| 102 | 164 } |
| 103 /** | 165 |
| 104 * @override | 166 /** |
| 105 * @param {number} itemIndex | 167 * @override |
| 106 * @return {string} | 168 * @return {number} |
| 107 */ | 169 */ |
| 108 itemKeyAt: function(itemIndex) | 170 itemCount() { |
| 109 { | 171 return this._commands.length; |
| 110 return this._commands[itemIndex].key(); | 172 } |
| 111 }, | 173 |
| 112 | 174 /** |
| 113 /** | 175 * @override |
| 114 * @override | 176 * @param {number} itemIndex |
| 115 * @param {number} itemIndex | 177 * @return {string} |
| 116 * @param {string} query | 178 */ |
| 117 * @return {number} | 179 itemKeyAt(itemIndex) { |
| 118 */ | 180 return this._commands[itemIndex].key(); |
| 119 itemScoreAt: function(itemIndex, query) | 181 } |
| 120 { | 182 |
| 121 var command = this._commands[itemIndex]; | 183 /** |
| 122 var opcodes = WebInspector.Diff.charDiff(query.toLowerCase(), command.ti
tle().toLowerCase()); | 184 * @override |
| 123 var score = 0; | 185 * @param {number} itemIndex |
| 124 // Score longer sequences higher. | 186 * @param {string} query |
| 125 for (var i = 0; i < opcodes.length; ++i) { | 187 * @return {number} |
| 126 if (opcodes[i][0] === WebInspector.Diff.Operation.Equal) | 188 */ |
| 127 score += opcodes[i][1].length * opcodes[i][1].length; | 189 itemScoreAt(itemIndex, query) { |
| 128 } | 190 var command = this._commands[itemIndex]; |
| 129 | 191 var opcodes = WebInspector.Diff.charDiff(query.toLowerCase(), command.title(
).toLowerCase()); |
| 130 // Score panel/drawer reveals above regular actions. | 192 var score = 0; |
| 131 if (command.category().startsWith("Panel")) | 193 // Score longer sequences higher. |
| 132 score += 2; | 194 for (var i = 0; i < opcodes.length; ++i) { |
| 133 else if (command.category().startsWith("Drawer")) | 195 if (opcodes[i][0] === WebInspector.Diff.Operation.Equal) |
| 134 score += 1; | 196 score += opcodes[i][1].length * opcodes[i][1].length; |
| 135 | 197 } |
| 136 return score; | 198 |
| 137 }, | 199 // Score panel/drawer reveals above regular actions. |
| 138 | 200 if (command.category().startsWith('Panel')) |
| 139 /** | 201 score += 2; |
| 140 * @override | 202 else if (command.category().startsWith('Drawer')) |
| 141 * @param {number} itemIndex | 203 score += 1; |
| 142 * @param {string} query | 204 |
| 143 * @param {!Element} titleElement | 205 return score; |
| 144 * @param {!Element} subtitleElement | 206 } |
| 145 */ | 207 |
| 146 renderItem: function(itemIndex, query, titleElement, subtitleElement) | 208 /** |
| 147 { | 209 * @override |
| 148 var command = this._commands[itemIndex]; | 210 * @param {number} itemIndex |
| 149 titleElement.removeChildren(); | 211 * @param {string} query |
| 150 var tagElement = titleElement.createChild("span", "tag"); | 212 * @param {!Element} titleElement |
| 151 var index = String.hashCode(command.category()) % WebInspector.CommandMe
nuDelegate.MaterialPaletteColors.length; | 213 * @param {!Element} subtitleElement |
| 152 tagElement.style.backgroundColor = WebInspector.CommandMenuDelegate.Mate
rialPaletteColors[index]; | 214 */ |
| 153 tagElement.textContent = command.category(); | 215 renderItem(itemIndex, query, titleElement, subtitleElement) { |
| 154 titleElement.createTextChild(command.title()); | 216 var command = this._commands[itemIndex]; |
| 155 this.highlightRanges(titleElement, query); | 217 titleElement.removeChildren(); |
| 156 subtitleElement.textContent = command.shortcut(); | 218 var tagElement = titleElement.createChild('span', 'tag'); |
| 157 }, | 219 var index = String.hashCode(command.category()) % WebInspector.CommandMenuDe
legate.MaterialPaletteColors.length; |
| 158 | 220 tagElement.style.backgroundColor = WebInspector.CommandMenuDelegate.Material
PaletteColors[index]; |
| 159 /** | 221 tagElement.textContent = command.category(); |
| 160 * @override | 222 titleElement.createTextChild(command.title()); |
| 161 * @param {?number} itemIndex | 223 this.highlightRanges(titleElement, query); |
| 162 * @param {string} promptValue | 224 subtitleElement.textContent = command.shortcut(); |
| 163 */ | 225 } |
| 164 selectItem: function(itemIndex, promptValue) | 226 |
| 165 { | 227 /** |
| 166 this._commands[itemIndex].execute(); | 228 * @override |
| 167 }, | 229 * @param {?number} itemIndex |
| 168 | 230 * @param {string} promptValue |
| 169 /** | 231 */ |
| 170 * @override | 232 selectItem(itemIndex, promptValue) { |
| 171 * @return {boolean} | 233 this._commands[itemIndex].execute(); |
| 172 */ | 234 } |
| 173 caseSensitive: function() | 235 |
| 174 { | 236 /** |
| 175 return false; | 237 * @override |
| 176 }, | 238 * @return {boolean} |
| 177 | 239 */ |
| 178 /** | 240 caseSensitive() { |
| 179 * @override | 241 return false; |
| 180 * @return {boolean} | 242 } |
| 181 */ | 243 |
| 182 renderMonospace: function() | 244 /** |
| 183 { | 245 * @override |
| 184 return false; | 246 * @return {boolean} |
| 185 }, | 247 */ |
| 186 | 248 renderMonospace() { |
| 187 __proto__: WebInspector.FilteredListWidget.Delegate.prototype | 249 return false; |
| 250 } |
| 188 }; | 251 }; |
| 189 | 252 |
| 253 WebInspector.CommandMenuDelegate.MaterialPaletteColors = [ |
| 254 '#F44336', '#E91E63', '#9C27B0', '#673AB7', '#3F51B5', '#03A9F4', '#00BCD4', '
#009688', '#4CAF50', '#8BC34A', |
| 255 '#CDDC39', '#FFC107', '#FF9800', '#FF5722', '#795548', '#9E9E9E', '#607D8B' |
| 256 ]; |
| 257 |
| 190 /** | 258 /** |
| 191 * @constructor | 259 * @unrestricted |
| 192 * @param {string} category | |
| 193 * @param {string} title | |
| 194 * @param {string} key | |
| 195 * @param {string} shortcut | |
| 196 * @param {function()} executeHandler | |
| 197 * @param {function()=} availableHandler | |
| 198 */ | 260 */ |
| 199 WebInspector.CommandMenu.Command = function(category, title, key, shortcut, exec
uteHandler, availableHandler) | 261 WebInspector.CommandMenu.Command = class { |
| 200 { | 262 /** |
| 263 * @param {string} category |
| 264 * @param {string} title |
| 265 * @param {string} key |
| 266 * @param {string} shortcut |
| 267 * @param {function()} executeHandler |
| 268 * @param {function()=} availableHandler |
| 269 */ |
| 270 constructor(category, title, key, shortcut, executeHandler, availableHandler)
{ |
| 201 this._category = category; | 271 this._category = category; |
| 202 this._title = title; | 272 this._title = title; |
| 203 this._key = category + "\0" + title + "\0" + key; | 273 this._key = category + '\0' + title + '\0' + key; |
| 204 this._shortcut = shortcut; | 274 this._shortcut = shortcut; |
| 205 this._executeHandler = executeHandler; | 275 this._executeHandler = executeHandler; |
| 206 this._availableHandler = availableHandler; | 276 this._availableHandler = availableHandler; |
| 277 } |
| 278 |
| 279 /** |
| 280 * @return {string} |
| 281 */ |
| 282 category() { |
| 283 return this._category; |
| 284 } |
| 285 |
| 286 /** |
| 287 * @return {string} |
| 288 */ |
| 289 title() { |
| 290 return this._title; |
| 291 } |
| 292 |
| 293 /** |
| 294 * @return {string} |
| 295 */ |
| 296 key() { |
| 297 return this._key; |
| 298 } |
| 299 |
| 300 /** |
| 301 * @return {string} |
| 302 */ |
| 303 shortcut() { |
| 304 return this._shortcut; |
| 305 } |
| 306 |
| 307 /** |
| 308 * @return {boolean} |
| 309 */ |
| 310 available() { |
| 311 return this._availableHandler ? this._availableHandler() : true; |
| 312 } |
| 313 |
| 314 execute() { |
| 315 this._executeHandler(); |
| 316 } |
| 207 }; | 317 }; |
| 208 | 318 |
| 209 WebInspector.CommandMenu.Command.prototype = { | |
| 210 /** | |
| 211 * @return {string} | |
| 212 */ | |
| 213 category: function() | |
| 214 { | |
| 215 return this._category; | |
| 216 }, | |
| 217 | |
| 218 /** | |
| 219 * @return {string} | |
| 220 */ | |
| 221 title: function() | |
| 222 { | |
| 223 return this._title; | |
| 224 }, | |
| 225 | |
| 226 /** | |
| 227 * @return {string} | |
| 228 */ | |
| 229 key: function() | |
| 230 { | |
| 231 return this._key; | |
| 232 }, | |
| 233 | |
| 234 /** | |
| 235 * @return {string} | |
| 236 */ | |
| 237 shortcut: function() | |
| 238 { | |
| 239 return this._shortcut; | |
| 240 }, | |
| 241 | |
| 242 /** | |
| 243 * @return {boolean} | |
| 244 */ | |
| 245 available: function() | |
| 246 { | |
| 247 return this._availableHandler ? this._availableHandler() : true; | |
| 248 }, | |
| 249 | |
| 250 execute: function() | |
| 251 { | |
| 252 this._executeHandler(); | |
| 253 } | |
| 254 }; | |
| 255 | |
| 256 /** | |
| 257 * @param {string} category | |
| 258 * @param {string} keys | |
| 259 * @param {string} title | |
| 260 * @param {string} shortcut | |
| 261 * @param {function()} executeHandler | |
| 262 * @param {function()=} availableHandler | |
| 263 * @return {!WebInspector.CommandMenu.Command} | |
| 264 */ | |
| 265 WebInspector.CommandMenu.createCommand = function(category, keys, title, shortcu
t, executeHandler, availableHandler) | |
| 266 { | |
| 267 // Separate keys by null character, to prevent fuzzy matching from matching
across them. | |
| 268 var key = keys.replace(/,/g, "\0"); | |
| 269 return new WebInspector.CommandMenu.Command(category, title, key, shortcut,
executeHandler, availableHandler); | |
| 270 }; | |
| 271 | |
| 272 /** | |
| 273 * @param {!Runtime.Extension} extension | |
| 274 * @param {string} title | |
| 275 * @param {V} value | |
| 276 * @return {!WebInspector.CommandMenu.Command} | |
| 277 * @template V | |
| 278 */ | |
| 279 WebInspector.CommandMenu.createSettingCommand = function(extension, title, value
) | |
| 280 { | |
| 281 var category = extension.descriptor()["category"] || ""; | |
| 282 var tags = extension.descriptor()["tags"] || ""; | |
| 283 var setting = WebInspector.settings.moduleSetting(extension.descriptor()["se
ttingName"]); | |
| 284 return WebInspector.CommandMenu.createCommand(category, tags, title, "", set
ting.set.bind(setting, value), availableHandler); | |
| 285 | |
| 286 /** | |
| 287 * @return {boolean} | |
| 288 */ | |
| 289 function availableHandler() | |
| 290 { | |
| 291 return setting.get() !== value; | |
| 292 } | |
| 293 }; | |
| 294 | |
| 295 /** | |
| 296 * @param {!WebInspector.Action} action | |
| 297 * @return {!WebInspector.CommandMenu.Command} | |
| 298 */ | |
| 299 WebInspector.CommandMenu.createActionCommand = function(action) | |
| 300 { | |
| 301 var shortcut = WebInspector.shortcutRegistry.shortcutTitleForAction(action.i
d()) || ""; | |
| 302 return WebInspector.CommandMenu.createCommand(action.category(), action.tags
(), action.title(), shortcut, action.execute.bind(action)); | |
| 303 }; | |
| 304 | |
| 305 /** | |
| 306 * @param {!Runtime.Extension} extension | |
| 307 * @return {!WebInspector.CommandMenu.Command} | |
| 308 */ | |
| 309 WebInspector.CommandMenu.createRevealPanelCommand = function(extension) | |
| 310 { | |
| 311 var panelName = extension.descriptor()["name"]; | |
| 312 var tags = extension.descriptor()["tags"] || ""; | |
| 313 return WebInspector.CommandMenu.createCommand(WebInspector.UIString("Panel")
, tags, WebInspector.UIString("Show %s", extension.title()), "", executeHandler,
availableHandler); | |
| 314 | |
| 315 /** | |
| 316 * @return {boolean} | |
| 317 */ | |
| 318 function availableHandler() | |
| 319 { | |
| 320 return true; | |
| 321 } | |
| 322 | |
| 323 function executeHandler() | |
| 324 { | |
| 325 WebInspector.viewManager.showView(panelName); | |
| 326 } | |
| 327 }; | |
| 328 | |
| 329 /** | |
| 330 * @param {!Runtime.Extension} extension | |
| 331 * @return {!WebInspector.CommandMenu.Command} | |
| 332 */ | |
| 333 WebInspector.CommandMenu.createRevealDrawerCommand = function(extension) | |
| 334 { | |
| 335 var drawerId = extension.descriptor()["id"]; | |
| 336 var executeHandler = WebInspector.viewManager.showView.bind(WebInspector.vie
wManager, drawerId); | |
| 337 var tags = extension.descriptor()["tags"] || ""; | |
| 338 return WebInspector.CommandMenu.createCommand(WebInspector.UIString("Drawer"
), tags, WebInspector.UIString("Show %s", extension.title()), "", executeHandler
); | |
| 339 }; | |
| 340 | 319 |
| 341 /** @type {!WebInspector.CommandMenu} */ | 320 /** @type {!WebInspector.CommandMenu} */ |
| 342 WebInspector.commandMenu = new WebInspector.CommandMenu(); | 321 WebInspector.commandMenu = new WebInspector.CommandMenu(); |
| 343 | 322 |
| 344 /** | 323 /** |
| 345 * @constructor | |
| 346 * @implements {WebInspector.ActionDelegate} | 324 * @implements {WebInspector.ActionDelegate} |
| 325 * @unrestricted |
| 347 */ | 326 */ |
| 348 WebInspector.CommandMenu.ShowActionDelegate = function() | 327 WebInspector.CommandMenu.ShowActionDelegate = class { |
| 349 { | 328 /** |
| 329 * @override |
| 330 * @param {!WebInspector.Context} context |
| 331 * @param {string} actionId |
| 332 * @return {boolean} |
| 333 */ |
| 334 handleAction(context, actionId) { |
| 335 new WebInspector.FilteredListWidget(new WebInspector.CommandMenuDelegate()).
showAsDialog(); |
| 336 InspectorFrontendHost.bringToFront(); |
| 337 return true; |
| 338 } |
| 350 }; | 339 }; |
| 351 | |
| 352 WebInspector.CommandMenu.ShowActionDelegate.prototype = { | |
| 353 /** | |
| 354 * @override | |
| 355 * @param {!WebInspector.Context} context | |
| 356 * @param {string} actionId | |
| 357 * @return {boolean} | |
| 358 */ | |
| 359 handleAction: function(context, actionId) | |
| 360 { | |
| 361 new WebInspector.FilteredListWidget(new WebInspector.CommandMenuDelegate
()).showAsDialog(); | |
| 362 InspectorFrontendHost.bringToFront(); | |
| 363 return true; | |
| 364 } | |
| 365 }; | |
| 366 | |
| OLD | NEW |