Commit 069e64df authored by Eric Roman's avatar Eric Roman

Revert "Typecheck JS files for chrome://extensions"

This reverts commit 405253b7.

Caused a liscene failure on android bot:
http://build.chromium.org/p/chromium.linux/builders/Android%20Builder%20%28dbg%29/builds/64664/steps/check_licenses/logs/stdio

Review URL: https://codereview.chromium.org/508283002

Cr-Commit-Position: refs/heads/master@{#292208}
parent d05a25f0
......@@ -2,18 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* The type of the app data object. The definition is based on
* chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.cc:
* PopulateAppDict()
* @typedef {{id: string,
* name: string,
* iconURL: string,
* autoLaunch: boolean,
* isLoading: boolean}}
*/
var AppDict;
cr.define('extensions', function() {
/** @const */ var List = cr.ui.List;
/** @const */ var ListItem = cr.ui.ListItem;
......@@ -61,7 +49,7 @@ cr.define('extensions', function() {
/**
* Updates the given app.
* @param {!AppDict} app An app info object.
* @param {!Object} app An app info object.
*/
updateApp: function(app) {
for (var i = 0; i < this.items.length; ++i) {
......@@ -167,8 +155,9 @@ cr.define('extensions', function() {
}
};
/**
/*
* True if the app represented by this item will auto launch.
* @type {boolean}
*/
cr.defineProperty(KioskAppListItem, 'autoLaunch', cr.PropertyKind.BOOL_ATTR);
......
......@@ -100,9 +100,9 @@ cr.define('extensions', function() {
/**
* Sets apps to be displayed in kiosk-app-list.
* @param {!Object.<{apps: !Array.<AppDict>, disableBailout: boolean,
* hasAutoLaunchApp: boolean}>} settings An object containing an array of
* app info objects and disable bailout shortcut flag.
* @param {!Object.<{apps: !Array.<Object>, disableBailout: boolean}>}
* settings An object containing an array of app info objects and
* disable bailout shortcut flag.
*/
KioskAppsOverlay.setSettings = function(settings) {
$('kiosk-app-list').setApps(settings.apps);
......@@ -128,7 +128,7 @@ cr.define('extensions', function() {
/**
* Enables consumer kiosk.
* @param {!{kioskEnabled: boolean, autoLaunchEnabled: boolean}} params
* @param {!boolean} enable True if consumer kiosk feature is enabled.
*/
KioskAppsOverlay.enableKiosk = function(params) {
$('add-kiosk-app').hidden = !params.kioskEnabled;
......
# Copyright 2014 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.
{
'targets': [
{
'target_name': 'extensions',
'variables': {
'depends': [
'../../../../ui/webui/resources/js/assert.js',
'../../../../ui/webui/resources/js/assert.js',
'../../../../ui/webui/resources/js/cr.js',
'../../../../ui/webui/resources/js/cr/event_target.js',
'../../../../ui/webui/resources/js/cr/ui.js',
'../../../../ui/webui/resources/js/cr/ui/alert_overlay.js',
'../../../../ui/webui/resources/js/cr/ui/array_data_model.js',
'../../../../ui/webui/resources/js/cr/ui/drag_wrapper.js',
'../../../../ui/webui/resources/js/cr/ui/focus_manager.js',
'../../../../ui/webui/resources/js/cr/ui/focus_outline_manager.js',
'../../../../ui/webui/resources/js/cr/ui/list.js',
'../../../../ui/webui/resources/js/cr/ui/list_item.js',
'../../../../ui/webui/resources/js/cr/ui/list_selection_controller.js',
'../../../../ui/webui/resources/js/cr/ui/list_selection_model.js',
'../../../../ui/webui/resources/js/cr/ui/overlay.js',
'../../../../ui/webui/resources/js/load_time_data.js',
'../../../../ui/webui/resources/js/util.js',
],
'externs': ['<(CLOSURE_DIR)/externs/chrome_send_externs.js'],
},
'includes': ['../../../../third_party/closure_compiler/compile_js.gypi'],
}
],
}
......@@ -2,22 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @typedef {{afterHighlight: string,
* beforeHighlight: string,
* highlight: string,
* title: string}}
*/
var ExtensionHighlight;
cr.define('extensions', function() {
'use strict';
/**
* ExtensionCode is an element which displays code in a styled div, and is
* designed to highlight errors.
* @constructor
* @extends {HTMLDivElement}
*/
function ExtensionCode(div) {
div.__proto__ = ExtensionCode.prototype;
......@@ -30,12 +20,13 @@ cr.define('extensions', function() {
/**
* Populate the content area of the code div with the given code. This will
* highlight the erroneous section (if any).
* @param {ExtensionHighlight} code The 'highlight' strings represent the
* three portions of the file's content to display - the portion which
* is most relevant and should be emphasized (highlight), and the parts
* both before and after this portion. The title is the error message,
* which will be the mouseover hint for the highlighted region. These
* may be empty.
* @param {Object} code An object with four strings: beforeHighlight,
* afterHighlight, highlight, and the message. The 'highlight' strings
* represent the three portions of the file's content to display - the
* portion which is most relevant and should be emphasized (highlight),
* and the parts both before and after this portion. The message is the
* error message, which will be the mouseover hint for the highlighted
* region. These may be empty.
* @param {string} emptyMessage The message to display if the code
* object is empty (e.g., 'could not load code').
*/
......
......@@ -2,16 +2,6 @@
// 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';
......@@ -19,7 +9,7 @@ cr.define('options', function() {
* Creates a new list of extension commands.
* @param {Object=} opt_propertyBag Optional properties.
* @constructor
* @extends {HTMLDivElement}
* @extends {cr.ui.div}
*/
var ExtensionCommandList = cr.ui.define('div');
......@@ -55,7 +45,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 {number} keyCode The keycode to consider.
* @param {int} keyCode The keycode to consider.
* @return {boolean} Returns whether the char is valid.
*/
function validChar(keyCode) {
......@@ -149,7 +139,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 {number} keyCode The keycode to consider.
* @param {int} keyCode The keycode to consider.
* @return {Modifiers} Returns whether the keycode require modifiers.
*/
function modifiers(keyCode) {
......@@ -184,7 +174,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 {KeyboardEvent}.
* @type: {keyboard event}.
* @private
*/
currentKeyEvent_: null,
......@@ -192,7 +182,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_: '',
......@@ -200,7 +190,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,
......@@ -237,8 +227,7 @@ cr.define('options', function() {
/**
* Synthesizes and initializes an HTML element for the extension command
* metadata given in |command|.
* @param {ExtensionCommand} command A dictionary of extension command
* metadata.
* @param {Object} command A dictionary of extension command metadata.
* @private
*/
createNodeForCommand_: function(command) {
......@@ -256,7 +245,8 @@ 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('keydown',
this.handleKeyDown_.bind(this));
shortcutNode.addEventListener('keyup', this.handleKeyUp_.bind(this));
if (!command.active) {
shortcutNode.textContent =
......@@ -322,7 +312,7 @@ cr.define('options', function() {
shortcutNode.parentElement.querySelector('.command-clear');
commandClear.hidden = true;
this.capturingElement_ = /** @type {HTMLElement} */(event.target);
this.capturingElement_ = event.target;
},
/**
......@@ -394,7 +384,6 @@ cr.define('options', function() {
* @private
*/
handleKeyDown_: function(event) {
event = /** @type {KeyboardEvent} */(event);
if (event.keyCode == keyEscape) {
// Escape cancels capturing.
this.endCapture_(event);
......@@ -423,7 +412,6 @@ cr.define('options', function() {
* @private
*/
handleKeyUp_: function(event) {
event = /** @type {KeyboardEvent} */(event);
if (event.keyCode == keyTab) {
// Allow tab propagation for keyboard navigation.
return;
......@@ -451,7 +439,7 @@ cr.define('options', function() {
/**
* A general key handler (used for both KeyDown and KeyUp).
* @param {KeyboardEvent} event The keyboard event to consider.
* @param {Event} event The keyboard event to consider.
* @private
*/
handleKey_: function(event) {
......@@ -535,7 +523,8 @@ 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 {{extensionId: string, commandName: string}} The parsed id.
* @return {object} The parsed id, as an object with two members:
* extensionID and commandName.
* @private
*/
parseElementId_: function(namespace, id) {
......
......@@ -51,8 +51,6 @@ cr.define('extensions', function() {
/**
* Called by the dom_ui_ to re-populate the page with data representing
* the current state of extension commands.
* @param {!{commands: Array.<{name: string, id: string, commands: ?Array}>}}
* extensionsData
*/
ExtensionCommandsOverlay.returnExtensionsData = function(extensionsData) {
ExtensionCommandList.prototype.data_ = extensionsData;
......@@ -70,7 +68,7 @@ cr.define('extensions', function() {
list.classList.add('empty-extension-commands-list');
else
list.classList.remove('empty-extension-commands-list');
};
}
// Export
return {
......
......@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
<include src="extension_error_overlay.js">
cr.define('extensions', function() {
'use strict';
......@@ -11,8 +13,8 @@ cr.define('extensions', function() {
* @return {HTMLElement} The clone of the template.
*/
function cloneTemplate(templateName) {
return /** @type {HTMLElement} */($('template-collection-extension-error').
querySelector('.' + templateName).cloneNode(true));
return $('template-collection-extension-error').
querySelector('.' + templateName).cloneNode(true);
}
/**
......@@ -42,10 +44,7 @@ cr.define('extensions', function() {
ExtensionError.prototype = {
__proto__: HTMLDivElement.prototype,
/**
* @param {RuntimeError} error
* @override
*/
/** @override */
decorate: function(error) {
// Add an additional class for the severity level.
if (error.level == 0)
......
......@@ -2,35 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* The type of the stack trace object. The definition is based on
* extensions/browser/extension_error.cc:RuntimeError::ToValue().
* @typedef {{columnNumber: number,
* functionName: string,
* lineNumber: number,
* url: string}}
*/
var StackTrace;
/**
* The type of the extension error trace object. The definition is based on
* extensions/browser/extension_error.cc:RuntimeError::ToValue().
* @typedef {{canInspect: (boolean|undefined),
* contextUrl: (string|undefined),
* extensionId: string,
* fromIncognito: boolean,
* level: number,
* manifestKey: string,
* manifestSpecific: string,
* message: string,
* renderProcessId: (number|undefined),
* renderViewId: (number|undefined),
* source: string,
* stackTrace: (Array.<StackTrace>|undefined),
* type: number}}
*/
var RuntimeError;
cr.define('extensions', function() {
'use strict';
......@@ -114,24 +85,24 @@ cr.define('extensions', function() {
/**
* The underlying error whose details are being displayed.
* @type {?RuntimeError}
* @type {Object}
* @private
*/
error_: null,
error_: undefined,
/**
* The URL associated with this extension, i.e. chrome-extension://<id>/.
* @type {?string}
* @type {string}
* @private
*/
extensionUrl_: null,
extensionUrl_: undefined,
/**
* The node of the stack trace which is currently active.
* @type {?HTMLElement}
* @type {HTMLElement}
* @private
*/
currentFrameNode_: null,
currentFrameNode_: undefined,
/**
* Initialize the RuntimeErrorContent for the first time.
......@@ -142,8 +113,8 @@ cr.define('extensions', function() {
* @type {HTMLElement}
* @private
*/
this.stackTrace_ = /** @type {HTMLElement} */(
this.querySelector('.extension-error-overlay-stack-trace-list'));
this.stackTrace_ =
this.querySelector('.extension-error-overlay-stack-trace-list');
assert(this.stackTrace_);
/**
......@@ -151,15 +122,14 @@ cr.define('extensions', function() {
* @type {HTMLElement}
* @private
*/
this.contextUrl_ = /** @type {HTMLElement} */(
this.querySelector('.extension-error-overlay-context-url'));
this.contextUrl_ =
this.querySelector('.extension-error-overlay-context-url');
assert(this.contextUrl_);
},
/**
* Sets the error for the content.
* @param {RuntimeError} error The error whose content should
* be displayed.
* @param {Object} error The error whose content should be displayed.
* @param {string} extensionUrl The URL associated with this extension.
*/
setError: function(error, extensionUrl) {
......@@ -175,9 +145,9 @@ cr.define('extensions', function() {
* Wipe content associated with a specific error.
*/
clearError: function() {
this.error_ = null;
this.extensionUrl_ = null;
this.currentFrameNode_ = null;
this.error_ = undefined;
this.extensionUrl_ = undefined;
this.currentFrameNode_ = undefined;
clearElement(this.stackTrace_);
this.stackTrace_.hidden = true;
},
......@@ -185,7 +155,7 @@ cr.define('extensions', function() {
/**
* Makes |frame| active and deactivates the previously active frame (if
* there was one).
* @param {HTMLElement} frameNode The frame to activate.
* @param {HTMLElement} frame The frame to activate.
* @private
*/
setActiveFrame_: function(frameNode) {
......@@ -219,8 +189,8 @@ cr.define('extensions', function() {
// The description is a human-readable summation of the frame, in the
// form "<relative_url>:<line_number> (function)", e.g.
// "myfile.js:25 (myFunction)".
var description = getRelativeUrl(frame.url,
assert(this.extensionUrl_)) + ':' + frame.lineNumber;
var description = getRelativeUrl(frame.url, this.extensionUrl_) +
':' + frame.lineNumber;
if (frame.functionName) {
var functionName = frame.functionName == '(anonymous function)' ?
loadTimeData.getString('extensionErrorOverlayAnonymousFunction') :
......@@ -234,6 +204,9 @@ cr.define('extensions', function() {
// code with the line highlighted, and link the "Open DevTools" button
// with that frame.
frameNode.addEventListener('click', function(frame, frameNode, e) {
if (this.currStackFrame_ == frameNode)
return;
this.setActiveFrame_(frameNode);
// Request the file source with the section highlighted; this will
......@@ -255,8 +228,7 @@ cr.define('extensions', function() {
// internal frames.)
if (this.stackTrace_.children.length > 0) {
this.stackTrace_.hidden = false;
this.setActiveFrame_(assertInstanceof(this.stackTrace_.firstChild,
HTMLElement));
this.setActiveFrame_(this.stackTrace_.firstChild);
}
},
......@@ -372,10 +344,10 @@ cr.define('extensions', function() {
ExtensionErrorOverlay.prototype = {
/**
* The underlying error whose details are being displayed.
* @type {?RuntimeError}
* @type {Object}
* @private
*/
error_: null,
error_: undefined,
/**
* Initialize the page.
......@@ -398,13 +370,12 @@ cr.define('extensions', function() {
* @type {HTMLDivElement}
* @private
*/
this.overlayDiv_ = /** @type {HTMLDivElement} */(
$('extension-error-overlay'));
this.overlayDiv_ = $('extension-error-overlay');
/**
* The portion of the overlay which shows the code relating to the error
* and the corresponding line numbers.
* @type {extensions.ExtensionCode}
* @type {ExtensionCode}
* @private
*/
this.codeDiv_ =
......@@ -412,6 +383,7 @@ cr.define('extensions', function() {
/**
* The function to show or hide the ExtensionErrorOverlay.
* @type {function}
* @param {boolean} isVisible Whether the overlay should be visible.
*/
this.setVisible = function(isVisible) {
......@@ -426,8 +398,7 @@ cr.define('extensions', function() {
* @type {HTMLButtonElement}
* @private
*/
this.openDevtoolsButton_ = /** @type {HTMLButtonElement} */(
$('extension-error-overlay-devtools-button'));
this.openDevtoolsButton_ = $('extension-error-overlay-devtools-button');
this.openDevtoolsButton_.addEventListener('click', function() {
this.runtimeErrorContent_.openDevtools();
}.bind(this));
......@@ -458,7 +429,7 @@ cr.define('extensions', function() {
this.runtimeErrorContent_.clearError();
}
this.error_ = null;
this.error_ = undefined;
},
/**
......@@ -466,7 +437,7 @@ cr.define('extensions', function() {
* overlay, and, if possible, will populate the code section of the overlay
* with the relevant file, load the stack trace, and generate links for
* opening devtools (the latter two only happen for runtime errors).
* @param {RuntimeError} error The error to show in the overlay.
* @param {Object} error The error to show in the overlay.
* @param {string} extensionUrl The URL of the extension, in the form
* "chrome-extension://<extension_id>".
*/
......@@ -504,12 +475,10 @@ cr.define('extensions', function() {
}
},
/**
* Set the code to be displayed in the code portion of the overlay.
* @see ExtensionErrorOverlay.requestFileSourceResponse().
* @param {?ExtensionHighlight} code The code to be displayed. If |code| is
* null, then
* @param {?Object} code The code to be displayed. If |code| is null, then
* a "Could not display code" message will be displayed instead.
*/
setCode: function(code) {
......@@ -526,10 +495,11 @@ cr.define('extensions', function() {
/**
* Called by the ExtensionErrorHandler responding to the request for a file's
* source. Populate the content area of the overlay and display the overlay.
* @param {?ExtensionHighlight} result The three 'highlight' strings represent
* three portions of the file's content to display - the portion which is
* most relevant and should be emphasized (highlight), and the parts both
* before and after this portion. These may be empty.
* @param {Object?} result An object with four strings - the title,
* beforeHighlight, afterHighlight, and highlight. The three 'highlight'
* strings represent three portions of the file's content to display - the
* portion which is most relevant and should be emphasized (highlight),
* and the parts both before and after this portion. These may be empty.
*/
ExtensionErrorOverlay.requestFileSourceResponse = function(result) {
var overlay = extensions.ExtensionErrorOverlay.getInstance();
......
......@@ -4,60 +4,6 @@
<include src="extension_error.js">
/**
* The type of the extension data object. The definition is based on
* chrome/browser/ui/webui/extensions/extension_basic_info.cc
* and
* chrome/browser/ui/webui/extensions/extension_settings_handler.cc
* ExtensionSettingsHandler::CreateExtensionDetailValue()
* @typedef {{allow_reload: boolean,
* allowAllUrls: boolean,
* allowFileAccess: boolean,
* blacklistText: string,
* corruptInstall: boolean,
* dependentExtensions: Array,
* description: string,
* detailsUrl: string,
* enable_show_button: boolean,
* enabled: boolean,
* enabledIncognito: boolean,
* errorCollectionEnabled: (boolean|undefined),
* hasPopupAction: boolean,
* homepageProvided: boolean,
* homepageUrl: string,
* icon: string,
* id: string,
* incognitoCanBeEnabled: boolean,
* installWarnings: (Array|undefined),
* is_hosted_app: boolean,
* is_platform_app: boolean,
* isUnpacked: boolean,
* kioskEnabled: boolean,
* kioskOnly: boolean,
* locationText: string,
* managedInstall: boolean,
* manifestErrors: (Array.<RuntimeError>|undefined),
* name: string,
* offlineEnabled: boolean,
* optionsUrl: string,
* order: number,
* packagedApp: boolean,
* path: (string|undefined),
* prettifiedPath: (string|undefined),
* runtimeErrors: (Array.<RuntimeError>|undefined),
* suspiciousInstall: boolean,
* terminated: boolean,
* version: string,
* views: Array.<{renderViewId: number, renderProcessId: number,
* path: string, incognito: boolean,
* generatedBackgroundPage: boolean}>,
* wantsAllUrls: boolean,
* wantsErrorCollection: boolean,
* wantsFileAccess: boolean,
* warnings: (Array|undefined)}}
*/
var ExtensionData;
cr.define('options', function() {
'use strict';
......@@ -65,7 +11,7 @@ cr.define('options', function() {
* Creates a new list of extensions.
* @param {Object=} opt_propertyBag Optional properties.
* @constructor
* @extends {HTMLDivElement}
* @extends {cr.ui.div}
*/
var ExtensionsList = cr.ui.define('div');
......@@ -77,7 +23,7 @@ cr.define('options', function() {
var butterBarVisibility = {};
/**
* @type {Object.<string, number>} A map from extension id to last reloaded
* @type {Object.<string, string>} A map from extension id to last reloaded
* timestamp. The timestamp is recorded when the user click the 'Reload'
* link. It is used to refresh the icon of an unpacked extension.
* This persists between calls to decorate.
......@@ -152,7 +98,7 @@ cr.define('options', function() {
/**
* Synthesizes and initializes an HTML element for the extension metadata
* given in |extension|.
* @param {ExtensionData} extension A dictionary of extension metadata.
* @param {Object} extension A dictionary of extension metadata.
* @private
*/
createNode_: function(extension) {
......@@ -487,7 +433,7 @@ cr.define('options', function() {
// Scroll beneath the fixed header so that the extension is not
// obscured.
var topScroll = node.offsetTop - $('page-header').offsetHeight;
var pad = parseInt(window.getComputedStyle(node, null).marginTop, 10);
var pad = parseInt(getComputedStyle(node, null).marginTop, 10);
if (!isNaN(pad))
topScroll -= pad / 2;
setScrollTopForDocument(document, topScroll);
......
......@@ -9,7 +9,6 @@ cr.define('extensions', function() {
* Construct an ExtensionLoadError around the given |div|.
* @param {HTMLDivElement} div The HTML div for the extension load error.
* @constructor
* @extends {HTMLDivElement}
*/
function ExtensionLoadError(div) {
div.__proto__ = ExtensionLoadError.prototype;
......@@ -21,15 +20,14 @@ cr.define('extensions', function() {
* Construct a Failure.
* @param {string} filePath The path to the unpacked extension.
* @param {string} error The reason the extension failed to load.
* @param {ExtensionHighlight} manifest Three 'highlight' strings in
* |manifest| represent three portions of the file's content to display -
* the portion which is most relevant and should be emphasized
* (highlight), and the parts both before and after this portion. These
* may be empty.
* @param {Object} manifest An object with three strings: beforeHighlight,
* afterHighlight, and highlight. These represent three portions of the
* file's content to display - the portion which is most relevant and
* should be emphasized (highlight), and the parts both before and after
* this portion. These may be empty.
* @param {HTMLLIElement} listElement The HTML element used for displaying the
* failure path for the additional failures UI.
* @constructor
* @extends {HTMLDivElement}
*/
function Failure(filePath, error, manifest, listElement) {
this.path = filePath;
......@@ -47,23 +45,21 @@ cr.define('extensions', function() {
init: function() {
/**
* The element which displays the path of the extension.
* @type {HTMLElement}
* @type {HTMLSpanElement}
* @private
*/
this.path_ = /** @type {HTMLElement} */(
this.querySelector('#extension-load-error-path'));
this.path_ = this.querySelector('#extension-load-error-path');
/**
* The element which displays the reason the extension failed to load.
* @type {HTMLElement}
* @type {HTMLSpanElement}
* @private
*/
this.reason_ = /** @type {HTMLElement} */(
this.querySelector('#extension-load-error-reason'));
this.reason_ = this.querySelector('#extension-load-error-reason');
/**
* The element which displays the manifest code.
* @type {extensions.ExtensionCode}
* @type {ExtensionCode}
* @private
*/
this.manifest_ = new extensions.ExtensionCode(
......@@ -71,11 +67,10 @@ cr.define('extensions', function() {
/**
* The element which displays information about additional errors.
* @type {HTMLElement}
* @type {HTMLULElement}
* @private
*/
this.additional_ = /** @type {HTMLUListElement} */(
this.querySelector('#extension-load-error-additional'));
this.additional_ = this.querySelector('#extension-load-error-additional');
this.additional_.list = this.additional_.getElementsByTagName('ul')[0];
/**
......@@ -112,8 +107,7 @@ cr.define('extensions', function() {
if (this.failures_.length > 0)
this.failures_[this.failures_.length - 1].listElement.hidden = false;
failures.forEach(function(failure) {
var listItem = /** @type {HTMLLIElement} */(
document.createElement('li'));
var listItem = document.createElement('li');
listItem.textContent = failure.path;
this.additional_.list.appendChild(listItem);
this.failures_.push(new Failure(failure.path,
......@@ -178,8 +172,7 @@ cr.define('extensions', function() {
* @type {ExtensionLoadError}
* @private
*/
this.loadError_ = new ExtensionLoadError(
/** @type {HTMLDivElement} */($('extension-load-error')));
this.loadError_ = new ExtensionLoadError($('extension-load-error'));
}
cr.addSingletonGetter(ExtensionLoader);
......@@ -204,7 +197,7 @@ cr.define('extensions', function() {
},
};
/**
/*
* A static forwarding function for ExtensionLoader.notifyFailed.
* @param {Array.<Object>} failures Array of failures containing paths,
* errors, and manifests.
......
......@@ -17,11 +17,11 @@ cr.define('extensions', function() {
ExtensionOptionsOverlay.prototype = {
/**
* The function that shows the given element in the overlay.
* @type {?function(HTMLDivElement)} Function that receives the element to
* show in the overlay.
* @type {Function}
* @param {HTMLElement} The element to show in the overlay.
* @private
*/
showOverlay_: null,
showOverlay_: undefined,
/**
* Initialize the page.
......@@ -42,7 +42,7 @@ cr.define('extensions', function() {
/**
* Handles a click on the close button.
* @param {Event} event The click event.
* @param {Event} e The click event.
* @private
*/
handleDismiss_: function(event) {
......@@ -150,9 +150,7 @@ cr.define('extensions', function() {
* @private
*/
setVisible_: function(isVisible) {
this.showOverlay_(isVisible ?
/** @type {HTMLDivElement} */($('extension-options-overlay')) :
null);
this.showOverlay_(isVisible ? $('extension-options-overlay') : null);
}
};
......
......@@ -5,10 +5,10 @@
<include src="../uber/uber_utils.js">
<include src="extension_code.js">
<include src="extension_commands_overlay.js">
<include src="extension_error_overlay.js">
<include src="extension_focus_manager.js">
<include src="extension_list.js">
<include src="pack_extension_overlay.js">
<include src="extension_error_overlay.js">
<include src="extension_loader.js">
<include src="extension_options_overlay.js">
......@@ -16,19 +16,6 @@
<include src="chromeos/kiosk_apps.js">
</if>
/**
* The type of the extension data object. The definition is based on
* chrome/browser/ui/webui/extensions/extension_settings_handler.cc:
* ExtensionSettingsHandler::HandleRequestExtensionsData()
* @typedef {{developerMode: boolean,
* extensions: Array,
* incognitoAvailable: boolean,
* loadUnpackedDisabled: boolean,
* profileIsSupervised: boolean,
* promoteAppsDevTools: boolean}}
*/
var ExtensionDataResponse;
// Used for observing function of the backend datasource for this page by
// tests.
var webuiResponded = false;
......@@ -272,7 +259,7 @@ cr.define('extensions', function() {
} else {
$('extension-settings').classList.remove('dev-mode');
}
window.setTimeout(this.updatePromoVisibility_.bind(this), 0);
window.setTimeout(this.updatePromoVisibility_.bind(this));
chrome.send('extensionSettingsToggleDeveloperMode');
},
......@@ -293,7 +280,6 @@ cr.define('extensions', function() {
/**
* Called by the dom_ui_ to re-populate the page with data representing
* the current state of installed extensions.
* @param {ExtensionDataResponse} extensionsData
*/
ExtensionSettings.returnExtensionsData = function(extensionsData) {
// We can get called many times in short order, thus we need to
......@@ -417,7 +403,7 @@ cr.define('extensions', function() {
pages[i].setAttribute('aria-hidden', node ? 'true' : 'false');
}
$('overlay').hidden = !node;
overlay.hidden = !node;
uber.invokeMethodOnParent(node ? 'beginInterceptingEvents' :
'stopInterceptingEvents');
};
......
......@@ -60,9 +60,9 @@ cr.define('extensions', function() {
* @private
*/
showFileDialog_: function(selectType, operation, callback) {
window.handleFilePathSelected = function(filePath) {
handleFilePathSelected = function(filePath) {
callback(filePath);
window.handleFilePathSelected = function() {};
handleFilePathSelected = function() {};
};
chrome.send('packExtensionSelectFilePath', [selectType, operation]);
......@@ -104,14 +104,14 @@ cr.define('extensions', function() {
'',
function() {
extensions.ExtensionSettings.showOverlay(null);
});
},
null);
extensions.ExtensionSettings.showOverlay($('alertOverlay'));
};
/**
* Post an alert overlay showing |message|, and upon acknowledgement, close
* the alert overlay and return to showing the PackExtensionOverlay.
* @param {string} message The error message.
*/
PackExtensionOverlay.showError = function(message) {
alertOverlay.setValues(
......@@ -121,7 +121,8 @@ cr.define('extensions', function() {
'',
function() {
extensions.ExtensionSettings.showOverlay($('pack-extension-overlay'));
});
},
null);
extensions.ExtensionSettings.showOverlay($('alertOverlay'));
};
......
......@@ -42,9 +42,6 @@ void PopulateAppDict(const KioskAppManager::App& app_data,
if (!app_data.icon.isNull())
icon_url = webui::GetBitmapDataUrl(*app_data.icon.bitmap());
// The items which are to be written into app_dict are also described in
// chrome/browser/resources/extensions/chromeos/kiosk_app_list.js in @typedef
// for AppDict. Please update it whenever you add or remove any keys here.
app_dict->SetString("id", app_data.app_id);
app_dict->SetString("name", app_data.name);
app_dict->SetString("iconURL", icon_url);
......
......@@ -211,9 +211,6 @@ base::DictionaryValue* ExtensionSettingsHandler::CreateExtensionDetailValue(
const Extension* extension,
const std::vector<ExtensionPage>& pages,
const ExtensionWarningService* warning_service) {
// The items which are to be written into app_dict are also described in
// chrome/browser/resources/extensions/extension_list.js in @typedef for
// ExtensionData. Please update it whenever you add or remove any keys here.
base::DictionaryValue* extension_data = new base::DictionaryValue();
bool enabled = extension_service_->IsExtensionEnabled(extension->id());
GetExtensionBasicInfo(extension, enabled, extension_data);
......@@ -818,10 +815,6 @@ void ExtensionSettingsHandler::ReloadUnpackedExtensions() {
void ExtensionSettingsHandler::HandleRequestExtensionsData(
const base::ListValue* args) {
// The items which are to be written into results are also described in
// chrome/browser/resources/extensions/extensions.js in @typedef for
// ExtensionDataResponse. Please update it whenever you add or remove any keys
// here.
base::DictionaryValue results;
Profile* profile = Profile::FromWebUI(web_ui());
......
......@@ -158,10 +158,6 @@ RuntimeError::~RuntimeError() {
}
scoped_ptr<DictionaryValue> RuntimeError::ToValue() const {
// The items which are to be written into value are also described in
// chrome/browser/resources/extensions/extension_error_overlay.js in @typedef
// for RuntimeError and StackTrace. Please update them whenever you add or
// remove any keys here.
scoped_ptr<DictionaryValue> value = ExtensionError::ToValue();
value->SetString(kContextUrlKey, context_url_.spec());
value->SetInteger(kRenderViewIdKey, render_view_id_);
......
......@@ -62,7 +62,7 @@ cr.define('cr', function() {
/**
* Dispatches an event and calls all the listeners that are listening to
* the type of the event.
* @param {!Event} event The event to dispatch.
* @param {!cr.event.Event} event The event to dispatch.
* @return {boolean} Whether the default action was prevented. If someone
* calls preventDefault on the event object then this returns false.
*/
......
......@@ -42,18 +42,18 @@ cr.define('alertOverlay', function() {
* callbacks.
* @param {string} title The alert title to display to the user.
* @param {string} message The alert message to display to the user.
* @param {string=} opt_okTitle The title of the OK button. If undefined or
* empty, no button is shown.
* @param {string=} opt_cancelTitle The title of the cancel button. If
* undefined or empty, no button is shown.
* @param {string=} okTitle The title of the OK button. If undefined or empty,
* no button is shown.
* @param {string=} cancelTitle The title of the cancel button. If undefined
* or empty, no button is shown.
* @param {function()=} opt_okCallback A function to be called when the user
* presses the ok button. Can be undefined if |opt_okTitle| is falsey.
* presses the ok button. Can be undefined if |okTitle| is falsey.
* @param {function()=} opt_cancelCallback A function to be called when the
* user presses the cancel button. Can be undefined if |opt_cancelTitle|
* is falsey.
* user presses the cancel button. Can be undefined if |cancelTitle| is
* falsey.
*/
function setValues(title, message, opt_okTitle, opt_cancelTitle,
opt_okCallback, opt_cancelCallback) {
function setValues(title, message, okTitle, cancelTitle, opt_okCallback,
opt_cancelCallback) {
if (typeof title != 'undefined')
$('alertOverlayTitle').textContent = title;
$('alertOverlayTitle').hidden = typeof title == 'undefined';
......@@ -62,14 +62,14 @@ cr.define('alertOverlay', function() {
$('alertOverlayMessage').textContent = message;
$('alertOverlayMessage').hidden = typeof message == 'undefined';
if (opt_okTitle)
okButton.textContent = opt_okTitle;
okButton.hidden = !opt_okTitle;
if (okTitle)
okButton.textContent = okTitle;
okButton.hidden = !okTitle;
okButton.clickCallback = opt_okCallback;
if (opt_cancelTitle)
cancelButton.textContent = opt_cancelTitle;
cancelButton.hidden = !opt_cancelTitle;
if (cancelTitle)
cancelButton.textContent = cancelTitle;
cancelButton.hidden = !cancelTitle;
cancelButton.clickCallback = opt_cancelCallback;
};
......
......@@ -6,14 +6,6 @@
* @fileoverview This is a data model representin
*/
// The include directives are put into Javascript-style comments to prevent
// parsing errors in non-flattened mode. The flattener still sees them.
// Note that this makes the flattener to comment out the first line of the
// included file but that's all right since any javascript file should start
// with a copyright comment anyway.
//<include src="../../assert.js">
cr.define('cr.ui', function() {
/** @const */ var EventTarget = cr.EventTarget;
......@@ -22,7 +14,7 @@ cr.define('cr.ui', function() {
* initial indexes of elements for each position in sorted array.
* @param {!Array} array The underlying array.
* @constructor
* @extends {cr.EventTarget}
* @extends {EventTarget}
*/
function ArrayDataModel(array) {
this.array_ = array;
......@@ -70,8 +62,7 @@ cr.define('cr.ui', function() {
/**
* Sets compare function for given field.
* @param {string} field The field to set compare function.
* @param {function(*, *): number} compareFunction Compare function to set
* for given field.
* @param {function(*, *): number} Compare function to set for given field.
*/
setCompareFunction: function(field, compareFunction) {
if (!this.compareFunctions_) {
......@@ -136,7 +127,7 @@ cr.define('cr.ui', function() {
* the whole change.
* @param {number} index The index of the item to update.
* @param {number} deleteCount The number of items to remove.
* @param {...*} var_args The items to add.
* @param {...*} The items to add.
* @return {!Array} An array with the removed items.
*/
splice: function(index, deleteCount, var_args) {
......@@ -211,7 +202,7 @@ cr.define('cr.ui', function() {
*
* This dispatches a splice event.
*
* @param {...*} var_args The items to append.
* @param {...*} The items to append.
* @return {number} The new length of the model.
*/
push: function(var_args) {
......@@ -258,9 +249,11 @@ cr.define('cr.ui', function() {
* @param {Array.<number>} indexes The index list of items to update.
*/
updateIndexes: function(indexes) {
indexes.forEach(function(index) {
assert(index >= 0 && index < this.length, 'Invalid index');
var isIndexesValid = indexes.every(function(index) {
return 0 <= index && index < this.length;
}, this);
if (!isIndexesValid)
throw Error('Invalid index, ' + indexes[i]);
for (var i = 0; i < indexes.length; i++) {
var e = new Event('change');
......@@ -283,8 +276,8 @@ cr.define('cr.ui', function() {
/**
* Creates sort status with given field and direction.
* @param {?string} field Sort field.
* @param {?string} direction Sort direction.
* @param {string} field Sort field.
* @param {string} direction Sort direction.
* @return {!Object} Created sort status.
*/
createSortStatus: function(field, direction) {
......@@ -389,7 +382,7 @@ cr.define('cr.ui', function() {
* Returns the function set as sortFunction for given field
* or default compare function
* @param {string} field Sort field.
* @return {function(*, *): number} Compare function.
* @param {function(*, *): number} Compare function.
* @private
*/
createCompareFunction_: function(field) {
......@@ -403,12 +396,14 @@ cr.define('cr.ui', function() {
return defaultValuesCompareFunction.call(null, a[field], b[field]);
}
}
return compareFunction;
},
/**
* Creates compare function for given field and direction.
* @param {string} field Sort field.
* @param {string} direction Sort direction.
* @param {function(*, *): number} Compare function.
* @private
*/
sortFunction_: function(field, direction) {
......
......@@ -16,7 +16,6 @@ cr.define('cr.ui', function() {
* doDragLeave
* doDragOver
* doDrop
* @constructor
*/
function DragWrapper(target, handler) {
this.initialize(target, handler);
......
......@@ -90,9 +90,6 @@ cr.define('cr.ui', function() {
// Size comes here with margin already collapsed.
var size = this.getDefaultItemSize_();
if (!size)
return 0;
// We should uncollapse margin, since margin isn't collapsed for
// inline-block elements according to css spec which are thumbnail items.
......
......@@ -21,7 +21,7 @@ cr.define('cr.ui', function() {
* false if the mouseevent was generated over a border or a scrollbar.
* @param {!HTMLElement} el The element to test the event with.
* @param {!Event} e The mouse event.
* @return {boolean} Whether the mouse event was inside the viewport.
* @param {boolean} Whether the mouse event was inside the viewport.
*/
function inViewport(el, e) {
var rect = el.getBoundingClientRect();
......@@ -53,11 +53,11 @@ cr.define('cr.ui', function() {
* is needed. Note that lead item is allowed to have a different height, to
* accommodate lists where a single item at a time can be expanded to show
* more detail.
* @type {?{height: number, marginTop: number, marginBottom: number,
* width: number, marginLeft: number, marginRight: number}}
* @type {{height: number, marginTop: number, marginBottom:number,
* width: number, marginLeft: number, marginRight:number}}
* @private
*/
measured_: null,
measured_: undefined,
/**
* Whether or not the list is autoexpanding. If true, the list resizes
......@@ -85,14 +85,14 @@ cr.define('cr.ui', function() {
/**
* Function used to create grid items.
* @type {function(new:cr.ui.ListItem, Object)}
* @type {function(): !ListItem}
* @private
*/
itemConstructor_: cr.ui.ListItem,
/**
* Function used to create grid items.
* @return {function(new:cr.ui.ListItem, Object)}
* @type {function(): !ListItem}
*/
get itemConstructor() {
return this.itemConstructor_;
......@@ -242,7 +242,7 @@ cr.define('cr.ui', function() {
/**
* Convenience alias for selectionModel.selectedItems
* @type {!Array.<*>}
* @type {!Array<*>}
*/
get selectedItems() {
var indexes = this.selectionModel.selectedIndexes;
......@@ -397,18 +397,16 @@ cr.define('cr.ui', function() {
* @param {ListItem=} opt_item The list item to use to do the measuring. If
* this is not provided an item will be created based on the first value
* in the model.
* @return {{height: number, marginTop: number, marginBottom: number,
* width: number, marginLeft: number, marginRight: number}}
* @return {{height: number, marginTop: number, marginBottom:number,
* width: number, marginLeft: number, marginRight:number}}
* The height and width of the item, taking
* margins into account, and the top, bottom, left and right margins
* themselves.
*/
measureItem: function(opt_item) {
var dataModel = this.dataModel;
if (!dataModel || !dataModel.length) {
return {height: 0, marginTop: 0, marginBottom: 0,
width: 0, marginLeft: 0, marginRight: 0};
}
if (!dataModel || !dataModel.length)
return 0;
var item = opt_item || this.cachedMeasuredItem_ ||
this.createItem(dataModel.item(0));
if (!opt_item) {
......@@ -464,11 +462,11 @@ cr.define('cr.ui', function() {
if (this.disabled)
return;
var target = /** @type {HTMLElement} */(e.target);
var target = e.target;
var ancestor = this.getListItemAncestor(target);
if (ancestor)
this.activateItemAtIndex(this.getIndexOfListItem(ancestor));
target = this.getListItemAncestor(target);
if (target)
this.activateItemAtIndex(this.getIndexOfListItem(target));
},
/**
......@@ -480,7 +478,7 @@ cr.define('cr.ui', function() {
if (this.disabled)
return;
var target = /** @type {HTMLElement} */(e.target);
var target = e.target;
// If the target was this element we need to make sure that the user did
// not click on a border or a scrollbar.
......@@ -523,23 +521,26 @@ cr.define('cr.ui', function() {
* Returns the list item element containing the given element, or null if
* it doesn't belong to any list item element.
* @param {HTMLElement} element The element.
* @return {HTMLLIElement} The list item containing |element|, or null.
* @return {ListItem} The list item containing |element|, or null.
*/
getListItemAncestor: function(element) {
var container = element;
while (container && container.parentNode != this) {
container = container.parentNode;
}
return container && assertInstanceof(container, HTMLLIElement);
return container;
},
/**
* Handle a keydown event.
* @param {Event} e The keydown event.
* @return {boolean} Whether the key event was handled.
*/
handleKeyDown: function(e) {
if (!this.disabled)
this.selectionController_.handleKeyDown(e);
if (this.disabled)
return;
return this.selectionController_.handleKeyDown(e);
},
/**
......@@ -553,7 +554,7 @@ cr.define('cr.ui', function() {
/**
* Callback from the selection model. We dispatch {@code change} events
* when the selection changes.
* @param {!Event} ce Event with change info.
* @param {!Event} e Event with change info.
* @private
*/
handleOnChange_: function(ce) {
......@@ -605,7 +606,7 @@ cr.define('cr.ui', function() {
var self = this;
window.setTimeout(function() {
self.scrollIndexIntoView(pe.newValue);
}, 0);
});
}
}
},
......@@ -796,7 +797,7 @@ cr.define('cr.ui', function() {
/**
* Creates a new list item.
* @param {Object} value The value to use for the item.
* @param {*} value The value to use for the item.
* @return {!ListItem} The newly created list item.
*/
createItem: function(value) {
......@@ -1061,7 +1062,7 @@ cr.define('cr.ui', function() {
this.firstIndex_ = 0;
this.lastIndex_ = 0;
this.remainingSpace_ = this.clientHeight != 0;
this.mergeItems(0, 0);
this.mergeItems(0, 0, {}, {});
return;
}
......@@ -1275,11 +1276,10 @@ cr.define('cr.ui', function() {
/**
* Mousedown event handler.
* @this {cr.ui.List}
* @param {Event} e The mouse event object.
* @this {List}
* @param {MouseEvent} e The mouse event object.
*/
function handleMouseDown(e) {
e.target = /** @type {!HTMLElement} */(e.target);
var listItem = this.getListItemAncestor(e.target);
var wasSelected = listItem && listItem.selected;
this.handlePointerDownUp_(e);
......@@ -1307,11 +1307,10 @@ cr.define('cr.ui', function() {
* Dragstart event handler.
* If there is an item at starting position of drag operation and the item
* is not selected, select it.
* @this {cr.ui.List}
* @param {Event} e The event object for 'dragstart'.
* @this {List}
* @param {MouseEvent} e The event object for 'dragstart'.
*/
function handleDragStart(e) {
e = /** @type {MouseEvent} */(e);
var element = e.target.ownerDocument.elementFromPoint(e.clientX, e.clientY);
var listItem = this.getListItemAncestor(element);
if (!listItem)
......
......@@ -6,6 +6,7 @@ cr.define('cr.ui', function() {
/**
* Creates a new list item element.
* @param {string} opt_label The text label for the item.
* @constructor
* @extends {HTMLLIElement}
*/
......@@ -48,6 +49,7 @@ cr.define('cr.ui', function() {
/**
* Whether the item is selected. Setting this does not update the underlying
* selection model. This is only used for display purpose.
* @type {boolean}
*/
cr.defineProperty(ListItem, 'selected', cr.PropertyKind.BOOL_ATTR,
function() {
......@@ -57,12 +59,13 @@ cr.define('cr.ui', function() {
/**
* Whether the item is the lead in a selection. Setting this does not update
* the underlying selection model. This is only used for display purpose.
* @type {boolean}
*/
cr.defineProperty(ListItem, 'lead', cr.PropertyKind.BOOL_ATTR);
/**
* This item's index in the containing list.
* type {number}
* @type {number}
*/
cr.defineProperty(ListItem, 'listIndex');
......
......@@ -14,7 +14,7 @@ cr.define('cr.ui', function() {
* interact with.
*
* @constructor
* @extends {cr.EventTarget}
* @extends {!cr.EventTarget}
*/
function ListSelectionController(selectionModel) {
this.selectionModel_ = selectionModel;
......
......@@ -11,7 +11,7 @@ cr.define('cr.ui', function() {
* @param {number=} opt_length The number items in the selection.
*
* @constructor
* @extends {cr.EventTarget}
* @extends {!cr.EventTarget}
*/
function ListSelectionModel(opt_length) {
this.length_ = opt_length || 0;
......@@ -100,7 +100,7 @@ cr.define('cr.ui', function() {
/**
* Returns the nearest selected index or -1 if no item selected.
* @param {number} index The origin index.
* @return {number}
* @type {number}
* @private
*/
getNearestSelectedIndex_: function(index) {
......@@ -163,7 +163,7 @@ cr.define('cr.ui', function() {
unselectAll: function() {
this.beginChange();
for (var i in this.selectedIndexes_) {
this.setIndexSelected(+i, false);
this.setIndexSelected(i, false);
}
this.endChange();
},
......
......@@ -261,7 +261,7 @@ without changes to the corresponding grd file. -->
file="js/cr/ui/alert_overlay.js" type="chrome_html" />
<structure name="IDR_WEBUI_JS_CR_UI_ARRAY_DATA_MODEL"
file="js/cr/ui/array_data_model.js"
type="chrome_html" flattenhtml="true" />
type="chrome_html" />
<structure name="IDR_WEBUI_JS_CR_UI_AUTOCOMPLETE_LIST"
file="js/cr/ui/autocomplete_list.js"
type="chrome_html" />
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment