Commit 4afa337e authored by dpapad's avatar dpapad Committed by Commit Bot

WebUI: Use const/let instead of var in cr_components/.

Conversions performed with a tool
./node_modules/lebab/bin/index.js \
    --replace ui/webui/resources/cr_components --transform let

A .eslintrc.js file already exists, so probably these violations had
not been fixed at the time it was added.

Bug: 792774
Change-Id: I647bbf9a08c816fe810acf6582a5d9a0a45a96a0
Reviewed-on: https://chromium-review.googlesource.com/c/1354575Reviewed-by: default avatarDan Beam <dbeam@chromium.org>
Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612822}
parent 79d17cde
...@@ -60,7 +60,7 @@ Polymer({ ...@@ -60,7 +60,7 @@ Polymer({
onOkTap_: function() { onOkTap_: function() {
this.$.spinner.active = true; this.$.spinner.active = true;
var whenDone = this.model.id ? const whenDone = this.model.id ?
this.browserProxy_.editCaCertificateTrust( this.browserProxy_.editCaCertificateTrust(
this.model.id, this.$.ssl.checked, this.$.email.checked, this.model.id, this.$.ssl.checked, this.$.email.checked,
this.$.objSign.checked) : this.$.objSign.checked) :
......
...@@ -42,7 +42,7 @@ Polymer({ ...@@ -42,7 +42,7 @@ Polymer({
* @param {string} localizedMessageId * @param {string} localizedMessageId
* @return {string} * @return {string}
*/ */
var getString = localizedMessageId => const getString = localizedMessageId =>
loadTimeData.getStringF(localizedMessageId, this.model.name); loadTimeData.getStringF(localizedMessageId, this.model.name);
switch (this.certificateType) { switch (this.certificateType) {
...@@ -63,7 +63,7 @@ Polymer({ ...@@ -63,7 +63,7 @@ Polymer({
* @return {string} * @return {string}
*/ */
getDescriptionText_: function() { getDescriptionText_: function() {
var getString = loadTimeData.getString.bind(loadTimeData); const getString = loadTimeData.getString.bind(loadTimeData);
switch (this.certificateType) { switch (this.certificateType) {
case CertificateType.PERSONAL: case CertificateType.PERSONAL:
return getString('certificateManagerDeleteUserDescription'); return getString('certificateManagerDeleteUserDescription');
......
...@@ -145,7 +145,7 @@ Polymer({ ...@@ -145,7 +145,7 @@ Polymer({
* @private * @private
*/ */
handleImport_: function(useHardwareBacked, anchor) { handleImport_: function(useHardwareBacked, anchor) {
var browserProxy = const browserProxy =
certificate_manager.CertificatesBrowserProxyImpl.getInstance(); certificate_manager.CertificatesBrowserProxyImpl.getInstance();
if (this.certificateType == CertificateType.PERSONAL) { if (this.certificateType == CertificateType.PERSONAL) {
browserProxy.importPersonalCertificate(useHardwareBacked) browserProxy.importPersonalCertificate(useHardwareBacked)
......
...@@ -160,7 +160,8 @@ Polymer({ ...@@ -160,7 +160,8 @@ Polymer({
}); });
this.addEventListener('certificates-error', event => { this.addEventListener('certificates-error', event => {
var detail = /** @type {!CertificatesErrorEventDetail} */ (event.detail); const detail =
/** @type {!CertificatesErrorEventDetail} */ (event.detail);
this.errorDialogModel_ = detail.error; this.errorDialogModel_ = detail.error;
this.openDialog_( this.openDialog_(
'certificates-error-dialog', 'showErrorDialog_', detail.anchor); 'certificates-error-dialog', 'showErrorDialog_', detail.anchor);
...@@ -188,7 +189,7 @@ Polymer({ ...@@ -188,7 +189,7 @@ Polymer({
this.activeDialogAnchor_ = anchor; this.activeDialogAnchor_ = anchor;
this.set(domIfBooleanName, true); this.set(domIfBooleanName, true);
this.async(() => { this.async(() => {
var dialog = this.$$(dialogTagName); const dialog = this.$$(dialogTagName);
dialog.addEventListener('close', () => { dialog.addEventListener('close', () => {
this.set(domIfBooleanName, false); this.set(domIfBooleanName, false);
cr.ui.focusWithoutInk(assert(this.activeDialogAnchor_)); cr.ui.focusWithoutInk(assert(this.activeDialogAnchor_));
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* anchor: !HTMLElement * anchor: !HTMLElement
* }} * }}
*/ */
var CertificateActionEventDetail; let CertificateActionEventDetail;
/** /**
* The payload of the 'certificates-error' event. * The payload of the 'certificates-error' event.
...@@ -24,13 +24,13 @@ var CertificateActionEventDetail; ...@@ -24,13 +24,13 @@ var CertificateActionEventDetail;
* anchor: ?HTMLElement * anchor: ?HTMLElement
* }} * }}
*/ */
var CertificatesErrorEventDetail; let CertificatesErrorEventDetail;
/** /**
* Enumeration of actions that require a popup menu to be shown to the user. * Enumeration of actions that require a popup menu to be shown to the user.
* @enum {number} * @enum {number}
*/ */
var CertificateAction = { const CertificateAction = {
DELETE: 0, DELETE: 0,
EDIT: 1, EDIT: 1,
EXPORT_PERSONAL: 2, EXPORT_PERSONAL: 2,
...@@ -41,4 +41,4 @@ var CertificateAction = { ...@@ -41,4 +41,4 @@ var CertificateAction = {
* The name of the event fired when a certificate action is selected from the * The name of the event fired when a certificate action is selected from the
* dropdown menu. CertificateActionEventDetail is passed as the event detail. * dropdown menu. CertificateActionEventDetail is passed as the event detail.
*/ */
var CertificateActionEvent = 'certificate-action'; const CertificateActionEvent = 'certificate-action';
...@@ -62,7 +62,7 @@ Polymer({ ...@@ -62,7 +62,7 @@ Polymer({
/** @private */ /** @private */
validate_: function() { validate_: function() {
var isValid = const isValid =
this.password_ != '' && this.password_ == this.confirmPassword_; this.password_ != '' && this.password_ == this.confirmPassword_;
this.$.ok.disabled = !isValid; this.$.ok.disabled = !isValid;
}, },
......
...@@ -144,7 +144,7 @@ Polymer({ ...@@ -144,7 +144,7 @@ Polymer({
/** @private */ /** @private */
onDotsTap_: function() { onDotsTap_: function() {
var actionMenu = /** @type {!CrActionMenuElement} */ (this.$.menu.get()); const actionMenu = /** @type {!CrActionMenuElement} */ (this.$.menu.get());
actionMenu.showAt(this.$.dots); actionMenu.showAt(this.$.dots);
}, },
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
* }} * }}
* @see chrome/browser/ui/webui/settings/certificates_handler.cc * @see chrome/browser/ui/webui/settings/certificates_handler.cc
*/ */
var CertificateSubnode; let CertificateSubnode;
/** /**
* A data structure describing a certificate that is currently being imported, * A data structure describing a certificate that is currently being imported,
...@@ -28,7 +28,7 @@ var CertificateSubnode; ...@@ -28,7 +28,7 @@ var CertificateSubnode;
* name: string, * name: string,
* }} * }}
*/ */
var NewCertificateSubNode; let NewCertificateSubNode;
/** /**
* Top-level grouping node in a certificate list, representing an organization * Top-level grouping node in a certificate list, representing an organization
...@@ -43,7 +43,7 @@ var NewCertificateSubNode; ...@@ -43,7 +43,7 @@ var NewCertificateSubNode;
* }} * }}
* @see chrome/browser/ui/webui/settings/certificates_handler.cc * @see chrome/browser/ui/webui/settings/certificates_handler.cc
*/ */
var CertificatesOrgGroup; let CertificatesOrgGroup;
/** /**
* @typedef {{ * @typedef {{
...@@ -52,7 +52,7 @@ var CertificatesOrgGroup; ...@@ -52,7 +52,7 @@ var CertificatesOrgGroup;
* objSign: boolean * objSign: boolean
* }} * }}
*/ */
var CaTrustInfo; let CaTrustInfo;
/** /**
* Generic error returned from C++ via a Promise reject callback. * Generic error returned from C++ via a Promise reject callback.
...@@ -62,13 +62,13 @@ var CaTrustInfo; ...@@ -62,13 +62,13 @@ var CaTrustInfo;
* }} * }}
* @see chrome/browser/ui/webui/settings/certificates_handler.cc * @see chrome/browser/ui/webui/settings/certificates_handler.cc
*/ */
var CertificatesError; let CertificatesError;
/** /**
* Enumeration of all possible certificate types. * Enumeration of all possible certificate types.
* @enum {string} * @enum {string}
*/ */
var CertificateType = { const CertificateType = {
CA: 'ca', CA: 'ca',
OTHER: 'other', OTHER: 'other',
PERSONAL: 'personal', PERSONAL: 'personal',
...@@ -86,7 +86,7 @@ var CertificateType = { ...@@ -86,7 +86,7 @@ var CertificateType = {
* }} * }}
* @see chrome/browser/ui/webui/settings/certificates_handler.cc * @see chrome/browser/ui/webui/settings/certificates_handler.cc
*/ */
var CertificatesImportError; let CertificatesImportError;
cr.define('certificate_manager', function() { cr.define('certificate_manager', function() {
/** @interface */ /** @interface */
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* NOTE: This module depends on I18nBehavior which depends on loadTimeData. * NOTE: This module depends on I18nBehavior which depends on loadTimeData.
*/ */
var PairingEventType = chrome.bluetoothPrivate.PairingEventType; const PairingEventType = chrome.bluetoothPrivate.PairingEventType;
Polymer({ Polymer({
is: 'bluetooth-dialog', is: 'bluetooth-dialog',
...@@ -105,7 +105,7 @@ Polymer({ ...@@ -105,7 +105,7 @@ Polymer({
close: function() { close: function() {
this.endPairing(); this.endPairing();
var dialog = this.getDialog_(); const dialog = this.getDialog_();
if (dialog.open) if (dialog.open)
dialog.close(); dialog.close();
}, },
...@@ -119,7 +119,7 @@ Polymer({ ...@@ -119,7 +119,7 @@ Polymer({
* @return {boolean} * @return {boolean}
*/ */
handleError: function(device, lastError, result) { handleError: function(device, lastError, result) {
var error; let error;
if (lastError) { if (lastError) {
error = lastError.message; error = lastError.message;
} else { } else {
...@@ -135,8 +135,8 @@ Polymer({ ...@@ -135,8 +135,8 @@ Polymer({
} }
} }
var name = device.name || device.address; const name = device.name || device.address;
var id = 'bluetooth_connect_' + error; const id = 'bluetooth_connect_' + error;
if (this.i18nExists(id)) { if (this.i18nExists(id)) {
this.errorMessage_ = this.i18n(id, name); this.errorMessage_ = this.i18n(id, name);
} else { } else {
...@@ -256,7 +256,7 @@ Polymer({ ...@@ -256,7 +256,7 @@ Polymer({
* @private * @private
*/ */
getMessage_: function() { getMessage_: function() {
var message; let message;
if (!this.pairingEvent_) if (!this.pairingEvent_)
message = 'bluetoothStartConnecting'; message = 'bluetoothStartConnecting';
else else
...@@ -289,7 +289,7 @@ Polymer({ ...@@ -289,7 +289,7 @@ Polymer({
showDisplayPassOrPin_: function() { showDisplayPassOrPin_: function() {
if (!this.pairingEvent_) if (!this.pairingEvent_)
return false; return false;
var pairing = this.pairingEvent_.pairing; const pairing = this.pairingEvent_.pairing;
return ( return (
pairing == PairingEventType.DISPLAY_PINCODE || pairing == PairingEventType.DISPLAY_PINCODE ||
pairing == PairingEventType.DISPLAY_PASSKEY || pairing == PairingEventType.DISPLAY_PASSKEY ||
...@@ -313,7 +313,7 @@ Polymer({ ...@@ -313,7 +313,7 @@ Polymer({
showConnect_: function() { showConnect_: function() {
if (!this.pairingEvent_) if (!this.pairingEvent_)
return false; return false;
var pairing = this.pairingEvent_.pairing; const pairing = this.pairingEvent_.pairing;
return pairing == PairingEventType.REQUEST_PINCODE || return pairing == PairingEventType.REQUEST_PINCODE ||
pairing == PairingEventType.REQUEST_PASSKEY; pairing == PairingEventType.REQUEST_PASSKEY;
}, },
...@@ -325,13 +325,13 @@ Polymer({ ...@@ -325,13 +325,13 @@ Polymer({
enableConnect_: function() { enableConnect_: function() {
if (!this.showConnect_()) if (!this.showConnect_())
return false; return false;
var inputId = const inputId =
(this.pairingEvent_.pairing == PairingEventType.REQUEST_PINCODE) ? (this.pairingEvent_.pairing == PairingEventType.REQUEST_PINCODE) ?
'#pincode' : '#pincode' :
'#passkey'; '#passkey';
var crInput = /** @type {!CrInputElement} */ (this.$$(inputId)); const crInput = /** @type {!CrInputElement} */ (this.$$(inputId));
assert(crInput); assert(crInput);
/** @type {string} */ var value = crInput.value; /** @type {string} */ const value = crInput.value;
return !!value && crInput.validate(); return !!value && crInput.validate();
}, },
...@@ -367,11 +367,11 @@ Polymer({ ...@@ -367,11 +367,11 @@ Polymer({
sendResponse_: function(response) { sendResponse_: function(response) {
if (!this.pairingDevice) if (!this.pairingDevice)
return; return;
var options = const options =
/** @type {!chrome.bluetoothPrivate.SetPairingResponseOptions} */ ( /** @type {!chrome.bluetoothPrivate.SetPairingResponseOptions} */ (
{device: this.pairingDevice, response: response}); {device: this.pairingDevice, response: response});
if (response == chrome.bluetoothPrivate.PairingResponse.CONFIRM) { if (response == chrome.bluetoothPrivate.PairingResponse.CONFIRM) {
var pairing = this.pairingEvent_.pairing; const pairing = this.pairingEvent_.pairing;
if (pairing == PairingEventType.REQUEST_PINCODE) if (pairing == PairingEventType.REQUEST_PINCODE)
options.pincode = this.$$('#pincode').value; options.pincode = this.$$('#pincode').value;
else if (pairing == PairingEventType.REQUEST_PASSKEY) else if (pairing == PairingEventType.REQUEST_PASSKEY)
...@@ -414,8 +414,8 @@ Polymer({ ...@@ -414,8 +414,8 @@ Polymer({
getPinDigit_: function(index) { getPinDigit_: function(index) {
if (!this.pairingEvent_) if (!this.pairingEvent_)
return ''; return '';
var digit = '0'; let digit = '0';
var pairing = this.pairingEvent_.pairing; const pairing = this.pairingEvent_.pairing;
if (pairing == PairingEventType.DISPLAY_PINCODE && if (pairing == PairingEventType.DISPLAY_PINCODE &&
this.pairingEvent_.pincode && this.pairingEvent_.pincode &&
index < this.pairingEvent_.pincode.length) { index < this.pairingEvent_.pincode.length) {
...@@ -425,7 +425,7 @@ Polymer({ ...@@ -425,7 +425,7 @@ Polymer({
(pairing == PairingEventType.DISPLAY_PASSKEY || (pairing == PairingEventType.DISPLAY_PASSKEY ||
pairing == PairingEventType.KEYS_ENTERED || pairing == PairingEventType.KEYS_ENTERED ||
pairing == PairingEventType.CONFIRM_PASSKEY)) { pairing == PairingEventType.CONFIRM_PASSKEY)) {
var passkeyString = const passkeyString =
String(this.pairingEvent_.passkey).padStart(this.digits_.length, '0'); String(this.pairingEvent_.passkey).padStart(this.digits_.length, '0');
digit = passkeyString[index]; digit = passkeyString[index];
} }
...@@ -442,7 +442,7 @@ Polymer({ ...@@ -442,7 +442,7 @@ Polymer({
return ''; return '';
if (this.pairingEvent_.pairing == PairingEventType.CONFIRM_PASSKEY) if (this.pairingEvent_.pairing == PairingEventType.CONFIRM_PASSKEY)
return 'confirm'; return 'confirm';
var cssClass = 'display'; let cssClass = 'display';
if (this.pairingEvent_.pairing == PairingEventType.DISPLAY_PASSKEY) { if (this.pairingEvent_.pairing == PairingEventType.DISPLAY_PASSKEY) {
if (index == 0) if (index == 0)
cssClass += ' next'; cssClass += ' next';
...@@ -451,8 +451,8 @@ Polymer({ ...@@ -451,8 +451,8 @@ Polymer({
} else if ( } else if (
this.pairingEvent_.pairing == PairingEventType.KEYS_ENTERED && this.pairingEvent_.pairing == PairingEventType.KEYS_ENTERED &&
this.pairingEvent_.enteredKey) { this.pairingEvent_.enteredKey) {
var enteredKey = this.pairingEvent_.enteredKey; // 1-7 const enteredKey = this.pairingEvent_.enteredKey; // 1-7
var lastKey = this.digits_.length; // 6 const lastKey = this.digits_.length; // 6
if ((index == -1 && enteredKey > lastKey) || (index + 1 == enteredKey)) if ((index == -1 && enteredKey > lastKey) || (index + 1 == enteredKey))
cssClass += ' next'; cssClass += ' next';
else if (index > enteredKey) else if (index > enteredKey)
......
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