Chromium Code Reviews| Index: chrome/browser/resources/extensions/extension_command_list.js |
| diff --git a/chrome/browser/resources/extensions/extension_command_list.js b/chrome/browser/resources/extensions/extension_command_list.js |
| index 2c411d3a5fcdc0188ab6a89f6624f8888183211f..139c2ccbb46c5fa00309c2aeb9d02637a4b5560e 100644 |
| --- a/chrome/browser/resources/extensions/extension_command_list.js |
| +++ b/chrome/browser/resources/extensions/extension_command_list.js |
| @@ -2,6 +2,16 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +/** @typedef {{active: boolean, |
| + * command_name: string, |
| + * description: string, |
| + * extension_action: boolean, |
| + * extension_id: string, |
| + * global: boolean, |
| + * keybinding: string}} |
| + */ |
| +var CommandBackendObject; |
|
Dan Beam
2014/08/21 18:27:47
ExtensionCommand
Vitaly Pavlenko
2014/08/22 01:43:39
Done.
|
| + |
| cr.define('options', function() { |
| 'use strict'; |
| @@ -9,7 +19,7 @@ cr.define('options', function() { |
| * Creates a new list of extension commands. |
| * @param {Object=} opt_propertyBag Optional properties. |
| * @constructor |
| - * @extends {cr.ui.div} |
| + * @extends {HTMLDivElement} |
| */ |
| var ExtensionCommandList = cr.ui.define('div'); |
| @@ -45,7 +55,7 @@ cr.define('options', function() { |
| * Returns whether the passed in |keyCode| is a valid extension command |
| * char or not. This is restricted to A-Z and 0-9 (ignoring modifiers) at |
| * the moment. |
| - * @param {int} keyCode The keycode to consider. |
| + * @param {number} keyCode The keycode to consider. |
| * @return {boolean} Returns whether the char is valid. |
| */ |
| function validChar(keyCode) { |
| @@ -139,7 +149,7 @@ cr.define('options', function() { |
| * Returns whether the passed in |keyCode| require modifiers. Currently only |
| * "MediaNextTrack", "MediaPrevTrack", "MediaStop", "MediaPlayPause" are |
| * required to be used without any modifier. |
| - * @param {int} keyCode The keycode to consider. |
| + * @param {number} keyCode The keycode to consider. |
| * @return {Modifiers} Returns whether the keycode require modifiers. |
| */ |
| function modifiers(keyCode) { |
| @@ -174,7 +184,7 @@ cr.define('options', function() { |
| * While capturing, this records the current (last) keyboard event generated |
| * by the user. Will be |null| after capture and during capture when no |
| * keyboard event has been generated. |
| - * @type: {keyboard event}. |
| + * @type {KeyboardEvent}. |
| * @private |
| */ |
| currentKeyEvent_: null, |
| @@ -182,7 +192,7 @@ cr.define('options', function() { |
| /** |
| * While capturing, this keeps track of the previous selection so we can |
| * revert back to if no valid assignment is made during capture. |
| - * @type: {string}. |
| + * @type {string}. |
| * @private |
| */ |
| oldValue_: '', |
| @@ -190,7 +200,7 @@ cr.define('options', function() { |
| /** |
| * While capturing, this keeps track of which element the user asked to |
| * change. |
| - * @type: {HTMLElement}. |
| + * @type {HTMLElement}. |
| * @private |
| */ |
| capturingElement_: null, |
| @@ -227,7 +237,8 @@ cr.define('options', function() { |
| /** |
| * Synthesizes and initializes an HTML element for the extension command |
| * metadata given in |command|. |
| - * @param {Object} command A dictionary of extension command metadata. |
| + * @param {CommandBackendObject} command A dictionary of extension command |
| + * metadata. |
| * @private |
| */ |
| createNodeForCommand_: function(command) { |
| @@ -245,9 +256,10 @@ cr.define('options', function() { |
| this.startCapture_.bind(this)); |
| shortcutNode.addEventListener('focus', this.handleFocus_.bind(this)); |
| shortcutNode.addEventListener('blur', this.handleBlur_.bind(this)); |
| - shortcutNode.addEventListener('keydown', |
| - this.handleKeyDown_.bind(this)); |
| - shortcutNode.addEventListener('keyup', this.handleKeyUp_.bind(this)); |
| + shortcutNode.addEventListener('keydown', /** @type {function(Event)} */( |
|
Dan Beam
2014/08/21 18:27:47
cast the event later
Vitaly Pavlenko
2014/08/22 01:43:39
Done.
|
| + this.handleKeyDown_.bind(this))); |
| + shortcutNode.addEventListener('keyup', /** @type {function (Event)} */( |
| + this.handleKeyUp_.bind(this))); |
| if (!command.active) { |
| shortcutNode.textContent = |
| loadTimeData.getString('extensionCommandsInactive'); |
| @@ -312,7 +324,7 @@ cr.define('options', function() { |
| shortcutNode.parentElement.querySelector('.command-clear'); |
| commandClear.hidden = true; |
| - this.capturingElement_ = event.target; |
| + this.capturingElement_ = /** @type {HTMLElement} */(event.target); |
| }, |
| /** |
| @@ -380,7 +392,7 @@ cr.define('options', function() { |
| /** |
| * The KeyDown handler. |
| - * @param {Event} event The keyboard event to consider. |
| + * @param {KeyboardEvent} event The keyboard event to consider. |
| * @private |
| */ |
| handleKeyDown_: function(event) { |
| @@ -408,7 +420,7 @@ cr.define('options', function() { |
| /** |
| * The KeyUp handler. |
| - * @param {Event} event The keyboard event to consider. |
| + * @param {KeyboardEvent} event The keyboard event to consider. |
| * @private |
| */ |
| handleKeyUp_: function(event) { |
| @@ -439,7 +451,7 @@ cr.define('options', function() { |
| /** |
| * A general key handler (used for both KeyDown and KeyUp). |
| - * @param {Event} event The keyboard event to consider. |
| + * @param {KeyboardEvent} event The keyboard event to consider. |
| * @private |
| */ |
| handleKey_: function(event) { |
| @@ -523,8 +535,7 @@ cr.define('options', function() { |
| * extension id and a command name. |
| * @param {string} namespace The namespace to prepend the id with. |
| * @param {string} id The id to parse. |
| - * @return {object} The parsed id, as an object with two members: |
| - * extensionID and commandName. |
| + * @return {{extensionId: string, commandName: string}} The parsed id. |
| * @private |
| */ |
| parseElementId_: function(namespace, id) { |