Commit c168caec authored by vitalyp's avatar vitalyp Committed by Commit bot

Compile chrome://settings, part 6

R=dbeam@chromium.org
BUG=393873
TEST=GYP_GENERATORS=ninja gyp --depth . chrome/browser/resources/options/compiled_resources.gyp && ninja -C out/Default | grep ERROR | wc -l

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

Cr-Commit-Position: refs/heads/master@{#295606}
parent f765cb48
......@@ -9,10 +9,12 @@ var keyboard = {};
/**
* Swallows keypress and keyup events of arrow keys.
* @param {KeyboardEvent} event Raised event.
* @param {Event} event Raised event.
* @private
*/
keyboard.onKeyIgnore_ = function(event) {
event = /** @type {KeyboardEvent} */(event);
if (event.ctrlKey || event.shiftKey || event.altKey || event.metaKey)
return;
......@@ -27,26 +29,28 @@ keyboard.onKeyIgnore_ = function(event) {
/**
* Converts arrow keys into tab/shift-tab key events.
* @param {KeyboardEvent} event Raised event.
* @param {Event} event Raised event.
* @private
*/
keyboard.onKeyDown_ = function(event) {
if (event.ctrlKey || event.shiftKey || event.altKey || event.metaKey)
return;
event = /** @type {KeyboardEvent} */(event);
var needsUpDownKeys = event.target.classList.contains('needs-up-down-keys');
if (event.ctrlKey || event.shiftKey || event.altKey || event.metaKey)
return;
if (event.keyIdentifier == 'Left' ||
(!needsUpDownKeys && event.keyIdentifier == 'Up')) {
keyboard.raiseKeyFocusPrevious(document.activeElement);
event.stopPropagation();
event.preventDefault();
} else if (event.keyIdentifier == 'Right' ||
(!needsUpDownKeys && event.keyIdentifier == 'Down')) {
keyboard.raiseKeyFocusNext(document.activeElement);
event.stopPropagation();
event.preventDefault();
}
var needsUpDownKeys = event.target.classList.contains('needs-up-down-keys');
if (event.keyIdentifier == 'Left' ||
(!needsUpDownKeys && event.keyIdentifier == 'Up')) {
keyboard.raiseKeyFocusPrevious(document.activeElement);
event.stopPropagation();
event.preventDefault();
} else if (event.keyIdentifier == 'Right' ||
(!needsUpDownKeys && event.keyIdentifier == 'Down')) {
keyboard.raiseKeyFocusNext(document.activeElement);
event.stopPropagation();
event.preventDefault();
}
};
/**
......
......@@ -125,7 +125,9 @@ cr.define('options', function() {
decorate: function() {
Grid.prototype.decorate.call(this);
this.dataModel = new ArrayDataModel([]);
this.itemConstructor = UserImagesGridItem;
this.itemConstructor =
/** @type {function(new:cr.ui.ListItem, Object)} */(
UserImagesGridItem);
this.selectionModel = new ListSingleSelectionModel();
this.inProgramSelection_ = false;
this.addEventListener('dblclick', this.handleDblClick_.bind(this));
......
......@@ -662,7 +662,8 @@ cr.define('options', function() {
true);
document.body.addEventListener('click', function(e) {
var button = findAncestor(e.target, function(el) {
var target = assertInstanceof(e.target, Node);
var button = findAncestor(target, function(el) {
return el.tagName == 'BUTTON' &&
el.dataset.extensionId !== undefined &&
el.dataset.extensionId.length;
......@@ -718,7 +719,7 @@ cr.define('options', function() {
* @private
*/
handleWindowMessage_: function(e) {
if (e.data.method == 'frameSelected')
if ((/** @type {{method: string}} */(e.data)).method == 'frameSelected')
$('search-field').focus();
},
......@@ -1252,7 +1253,8 @@ cr.define('options', function() {
/**
* Get the selected profile item from the profile list. This also works
* correctly if the list is not displayed.
* @return {Object} the profile item object, or null if nothing is selected.
* @return {?Object} The profile item object, or null if nothing is
* selected.
* @private
*/
getSelectedProfileItem_: function() {
......
......@@ -2,6 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @typedef {{
* id: string,
* name: string,
* subnodes: Array.<{id: string, name: string, readonly: boolean,
* untrusted: boolean, extractable: boolean,
* policy: boolean}>
* }}
*/
var CertificateData;
cr.define('options', function() {
/** @const */ var Tree = cr.ui.Tree;
/** @const */ var TreeItem = cr.ui.TreeItem;
......@@ -132,7 +143,7 @@ cr.define('options', function() {
/**
* Populate the tree.
* @param {Array} nodesData Nodes data array.
* @param {Array.<CertificateData>} nodesData Nodes data array.
*/
populate: function(nodesData) {
this.clear();
......
......@@ -36,6 +36,10 @@ cr.define('options.accounts', function() {
});
},
/**
* @override
* @param {Object} user
*/
createItem: function(user) {
return new UserListItem(user);
},
......
......@@ -105,7 +105,7 @@ cr.define('options.accounts', function() {
/**
* Handler for key down event.
* @private
* @param {!Event} e The keydown event object.
* @param {Event} e The keydown event object.
*/
handleKeyDown_: function(e) {
if (e.keyIdentifier == 'Enter') {
......
......@@ -57,16 +57,7 @@ cr.define('options', function() {
/**
* Description of the bluetooth device.
* @type {{name: string,
* address: string,
* paired: boolean,
* connected: boolean,
* connecting: boolean,
* connectable: boolean,
* pairing: (string|undefined),
* passkey: (number|undefined),
* pincode: (string|undefined),
* entered: (number|undefined)}}
* @type {?BluetoothDevice}
* @private
*/
device_: null,
......@@ -170,11 +161,11 @@ cr.define('options', function() {
* @param {Object} device Description of the bluetooth device.
*/
update: function(device) {
this.device_ = {};
this.device_ = /** @type {BluetoothDevice} */({});
for (var key in device)
this.device_[key] = device[key];
// Update the pairing instructions.
var instructionsEl = $('bluetooth-pairing-instructions');
var instructionsEl = assert($('bluetooth-pairing-instructions'));
this.clearElement_(instructionsEl);
this.dismissible_ = ('dismissible' in device) ?
device.dismissible : true;
......@@ -228,7 +219,7 @@ cr.define('options', function() {
/**
* Handles the ENTER key for the passkey or pincode entry field.
* @return {Event} a keydown event.
* @param {Event} event A keydown event.
* @private
*/
keyDownEventHandler_: function(event) {
......@@ -275,7 +266,7 @@ cr.define('options', function() {
* @param {string} key Passkey or PIN to display.
*/
updatePasskey_: function(key) {
var passkeyEl = $('bluetooth-pairing-passkey-display');
var passkeyEl = assert($('bluetooth-pairing-passkey-display'));
var keyClass = (this.device_.pairing == PAIRING.REMOTE_PASSKEY ||
this.device_.pairing == PAIRING.REMOTE_PIN_CODE) ?
'bluetooth-keyboard-button' : 'bluetooth-passkey-char';
......
......@@ -274,7 +274,8 @@ cr.define('options', function() {
return true;
e.preventDefault();
return this.startDragging_(e.target, {x: e.pageX, y: e.pageY});
var target = assertInstanceof(e.target, HTMLElement);
return this.startDragging_(target, {x: e.pageX, y: e.pageY});
},
/**
......@@ -292,7 +293,8 @@ cr.define('options', function() {
e.preventDefault();
var touch = e.touches[0];
this.lastTouchLocation_ = {x: touch.pageX, y: touch.pageY};
return this.startDragging_(e.target, this.lastTouchLocation_);
var target = assertInstanceof(e.target, HTMLElement);
return this.startDragging_(target, this.lastTouchLocation_);
},
/**
......
......@@ -387,11 +387,13 @@ cr.define('options.internet', function() {
* Creates an indicator event for controlled properties using
* the same dictionary format as CoreOptionsHandler::CreateValueForPref.
* @param {string} name The name for the Event.
* @param {!{value: *, controlledBy: *, recommendedValue: *}} propData
* Property dictionary,
* @param {{value: *, controlledBy: *, recommendedValue: *}} propData
* Property dictionary.
* @private
*/
createControlledEvent_: function(name, propData) {
assert('value' in propData && 'controlledBy' in propData &&
'recommendedValue' in propData);
var event = new Event(name);
event.value = {
value: propData.value,
......@@ -1569,11 +1571,14 @@ cr.define('options.internet', function() {
onc.getActiveValue(propName);
if (propValue == undefined)
continue;
propValue = assertInstanceof(propValue, Object);
var event;
if (managed)
event = detailsPage.createManagedEvent_(propName, propValue);
else
event = detailsPage.createControlledEvent_(propName, propValue);
event = detailsPage.createControlledEvent_(propName,
/** @type {{value: *, controlledBy: *, recommendedValue: *}} */(
propValue));
indicators[i].handlePrefChange(event);
var forElement = $(indicators[i].getAttribute('for'));
if (forElement) {
......
......@@ -33,7 +33,8 @@ cr.define('options', function() {
options.SettingsDialog.call(this, 'keyboard-overlay',
loadTimeData.getString('keyboardOverlayTabTitle'),
'keyboard-overlay',
$('keyboard-confirm'), $('keyboard-cancel'));
assertInstanceof($('keyboard-confirm'), HTMLButtonElement),
assertInstanceof($('keyboard-cancel'), HTMLButtonElement));
}
cr.addSingletonGetter(KeyboardOverlay);
......
......@@ -2,6 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @typedef {{
* ConnectionState: string,
* iconURL: string,
* policyManaged: boolean,
* servicePath: string
* }}
* @see chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc
*/
var NetworkInfo;
cr.define('options.network', function() {
var ArrayDataModel = cr.ui.ArrayDataModel;
var List = cr.ui.List;
......@@ -392,8 +403,8 @@ cr.define('options.network', function() {
/**
* Creates a control for selecting or configuring a network connection based
* on the type of connection (e.g. wifi versus vpn).
* @param {{key: string, networkList: Array.<Object>}} data Description of the
* network.
* @param {{key: string, networkList: Array.<NetworkInfo>}} data Description
* of the network.
* @constructor
* @extends {NetworkMenuItem}
*/
......@@ -654,7 +665,7 @@ cr.define('options.network', function() {
/**
* Extracts a mapping of network names to menu element and position.
* @param {!Element} menu The menu to process.
* @return {Object.<string, {index: number, button: Element}>}
* @return {Object.<string, ?{index: number, button: Element}>}
* Network mapping.
* @private
*/
......@@ -923,12 +934,19 @@ cr.define('options.network', function() {
this.endBatchUpdates();
},
/** @override */
/**
* @override
* @param {Object} entry
*/
createItem: function(entry) {
if (entry.networkList)
return new NetworkSelectorItem(entry);
return new NetworkSelectorItem(
/** @type {{key: string, networkList: Array.<NetworkInfo>}} */(
entry));
if (entry.command)
return new NetworkButtonItem(entry);
return new NetworkButtonItem(
/** @type {{key: string, subtitle: string, command: Function}} */(
entry));
if (entry.menu)
return new NetworkMenuItem(entry);
return undefined;
......@@ -971,12 +989,12 @@ cr.define('options.network', function() {
/**
* Chrome callback for updating network controls.
* @param {{wiredList: Array, wirelessList: Array, vpnList: Array,
* rememberedList: Array, wifiAvailable: boolean, wifiEnabled: boolean,
* wimaxAvailable: boolean, wimaxEnabled: boolean,
* cellularAvailable: boolean, cellularEnabled: boolean,
* cellularSupportsScan: boolean}} data Description of available network
* devices and their corresponding state.
* @param {{wiredList: Array.<NetworkInfo>, wirelessList: Array.<NetworkInfo>,
* vpnList: Array.<NetworkInfo>, rememberedList: Array.<NetworkInfo>,
* wifiAvailable: boolean, wifiEnabled: boolean, wimaxAvailable: boolean,
* wimaxEnabled: boolean, cellularAvailable: boolean,
* cellularEnabled: boolean, cellularSupportsScan: boolean}} data
* Description of available network devices and their corresponding state.
*/
NetworkList.refreshNetworkData = function(data) {
var networkList = $('network-list');
......
......@@ -7,6 +7,14 @@
* ONC managed or unmanaged dictionaries. Supports nested dictionaries,
* e.g. data.getManagedProperty('VPN.Type').
*/
cr.exportPath('cr.onc');
/**
* @typedef {(Object|Array|string|undefined)}
*/
cr.onc.OncValue;
cr.define('cr.onc', function() {
'use strict';
......@@ -22,8 +30,8 @@ cr.define('cr.onc', function() {
/**
* Returns either a managed property dictionary or an unmanaged value.
* @param {string} key The property key.
* @return {*} The property value or dictionary if it exists, otherwise
* undefined.
* @return {cr.onc.OncValue} The property value or dictionary if it exists,
* otherwise undefined.
*/
getManagedProperty: function(key) {
var data = this.data_;
......@@ -44,7 +52,7 @@ cr.define('cr.onc', function() {
* Sets the value of a property. Currently only supports unmanaged
* properties.
* @param {string} key The property key.
* @param {string} value The property value to set.
* @param {Object} value The property value to set.
*/
setManagedProperty: function(key, value) {
var data = this.data_;
......@@ -76,7 +84,7 @@ cr.define('cr.onc', function() {
/**
* Gets the active value of a property.
* @param {string} key The property key.
* @return {*} The property value or undefined.
* @return {cr.onc.OncValue} The property value or undefined.
*/
getActiveValue: function(key) {
var property = this.getManagedProperty(key);
......@@ -86,7 +94,8 @@ cr.define('cr.onc', function() {
if ('Active' in property)
return property['Active'];
// If no Active value is defined, return the effective value if present.
var effective = this.getEffectiveValueFromProperty_(property);
var effective = this.getEffectiveValueFromProperty_(
/** @type {Object} */(property));
if (effective != undefined)
return effective;
// Otherwise this is an Object but not a Managed one.
......@@ -97,7 +106,8 @@ cr.define('cr.onc', function() {
* Gets the translated ONC value from the result of getActiveValue() using
* loadTimeData. If no translation exists, returns the untranslated value.
* @param {string} key The property key.
* @return {*} The translation if available or the value if not.
* @return {cr.onc.OncValue} The translation if available or the value if
* not.
*/
getTranslatedValue: function(key) {
var value = this.getActiveValue(key);
......@@ -121,7 +131,7 @@ cr.define('cr.onc', function() {
/**
* Gets the recommended value of a property.
* @param {string} key The property key.
* @return {*} The property value or undefined.
* @return {cr.onc.OncValue} The property value or undefined.
*/
getRecommendedValue: function(key) {
var property = this.getManagedProperty(key);
......@@ -161,7 +171,7 @@ cr.define('cr.onc', function() {
/**
* Get the effective value from a Managed property ONC dictionary.
* @param {Object} property The managed property ONC dictionary.
* @return {*} The effective value or undefined.
* @return {cr.onc.OncValue} The effective value or undefined.
* @private
*/
getEffectiveValueFromProperty_: function(property) {
......
......@@ -15,9 +15,9 @@ cr.define('options', function() {
// The title is updated dynamically in the setTitle method as pointer
// devices are discovered or removed.
SettingsDialog.call(this, 'pointer-overlay',
'', 'pointer-overlay',
$('pointer-overlay-confirm'),
$('pointer-overlay-cancel'));
'', 'pointer-overlay',
assertInstanceof($('pointer-overlay-confirm'), HTMLButtonElement),
assertInstanceof($('pointer-overlay-cancel'), HTMLButtonElement));
}
cr.addSingletonGetter(PointerOverlay);
......
......@@ -2,6 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
cr.exportPath('options');
/**
* @typedef {{Name: string, Type: string, servicePath: string}}
*/
options.PreferredNetwork;
cr.define('options', function() {
var Page = cr.ui.pageManager.Page;
......@@ -19,7 +26,7 @@ cr.define('options', function() {
* @extends {cr.ui.pageManager.Page}
*/
function PreferredNetworks(model) {
Page.call(this, 'preferredNetworksPage', null, 'preferredNetworksPage');
Page.call(this, 'preferredNetworksPage', '', 'preferredNetworksPage');
}
cr.addSingletonGetter(PreferredNetworks);
......@@ -48,8 +55,7 @@ cr.define('options', function() {
/**
* Creates a list entry for a remembered network.
* @param {{Name: string, Type: string, servicePath: string}} data
* Description of the network.
* @param {options.PreferredNetwork} data Description of the network.
* @constructor
* @extends {options.DeletableItem}
*/
......@@ -68,7 +74,7 @@ cr.define('options', function() {
/**
* Description of the network.
* @type {{Name: string, Type: string, servicePath: string}}
* @type {?options.PreferredNetwork}
*/
data: null,
......@@ -108,7 +114,10 @@ cr.define('options', function() {
this.selectionModel.unselectAll();
},
/** @override */
/**
* @override
* @param {options.PreferredNetwork} entry
*/
createItem: function(entry) {
return new PreferredNetworkListItem(entry);
},
......@@ -140,8 +149,7 @@ cr.define('options', function() {
/**
* Adds a remembered network to the list.
* @param {{Name: string, Type: string, servicePath: string}} data
* Description of the network.
* @param {options.PreferredNetwork} data Description of the network.
*/
append: function(data) {
this.dataModel.push(data);
......
......@@ -39,6 +39,10 @@ cr.define('options.proxyexceptions', function() {
});
},
/**
* @override
* @param {Object} exception
*/
createItem: function(exception) {
return new ProxyExceptionsItem(exception);
},
......
......@@ -17,8 +17,9 @@ cr.define('options', function() {
this, 'thirdPartyImeConfirm',
loadTimeData.getString('thirdPartyImeConfirmOverlayTabTitle'),
'third-party-ime-confirm-overlay',
$('third-party-ime-confirm-ok'),
$('third-party-ime-confirm-cancel'));
assertInstanceof($('third-party-ime-confirm-ok'), HTMLButtonElement),
assertInstanceof($('third-party-ime-confirm-cancel'),
HTMLButtonElement));
}
cr.addSingletonGetter(ThirdPartyImeConfirmOverlay);
......
......@@ -37,6 +37,7 @@
'../../../../ui/webui/resources/js/load_time_data.js',
'../../../../ui/webui/resources/js/parse_html_subset.js',
'../../../../ui/webui/resources/js/util.js',
'../../../../chrome/browser/resources/chromeos/keyboard/keyboard_utils.js',
],
'externs': ['<(CLOSURE_DIR)/externs/chrome_send_externs.js'],
},
......
......@@ -152,7 +152,8 @@ cr.define('options', function() {
var target = e.target;
if (target.classList.contains('row-delete-button')) {
var listItem = this.getListItemAncestor(target);
var listItem = this.getListItemAncestor(
/** @type {HTMLElement} */(target));
var idx = this.getIndexOfListItem(listItem);
this.deleteItemAtIndex(idx);
}
......
......@@ -42,7 +42,11 @@ cr.define('options', function() {
/////////////////////////////////////////////////////////////////////////////
// PrefInputElement class:
// Define a constructor that uses an input element as its underlying element.
/**
* Define a constructor that uses an input element as its underlying element.
* @constructor
* @extends {HTMLInputElement}
*/
var PrefInputElement = cr.ui.define('input');
PrefInputElement.prototype = {
......@@ -323,8 +327,11 @@ cr.define('options', function() {
* @private
*/
updatePrefFromState_: function() {
Preferences.setIntegerPref(this.pref, this.mapPositionToPref(this.value),
!this.dialogPref, this.metric);
Preferences.setIntegerPref(
this.pref,
this.mapPositionToPref(parseInt(this.value, 10)),
!this.dialogPref,
this.metric);
},
/**
......@@ -575,6 +582,7 @@ cr.define('options', function() {
// Export
return {
PrefCheckbox: PrefCheckbox,
PrefInputElement: PrefInputElement,
PrefNumber: PrefNumber,
PrefRadio: PrefRadio,
PrefRange: PrefRange,
......
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