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

Unified Diff: chrome/browser/resources/extensions/extension_command_list.js

Issue 512003002: Revert of Revert "Typecheck JS files for chrome://extensions" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
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..1f92c19cfda5f3b732e0abe71f252d58ce4dd36f 100644
--- a/chrome/browser/resources/extensions/extension_command_list.js
+++ b/chrome/browser/resources/extensions/extension_command_list.js
@@ -1,6 +1,16 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// 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 ExtensionCommand;
cr.define('options', function() {
'use strict';
@@ -9,7 +19,7 @@
* 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 @@
* 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 @@
* 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 @@
* 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 @@
/**
* 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 @@
/**
* While capturing, this keeps track of which element the user asked to
* change.
- * @type: {HTMLElement}.
+ * @type {HTMLElement}.
* @private
*/
capturingElement_: null,
@@ -227,7 +237,8 @@
/**
* Synthesizes and initializes an HTML element for the extension command
* metadata given in |command|.
- * @param {Object} command A dictionary of extension command metadata.
+ * @param {ExtensionCommand} command A dictionary of extension command
+ * metadata.
* @private
*/
createNodeForCommand_: function(command) {
@@ -245,8 +256,7 @@
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('keydown', this.handleKeyDown_.bind(this));
shortcutNode.addEventListener('keyup', this.handleKeyUp_.bind(this));
if (!command.active) {
shortcutNode.textContent =
@@ -312,7 +322,7 @@
shortcutNode.parentElement.querySelector('.command-clear');
commandClear.hidden = true;
- this.capturingElement_ = event.target;
+ this.capturingElement_ = /** @type {HTMLElement} */(event.target);
},
/**
@@ -384,6 +394,7 @@
* @private
*/
handleKeyDown_: function(event) {
+ event = /** @type {KeyboardEvent} */(event);
if (event.keyCode == keyEscape) {
// Escape cancels capturing.
this.endCapture_(event);
@@ -412,6 +423,7 @@
* @private
*/
handleKeyUp_: function(event) {
+ event = /** @type {KeyboardEvent} */(event);
if (event.keyCode == keyTab) {
// Allow tab propagation for keyboard navigation.
return;
@@ -439,7 +451,7 @@
/**
* 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 @@
* 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) {

Powered by Google App Engine
This is Rietveld 408576698