Commit 004cb56a authored by Roman Aleksandrov's avatar Roman Aleksandrov Committed by Commit Bot

Migrate away from using 'var' in network directory.

Just simple refactoring.

Bug: 792774
Change-Id: I90e97fb8fd4e1ab5bb91f03b19ec8031eeb24375
Reviewed-on: https://chromium-review.googlesource.com/c/1326145Reviewed-by: default avatarAlexander Hendrich <hendrich@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Commit-Queue: Roman Aleksandrov <raleksandrov@google.com>
Cr-Commit-Position: refs/heads/master@{#606918}
parent 31aaefcb
...@@ -91,10 +91,10 @@ Polymer({ ...@@ -91,10 +91,10 @@ Polymer({
if (!this.networkProperties || !this.networkProperties.Cellular) if (!this.networkProperties || !this.networkProperties.Cellular)
return; return;
/** @type {!CrOnc.APNProperties|undefined} */ var activeApn; /** @type {!CrOnc.APNProperties|undefined} */ let activeApn;
var cellular = this.networkProperties.Cellular; const cellular = this.networkProperties.Cellular;
/** @type {!chrome.networkingPrivate.ManagedAPNProperties|undefined} */ var /** @type {!chrome.networkingPrivate.ManagedAPNProperties|undefined} */
apn = cellular.APN; const apn = cellular.APN;
if (apn && apn.AccessPointName) { if (apn && apn.AccessPointName) {
activeApn = /** @type {!CrOnc.APNProperties|undefined} */ ( activeApn = /** @type {!CrOnc.APNProperties|undefined} */ (
CrOnc.getActiveProperties(apn)); CrOnc.getActiveProperties(apn));
...@@ -113,18 +113,18 @@ Polymer({ ...@@ -113,18 +113,18 @@ Polymer({
*/ */
setApnSelectList_: function(activeApn) { setApnSelectList_: function(activeApn) {
// Copy the list of APNs from this.networkProperties. // Copy the list of APNs from this.networkProperties.
var result = this.getApnList_().slice(); const result = this.getApnList_().slice();
// Test whether |activeApn| is in the current APN list in networkProperties. // Test whether |activeApn| is in the current APN list in networkProperties.
var activeApnInList = activeApn && result.some(function(a) { const activeApnInList = activeApn && result.some(function(a) {
return a.AccessPointName == activeApn.AccessPointName; return a.AccessPointName == activeApn.AccessPointName;
}); });
// If |activeApn| is specified and not in the list, use the active // If |activeApn| is specified and not in the list, use the active
// properties for 'other'. Otherwise use any existing 'other' properties. // properties for 'other'. Otherwise use any existing 'other' properties.
var otherApnProperties = const otherApnProperties =
(activeApn && !activeApnInList) ? activeApn : this.otherApn_; (activeApn && !activeApnInList) ? activeApn : this.otherApn_;
var otherApn = this.createApnObject_(otherApnProperties); const otherApn = this.createApnObject_(otherApnProperties);
// Always use 'Other' for the name of custom APN entries (the name does // Always use 'Other' for the name of custom APN entries (the name does
// not get saved). // not get saved).
...@@ -155,7 +155,7 @@ Polymer({ ...@@ -155,7 +155,7 @@ Polymer({
* @private * @private
*/ */
createApnObject_: function(apnProperties) { createApnObject_: function(apnProperties) {
var newApn = {AccessPointName: ''}; const newApn = {AccessPointName: ''};
if (apnProperties) if (apnProperties)
Object.assign(newApn, apnProperties); Object.assign(newApn, apnProperties);
return newApn; return newApn;
...@@ -169,8 +169,8 @@ Polymer({ ...@@ -169,8 +169,8 @@ Polymer({
getApnList_: function() { getApnList_: function() {
if (!this.networkProperties || !this.networkProperties.Cellular) if (!this.networkProperties || !this.networkProperties.Cellular)
return []; return [];
/** @type {!chrome.networkingPrivate.ManagedAPNList|undefined} */ var /** @type {!chrome.networkingPrivate.ManagedAPNList|undefined} */
apnlist = this.networkProperties.Cellular.APNList; const apnlist = this.networkProperties.Cellular.APNList;
if (!apnlist) if (!apnlist)
return []; return [];
return /** @type {!Array<!CrOnc.APNProperties>} */ ( return /** @type {!Array<!CrOnc.APNProperties>} */ (
...@@ -183,8 +183,8 @@ Polymer({ ...@@ -183,8 +183,8 @@ Polymer({
* @private * @private
*/ */
onSelectApnChange_: function(event) { onSelectApnChange_: function(event) {
var target = /** @type {!HTMLSelectElement} */ (event.target); const target = /** @type {!HTMLSelectElement} */ (event.target);
var accessPointName = target.value; const accessPointName = target.value;
// When selecting 'Other', don't set a change event unless a valid // When selecting 'Other', don't set a change event unless a valid
// non-default value has been set for Other. // non-default value has been set for Other.
if (this.isOtherSelected_(accessPointName) && if (this.isOtherSelected_(accessPointName) &&
...@@ -204,7 +204,7 @@ Polymer({ ...@@ -204,7 +204,7 @@ Polymer({
onOtherApnChange_: function(event) { onOtherApnChange_: function(event) {
// TODO(benchan/stevenjb): Move this to shill or // TODO(benchan/stevenjb): Move this to shill or
// onc_translator_onc_to_shill.cc. // onc_translator_onc_to_shill.cc.
var value = (event.detail.field == 'AccessPointName') ? const value = (event.detail.field == 'AccessPointName') ?
event.detail.value.toUpperCase() : event.detail.value.toUpperCase() :
event.detail.value; event.detail.value;
this.set('otherApn_.' + event.detail.field, value); this.set('otherApn_.' + event.detail.field, value);
...@@ -226,8 +226,8 @@ Polymer({ ...@@ -226,8 +226,8 @@ Polymer({
* @private * @private
*/ */
sendApnChange_: function(accessPointName) { sendApnChange_: function(accessPointName) {
var apnList = this.getApnList_(); const apnList = this.getApnList_();
var apn = this.findApnInList(apnList, accessPointName); let apn = this.findApnInList(apnList, accessPointName);
if (apn == undefined) { if (apn == undefined) {
apn = this.createApnObject_(); apn = this.createApnObject_();
if (this.otherApn_) { if (this.otherApn_) {
...@@ -247,8 +247,8 @@ Polymer({ ...@@ -247,8 +247,8 @@ Polymer({
isOtherSelected_: function(accessPointName) { isOtherSelected_: function(accessPointName) {
if (!this.networkProperties || !this.networkProperties.Cellular) if (!this.networkProperties || !this.networkProperties.Cellular)
return false; return false;
var apnList = this.getApnList_(); const apnList = this.getApnList_();
var apn = this.findApnInList(apnList, accessPointName); const apn = this.findApnInList(apnList, accessPointName);
return apn == undefined; return apn == undefined;
}, },
......
...@@ -66,13 +66,13 @@ Polymer({ ...@@ -66,13 +66,13 @@ Polymer({
networkPropertiesChanged_: function() { networkPropertiesChanged_: function() {
if (!this.networkProperties || !this.networkProperties.Cellular) if (!this.networkProperties || !this.networkProperties.Cellular)
return; return;
var cellular = this.networkProperties.Cellular; const cellular = this.networkProperties.Cellular;
this.mobileNetworkList_ = cellular.FoundNetworks || this.mobileNetworkList_ = cellular.FoundNetworks ||
[{NetworkId: 'none', LongName: this.i18n('networkCellularNoNetworks')}]; [{NetworkId: 'none', LongName: this.i18n('networkCellularNoNetworks')}];
// Set selectedMobileNetworkId_ after the dom-repeat has been stamped. // Set selectedMobileNetworkId_ after the dom-repeat has been stamped.
this.async(() => { this.async(() => {
var selected = this.mobileNetworkList_.find(function(mobileNetwork) { let selected = this.mobileNetworkList_.find(function(mobileNetwork) {
return mobileNetwork.Status == 'current'; return mobileNetwork.Status == 'current';
}); });
if (!selected) if (!selected)
...@@ -110,7 +110,7 @@ Polymer({ ...@@ -110,7 +110,7 @@ Polymer({
properties.ConnectionState != CrOnc.ConnectionState.NOT_CONNECTED) { properties.ConnectionState != CrOnc.ConnectionState.NOT_CONNECTED) {
return false; return false;
} }
var found = this.get('Cellular.FoundNetworks', properties); const found = this.get('Cellular.FoundNetworks', properties);
return !!found && found.length > 0; return !!found && found.length > 0;
}, },
...@@ -122,7 +122,7 @@ Polymer({ ...@@ -122,7 +122,7 @@ Polymer({
getSecondaryText_: function(properties) { getSecondaryText_: function(properties) {
if (!properties || !properties.Cellular) if (!properties || !properties.Cellular)
return ''; return '';
var cellular = properties.Cellular; const cellular = properties.Cellular;
if (cellular.Scanning) if (cellular.Scanning)
return this.i18n('networkCellularScanning'); return this.i18n('networkCellularScanning');
else if (this.scanRequested_) else if (this.scanRequested_)
...@@ -157,7 +157,7 @@ Polymer({ ...@@ -157,7 +157,7 @@ Polymer({
* @private * @private
*/ */
onChange_: function(event) { onChange_: function(event) {
var target = /** @type {!HTMLSelectElement} */ (event.target); const target = /** @type {!HTMLSelectElement} */ (event.target);
if (!target.value || target.value == 'none') if (!target.value || target.value == 'none')
return; return;
this.networkingPrivate.selectCellularMobileNetwork( this.networkingPrivate.selectCellularMobileNetwork(
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* Note: closure does not always recognize this if inside function() {}. * Note: closure does not always recognize this if inside function() {}.
* @enum {string} * @enum {string}
*/ */
var VPNConfigType = { const VPNConfigType = {
L2TP_IPSEC_PSK: 'L2TP_IPsec_PSK', L2TP_IPSEC_PSK: 'L2TP_IPsec_PSK',
L2TP_IPSEC_CERT: 'L2TP_IPsec_Cert', L2TP_IPSEC_CERT: 'L2TP_IPsec_Cert',
OPEN_VPN: 'OpenVPN', OPEN_VPN: 'OpenVPN',
...@@ -22,14 +22,14 @@ var VPNConfigType = { ...@@ -22,14 +22,14 @@ var VPNConfigType = {
(function() { (function() {
'use strict'; 'use strict';
/** @const */ var DEFAULT_HASH = 'default'; /** @type {string} */ const DEFAULT_HASH = 'default';
/** @const */ var DO_NOT_CHECK_HASH = 'do-not-check'; /** @type {string} */ const DO_NOT_CHECK_HASH = 'do-not-check';
/** @const */ var NO_CERTS_HASH = 'no-certs'; /** @type {string} */ const NO_CERTS_HASH = 'no-certs';
/** @const */ var NO_USER_CERT_HASH = 'no-user-cert'; /** @type {string} */ const NO_USER_CERT_HASH = 'no-user-cert';
// Used to indicate a saved but unknown PSK value. Will appear as *'s in the // Used to indicate a saved but unknown PSK value. Will appear as *'s in the
// PSK field by default. // PSK field by default.
/** @const */ var UNKNOWN_PSK = ' '; /** @type {string} */ const UNKNOWN_PSK = ' ';
Polymer({ Polymer({
is: 'network-config', is: 'network-config',
...@@ -404,7 +404,7 @@ Polymer({ ...@@ -404,7 +404,7 @@ Polymer({
this.propertiesSent_ = true; this.propertiesSent_ = true;
this.error = ''; this.error = '';
var propertiesToSet = this.getPropertiesToSet_(); const propertiesToSet = this.getPropertiesToSet_();
if (this.getSource_() == CrOnc.Source.NONE) { if (this.getSource_() == CrOnc.Source.NONE) {
// Set 'AutoConnect' to false for VPN or if prohibited by policy. // Set 'AutoConnect' to false for VPN or if prohibited by policy.
// Note: Do not set AutoConnect to true, the connection manager will do // Note: Do not set AutoConnect to true, the connection manager will do
...@@ -428,7 +428,7 @@ Polymer({ ...@@ -428,7 +428,7 @@ Polymer({
/** @private */ /** @private */
focusFirstInput_: function() { focusFirstInput_: function() {
Polymer.dom.flush(); Polymer.dom.flush();
var e = this.$$( const e = this.$$(
'network-config-input:not([readonly]),' + 'network-config-input:not([readonly]),' +
'network-password-input:not([disabled]),' + 'network-password-input:not([disabled]),' +
'network-config-select:not([disabled])'); 'network-config-select:not([disabled])');
...@@ -464,18 +464,18 @@ Polymer({ ...@@ -464,18 +464,18 @@ Polymer({
getSource_: function() { getSource_: function() {
if (!this.guid) if (!this.guid)
return CrOnc.Source.NONE; return CrOnc.Source.NONE;
var source = this.managedProperties.Source; const source = this.managedProperties.Source;
return source ? /** @type {!CrOnc.Source} */ (source) : CrOnc.Source.NONE; return source ? /** @type {!CrOnc.Source} */ (source) : CrOnc.Source.NONE;
}, },
/** @private */ /** @private */
onCertificateListsChanged_: function() { onCertificateListsChanged_: function() {
this.networkingPrivate.getCertificateLists(function(certificateLists) { this.networkingPrivate.getCertificateLists(function(certificateLists) {
var isOpenVpn = this.type == CrOnc.Type.VPN && const isOpenVpn = this.type == CrOnc.Type.VPN &&
this.get('VPN.Type', this.configProperties_) == this.get('VPN.Type', this.configProperties_) ==
CrOnc.VPNType.OPEN_VPN; CrOnc.VPNType.OPEN_VPN;
var caCerts = certificateLists.serverCaCertificates.slice(); const caCerts = certificateLists.serverCaCertificates.slice();
if (!isOpenVpn) { if (!isOpenVpn) {
// 'Default' is the same as 'Do not check' except it sets // 'Default' is the same as 'Do not check' except it sets
// eap.UseSystemCAs (which does not apply to OpenVPN). // eap.UseSystemCAs (which does not apply to OpenVPN).
...@@ -486,7 +486,7 @@ Polymer({ ...@@ -486,7 +486,7 @@ Polymer({
this.i18n('networkCADoNotCheck'), DO_NOT_CHECK_HASH)); this.i18n('networkCADoNotCheck'), DO_NOT_CHECK_HASH));
this.set('serverCaCerts_', caCerts); this.set('serverCaCerts_', caCerts);
var userCerts = certificateLists.userCertificates.slice(); let userCerts = certificateLists.userCertificates.slice();
// Only hardware backed user certs are supported. // Only hardware backed user certs are supported.
userCerts.forEach(function(cert) { userCerts.forEach(function(cert) {
if (!cert.hardwareBacked) if (!cert.hardwareBacked)
...@@ -638,7 +638,7 @@ Polymer({ ...@@ -638,7 +638,7 @@ Polymer({
// Look for an existing EAP configuration. This may be stored in a // Look for an existing EAP configuration. This may be stored in a
// separate 'Ethernet EAP Parameters' configuration. // separate 'Ethernet EAP Parameters' configuration.
var ethernetEap = networks.find(function(network) { const ethernetEap = networks.find(function(network) {
return !!network.Ethernet && return !!network.Ethernet &&
network.Ethernet.Authentication == CrOnc.Authentication.WEP_8021X; network.Ethernet.Authentication == CrOnc.Authentication.WEP_8021X;
}); });
...@@ -675,7 +675,7 @@ Polymer({ ...@@ -675,7 +675,7 @@ Polymer({
/** @private */ /** @private */
setShareNetwork_: function() { setShareNetwork_: function() {
var source = this.getSource_(); const source = this.getSource_();
if (source != CrOnc.Source.NONE) { if (source != CrOnc.Source.NONE) {
// Configured networks can not change whether they are shared. // Configured networks can not change whether they are shared.
this.shareNetwork_ = this.shareNetwork_ =
...@@ -694,7 +694,7 @@ Polymer({ ...@@ -694,7 +694,7 @@ Polymer({
return; return;
} }
// Networks requiring a user certificate cannot be shared. // Networks requiring a user certificate cannot be shared.
var eap = this.eapProperties_; const eap = this.eapProperties_;
if (eap && eap.Outer == CrOnc.EAPType.EAP_TLS) { if (eap && eap.Outer == CrOnc.EAPType.EAP_TLS) {
this.shareNetwork_ = false; this.shareNetwork_ = false;
return; return;
...@@ -714,8 +714,8 @@ Polymer({ ...@@ -714,8 +714,8 @@ Polymer({
this.showVpn_ = null; this.showVpn_ = null;
this.vpnType_ = undefined; this.vpnType_ = undefined;
var managedProperties = this.managedProperties; const managedProperties = this.managedProperties;
var configProperties = const configProperties =
/** @type {chrome.networkingPrivate.NetworkConfigProperties} */ ({ /** @type {chrome.networkingPrivate.NetworkConfigProperties} */ ({
Name: CrOnc.getActiveValue(managedProperties.Name) || '', Name: CrOnc.getActiveValue(managedProperties.Name) || '',
Type: managedProperties.Type, Type: managedProperties.Type,
...@@ -781,7 +781,7 @@ Polymer({ ...@@ -781,7 +781,7 @@ Polymer({
break; break;
case CrOnc.Type.VPN: case CrOnc.Type.VPN:
if (managedProperties.VPN) { if (managedProperties.VPN) {
var vpn = { const vpn = {
Host: /** @type {string|undefined} */ ( Host: /** @type {string|undefined} */ (
CrOnc.getActiveValue(managedProperties.VPN.Host)), CrOnc.getActiveValue(managedProperties.VPN.Host)),
Type: /** @type {string|undefined} */ ( Type: /** @type {string|undefined} */ (
...@@ -835,13 +835,13 @@ Polymer({ ...@@ -835,13 +835,13 @@ Polymer({
// Set the share value to its default when the security type changes. // Set the share value to its default when the security type changes.
this.setShareNetwork_(); this.setShareNetwork_();
} else if (this.type == CrOnc.Type.ETHERNET) { } else if (this.type == CrOnc.Type.ETHERNET) {
var auth = this.security_ == CrOnc.Security.WPA_EAP ? const auth = this.security_ == CrOnc.Security.WPA_EAP ?
CrOnc.Authentication.WEP_8021X : CrOnc.Authentication.WEP_8021X :
CrOnc.Authentication.NONE; CrOnc.Authentication.NONE;
this.set('Ethernet.Authentication', auth, this.configProperties_); this.set('Ethernet.Authentication', auth, this.configProperties_);
} }
if (this.security_ == CrOnc.Security.WPA_EAP) { if (this.security_ == CrOnc.Security.WPA_EAP) {
var eap = this.getEap_(this.configProperties_, true); const eap = this.getEap_(this.configProperties_, true);
eap.Outer = eap.Outer || CrOnc.EAPType.LEAP; eap.Outer = eap.Outer || CrOnc.EAPType.LEAP;
this.setEap_(eap); this.setEap_(eap);
} else { } else {
...@@ -855,10 +855,10 @@ Polymer({ ...@@ -855,10 +855,10 @@ Polymer({
* @private * @private
*/ */
updateEapOuter_: function() { updateEapOuter_: function() {
var eap = this.eapProperties_; const eap = this.eapProperties_;
if (!eap || !eap.Outer) if (!eap || !eap.Outer)
return; return;
var innerItems = this.getEapInnerItems_(eap.Outer); const innerItems = this.getEapInnerItems_(eap.Outer);
if (innerItems.length > 0) { if (innerItems.length > 0) {
if (!eap.Inner || innerItems.indexOf(eap.Inner) < 0) if (!eap.Inner || innerItems.indexOf(eap.Inner) < 0)
this.set('eapProperties_.Inner', innerItems[0]); this.set('eapProperties_.Inner', innerItems[0]);
...@@ -874,9 +874,9 @@ Polymer({ ...@@ -874,9 +874,9 @@ Polymer({
// EAP is used for all configurable types except VPN. // EAP is used for all configurable types except VPN.
if (this.type == CrOnc.Type.VPN) if (this.type == CrOnc.Type.VPN)
return; return;
var eap = this.eapProperties_; const eap = this.eapProperties_;
var pem = eap && eap.ServerCAPEMs ? eap.ServerCAPEMs[0] : ''; const pem = eap && eap.ServerCAPEMs ? eap.ServerCAPEMs[0] : '';
var certId = const certId =
eap && eap.ClientCertType == 'PKCS11Id' ? eap.ClientCertPKCS11Id : ''; eap && eap.ClientCertType == 'PKCS11Id' ? eap.ClientCertPKCS11Id : '';
this.setSelectedCerts_(pem, certId); this.setSelectedCerts_(pem, certId);
}, },
...@@ -888,7 +888,7 @@ Polymer({ ...@@ -888,7 +888,7 @@ Polymer({
this.updateCertError_(); this.updateCertError_();
return; return;
} }
var outer = this.eapProperties_.Outer; const outer = this.eapProperties_.Outer;
switch (this.type) { switch (this.type) {
case CrOnc.Type.WI_MAX: case CrOnc.Type.WI_MAX:
this.showEap_ = { this.showEap_ = {
...@@ -921,7 +921,7 @@ Polymer({ ...@@ -921,7 +921,7 @@ Polymer({
* @private * @private
*/ */
getEap_: function(properties, opt_create) { getEap_: function(properties, opt_create) {
var eap; let eap;
switch (properties.Type) { switch (properties.Type) {
case CrOnc.Type.WI_FI: case CrOnc.Type.WI_FI:
eap = properties.WiFi && properties.WiFi.EAP; eap = properties.WiFi && properties.WiFi.EAP;
...@@ -965,7 +965,7 @@ Polymer({ ...@@ -965,7 +965,7 @@ Polymer({
* @private * @private
*/ */
getManagedEap_: function(managedProperties) { getManagedEap_: function(managedProperties) {
var managedEap; let managedEap;
switch (managedProperties.Type) { switch (managedProperties.Type) {
case CrOnc.Type.WI_FI: case CrOnc.Type.WI_FI:
managedEap = managedProperties.WiFi && managedProperties.WiFi.EAP; managedEap = managedProperties.WiFi && managedProperties.WiFi.EAP;
...@@ -986,7 +986,7 @@ Polymer({ ...@@ -986,7 +986,7 @@ Polymer({
* @private * @private
*/ */
getVpnTypeFromProperties_: function(properties) { getVpnTypeFromProperties_: function(properties) {
var vpn = properties.VPN; const vpn = properties.VPN;
assert(vpn); assert(vpn);
if (vpn.Type == CrOnc.VPNType.L2TP_IPSEC) { if (vpn.Type == CrOnc.VPNType.L2TP_IPSEC) {
return vpn.IPsec.AuthenticationType == return vpn.IPsec.AuthenticationType ==
...@@ -1002,7 +1002,7 @@ Polymer({ ...@@ -1002,7 +1002,7 @@ Polymer({
if (this.configProperties_ === undefined) if (this.configProperties_ === undefined)
return; return;
var vpn = this.configProperties_.VPN; const vpn = this.configProperties_.VPN;
if (!vpn) { if (!vpn) {
this.showVpn_ = null; this.showVpn_ = null;
this.updateCertError_(); this.updateCertError_();
...@@ -1039,8 +1039,8 @@ Polymer({ ...@@ -1039,8 +1039,8 @@ Polymer({
updateVpnIPsecCerts_: function() { updateVpnIPsecCerts_: function() {
if (this.vpnType_ != VPNConfigType.L2TP_IPSEC_CERT) if (this.vpnType_ != VPNConfigType.L2TP_IPSEC_CERT)
return; return;
var pem, certId; let pem, certId;
var ipsec = /** @type {chrome.networkingPrivate.IPSecProperties} */ ( const ipsec = /** @type {chrome.networkingPrivate.IPSecProperties} */ (
this.get('VPN.IPsec', this.configProperties_)); this.get('VPN.IPsec', this.configProperties_));
if (ipsec) { if (ipsec) {
pem = ipsec.ServerCAPEMs && ipsec.ServerCAPEMs[0]; pem = ipsec.ServerCAPEMs && ipsec.ServerCAPEMs[0];
...@@ -1054,8 +1054,8 @@ Polymer({ ...@@ -1054,8 +1054,8 @@ Polymer({
updateOpenVPNCerts_: function() { updateOpenVPNCerts_: function() {
if (this.vpnType_ != VPNConfigType.OPEN_VPN) if (this.vpnType_ != VPNConfigType.OPEN_VPN)
return; return;
var pem, certId; let pem, certId;
var openvpn = /** @type {chrome.networkingPrivate.OpenVPNProperties} */ ( const openvpn = /** @type {chrome.networkingPrivate.OpenVPNProperties} */ (
this.get('VPN.OpenVPN', this.configProperties_)); this.get('VPN.OpenVPN', this.configProperties_));
if (openvpn) { if (openvpn) {
pem = openvpn.ServerCAPEMs && openvpn.ServerCAPEMs[0]; pem = openvpn.ServerCAPEMs && openvpn.ServerCAPEMs[0];
...@@ -1070,14 +1070,14 @@ Polymer({ ...@@ -1070,14 +1070,14 @@ Polymer({
updateCertError_: function() { updateCertError_: function() {
// If |this.error| was set to something other than a cert error, do not // If |this.error| was set to something other than a cert error, do not
// change it. // change it.
/** @const */ var noCertsError = 'networkErrorNoUserCertificate'; /** @const */ const noCertsError = 'networkErrorNoUserCertificate';
/** @const */ var noValidCertsError = 'networkErrorNotHardwareBacked'; /** @const */ const noValidCertsError = 'networkErrorNotHardwareBacked';
if (this.error && this.error != noCertsError && if (this.error && this.error != noCertsError &&
this.error != noValidCertsError) { this.error != noValidCertsError) {
return; return;
} }
var requireCerts = (this.showEap_ && this.showEap_.UserCert) || const requireCerts = (this.showEap_ && this.showEap_.UserCert) ||
(this.showVpn_ && this.showVpn_.UserCert); (this.showVpn_ && this.showVpn_.UserCert);
if (!requireCerts) { if (!requireCerts) {
this.setError_(''); this.setError_('');
...@@ -1087,7 +1087,7 @@ Polymer({ ...@@ -1087,7 +1087,7 @@ Polymer({
this.setError_(noCertsError); this.setError_(noCertsError);
return; return;
} }
var validUserCert = this.userCerts_.find(function(cert) { const validUserCert = this.userCerts_.find(function(cert) {
return !!cert.hash; return !!cert.hash;
}); });
if (!validUserCert) { if (!validUserCert) {
...@@ -1107,7 +1107,7 @@ Polymer({ ...@@ -1107,7 +1107,7 @@ Polymer({
*/ */
setSelectedCerts_: function(pem, certId) { setSelectedCerts_: function(pem, certId) {
if (pem) { if (pem) {
var serverCa = this.serverCaCerts_.find(function(cert) { const serverCa = this.serverCaCerts_.find(function(cert) {
return cert.pem == pem; return cert.pem == pem;
}); });
if (serverCa) if (serverCa)
...@@ -1115,7 +1115,7 @@ Polymer({ ...@@ -1115,7 +1115,7 @@ Polymer({
} }
if (certId) { if (certId) {
var userCert = this.userCerts_.find(function(cert) { const userCert = this.userCerts_.find(function(cert) {
return cert.PKCS11Id == certId; return cert.PKCS11Id == certId;
}); });
if (userCert) if (userCert)
...@@ -1150,7 +1150,7 @@ Polymer({ ...@@ -1150,7 +1150,7 @@ Polymer({
this.selectedServerCaHash_ = undefined; this.selectedServerCaHash_ = undefined;
if (!this.selectedServerCaHash_ || if (!this.selectedServerCaHash_ ||
this.selectedServerCaHash_ == DEFAULT_HASH) { this.selectedServerCaHash_ == DEFAULT_HASH) {
var eap = this.eapProperties_; const eap = this.eapProperties_;
if (eap && eap.UseSystemCAs === false) if (eap && eap.UseSystemCAs === false)
this.selectedServerCaHash_ = DO_NOT_CHECK_HASH; this.selectedServerCaHash_ = DO_NOT_CHECK_HASH;
} }
...@@ -1178,7 +1178,7 @@ Polymer({ ...@@ -1178,7 +1178,7 @@ Polymer({
if (!this.get('WiFi.SSID', this.configProperties_)) if (!this.get('WiFi.SSID', this.configProperties_))
return false; return false;
if (this.configRequiresPassphrase_()) { if (this.configRequiresPassphrase_()) {
var passphrase = this.get('WiFi.Passphrase', this.configProperties_); const passphrase = this.get('WiFi.Passphrase', this.configProperties_);
if (!passphrase || passphrase.length < this.MIN_PASSPHRASE_LENGTH) if (!passphrase || passphrase.length < this.MIN_PASSPHRASE_LENGTH)
return false; return false;
} }
...@@ -1272,7 +1272,7 @@ Polymer({ ...@@ -1272,7 +1272,7 @@ Polymer({
return false; return false;
if (this.security_ == CrOnc.Security.WPA_EAP) { if (this.security_ == CrOnc.Security.WPA_EAP) {
var eap = this.getEap_(this.configProperties_); const eap = this.getEap_(this.configProperties_);
if (eap && eap.Outer == CrOnc.EAPType.EAP_TLS) if (eap && eap.Outer == CrOnc.EAPType.EAP_TLS)
return false; return false;
} }
...@@ -1299,7 +1299,7 @@ Polymer({ ...@@ -1299,7 +1299,7 @@ Polymer({
* @private * @private
*/ */
eapIsConfigured_: function() { eapIsConfigured_: function() {
var eap = this.getEap_(this.configProperties_); const eap = this.getEap_(this.configProperties_);
if (!eap) if (!eap)
return false; return false;
if (eap.Outer != CrOnc.EAPType.EAP_TLS) if (eap.Outer != CrOnc.EAPType.EAP_TLS)
...@@ -1312,7 +1312,7 @@ Polymer({ ...@@ -1312,7 +1312,7 @@ Polymer({
* @private * @private
*/ */
vpnIsConfigured_: function() { vpnIsConfigured_: function() {
var vpn = this.configProperties_.VPN; const vpn = this.configProperties_.VPN;
if (!this.configProperties_.Name || !vpn || !vpn.Host) if (!this.configProperties_.Name || !vpn || !vpn.Host)
return false; return false;
...@@ -1334,13 +1334,13 @@ Polymer({ ...@@ -1334,13 +1334,13 @@ Polymer({
/** @private */ /** @private */
getPropertiesToSet_: function() { getPropertiesToSet_: function() {
var propertiesToSet = Object.assign({}, this.configProperties_); const propertiesToSet = Object.assign({}, this.configProperties_);
// Do not set AutoConnect by default, the connection manager will set // Do not set AutoConnect by default, the connection manager will set
// it to true on a successful connection. // it to true on a successful connection.
CrOnc.setTypeProperty(propertiesToSet, 'AutoConnect', undefined); CrOnc.setTypeProperty(propertiesToSet, 'AutoConnect', undefined);
if (this.guid) if (this.guid)
propertiesToSet.GUID = this.guid; propertiesToSet.GUID = this.guid;
var eap = this.getEap_(propertiesToSet); const eap = this.getEap_(propertiesToSet);
if (eap) if (eap)
this.setEapProperties_(eap); this.setEapProperties_(eap);
if (this.configProperties_.Type == CrOnc.Type.VPN) { if (this.configProperties_.Type == CrOnc.Type.VPN) {
...@@ -1357,10 +1357,10 @@ Polymer({ ...@@ -1357,10 +1357,10 @@ Polymer({
* @private * @private
*/ */
getServerCaPems_: function() { getServerCaPems_: function() {
var caHash = this.selectedServerCaHash_ || ''; const caHash = this.selectedServerCaHash_ || '';
if (!caHash || caHash == DO_NOT_CHECK_HASH || caHash == DEFAULT_HASH) if (!caHash || caHash == DO_NOT_CHECK_HASH || caHash == DEFAULT_HASH)
return []; return [];
var serverCa = this.findCert_(this.serverCaCerts_, caHash); const serverCa = this.findCert_(this.serverCaCerts_, caHash);
return serverCa && serverCa.pem ? [serverCa.pem] : []; return serverCa && serverCa.pem ? [serverCa.pem] : [];
}, },
...@@ -1369,12 +1369,12 @@ Polymer({ ...@@ -1369,12 +1369,12 @@ Polymer({
* @private * @private
*/ */
getUserCertPkcs11Id_: function() { getUserCertPkcs11Id_: function() {
var userCertHash = this.selectedUserCertHash_ || ''; const userCertHash = this.selectedUserCertHash_ || '';
if (!this.selectedUserCertHashIsValid_() || if (!this.selectedUserCertHashIsValid_() ||
userCertHash == NO_USER_CERT_HASH) { userCertHash == NO_USER_CERT_HASH) {
return ''; return '';
} }
var userCert = this.findCert_(this.userCerts_, userCertHash); const userCert = this.findCert_(this.userCerts_, userCertHash);
return (userCert && userCert.PKCS11Id) || ''; return (userCert && userCert.PKCS11Id) || '';
}, },
...@@ -1387,7 +1387,7 @@ Polymer({ ...@@ -1387,7 +1387,7 @@ Polymer({
eap.ServerCAPEMs = this.getServerCaPems_(); eap.ServerCAPEMs = this.getServerCaPems_();
var pkcs11Id = this.getUserCertPkcs11Id_(); const pkcs11Id = this.getUserCertPkcs11Id_();
eap.ClientCertType = pkcs11Id ? 'PKCS11Id' : 'None'; eap.ClientCertType = pkcs11Id ? 'PKCS11Id' : 'None';
eap.ClientCertPKCS11Id = pkcs11Id || ''; eap.ClientCertPKCS11Id = pkcs11Id || '';
}, },
...@@ -1397,11 +1397,11 @@ Polymer({ ...@@ -1397,11 +1397,11 @@ Polymer({
* @private * @private
*/ */
setOpenVPNProperties_: function(propertiesToSet) { setOpenVPNProperties_: function(propertiesToSet) {
var openvpn = propertiesToSet.VPN.OpenVPN || {}; const openvpn = propertiesToSet.VPN.OpenVPN || {};
openvpn.ServerCAPEMs = this.getServerCaPems_(); openvpn.ServerCAPEMs = this.getServerCaPems_();
var pkcs11Id = this.getUserCertPkcs11Id_(); const pkcs11Id = this.getUserCertPkcs11Id_();
openvpn.ClientCertType = pkcs11Id ? 'PKCS11Id' : 'None'; openvpn.ClientCertType = pkcs11Id ? 'PKCS11Id' : 'None';
openvpn.ClientCertPKCS11Id = pkcs11Id || ''; openvpn.ClientCertPKCS11Id = pkcs11Id || '';
...@@ -1425,7 +1425,7 @@ Polymer({ ...@@ -1425,7 +1425,7 @@ Polymer({
* @private * @private
*/ */
setVpnIPsecProperties_: function(propertiesToSet) { setVpnIPsecProperties_: function(propertiesToSet) {
var vpn = propertiesToSet.VPN; const vpn = propertiesToSet.VPN;
assert(vpn.IPsec); assert(vpn.IPsec);
if (vpn.IPsec.AuthenticationType == CrOnc.IPsecAuthenticationType.CERT) { if (vpn.IPsec.AuthenticationType == CrOnc.IPsecAuthenticationType.CERT) {
vpn.IPsec.ClientCertType = 'PKCS11Id'; vpn.IPsec.ClientCertType = 'PKCS11Id';
...@@ -1458,7 +1458,7 @@ Polymer({ ...@@ -1458,7 +1458,7 @@ Polymer({
this.propertiesSent_ = false; this.propertiesSent_ = false;
return; return;
} }
var connectState = this.managedProperties.ConnectionState; const connectState = this.managedProperties.ConnectionState;
if (connect && if (connect &&
(!connectState || (!connectState ||
connectState == CrOnc.ConnectionState.NOT_CONNECTED)) { connectState == CrOnc.ConnectionState.NOT_CONNECTED)) {
...@@ -1492,7 +1492,7 @@ Polymer({ ...@@ -1492,7 +1492,7 @@ Polymer({
*/ */
startConnect_: function(guid) { startConnect_: function(guid) {
this.networkingPrivate.startConnect(guid, () => { this.networkingPrivate.startConnect(guid, () => {
var error = this.getRuntimeError_(); const error = this.getRuntimeError_();
if (!error || error == 'connected' || error == 'connect-canceled' || if (!error || error == 'connected' || error == 'connect-canceled' ||
error == 'connecting') { error == 'connecting') {
// Connect is in progress, completed or canceled, close the dialog. // Connect is in progress, completed or canceled, close the dialog.
...@@ -1544,7 +1544,7 @@ Polymer({ ...@@ -1544,7 +1544,7 @@ Polymer({
* @private * @private
*/ */
getManagedSecurity_: function(managedProperties) { getManagedSecurity_: function(managedProperties) {
var managedSecurity = undefined; let managedSecurity = undefined;
switch (managedProperties.Type) { switch (managedProperties.Type) {
case CrOnc.Type.WI_FI: case CrOnc.Type.WI_FI:
managedSecurity = managedSecurity =
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
*/ */
/** @polymerBehavior */ /** @polymerBehavior */
var NetworkConfigElementBehavior = { const NetworkConfigElementBehavior = {
properties: { properties: {
disabled: { disabled: {
type: Boolean, type: Boolean,
......
...@@ -52,7 +52,7 @@ Polymer({ ...@@ -52,7 +52,7 @@ Polymer({
updateSelected_: function() { updateSelected_: function() {
// Wait for the dom-repeat to populate the <option> entries. // Wait for the dom-repeat to populate the <option> entries.
this.async(function() { this.async(function() {
var select = this.$$('select'); const select = this.$$('select');
if (select.value != this.value) if (select.value != this.value)
select.value = this.value; select.value = this.value;
}); });
...@@ -69,8 +69,8 @@ Polymer({ ...@@ -69,8 +69,8 @@ Polymer({
return this.getCertificateName_( return this.getCertificateName_(
/** @type {chrome.networkingPrivate.Certificate}*/ (item)); /** @type {chrome.networkingPrivate.Certificate}*/ (item));
} }
var key = /** @type {string} */ (item); const key = /** @type {string} */ (item);
var oncKey = 'Onc' + prefix.replace(/\./g, '-') + '_' + key; const oncKey = 'Onc' + prefix.replace(/\./g, '-') + '_' + key;
if (this.i18nExists(oncKey)) if (this.i18nExists(oncKey))
return this.i18n(oncKey); return this.i18n(oncKey);
assertNotReached('ONC Key not found: ' + oncKey); assertNotReached('ONC Key not found: ' + oncKey);
...@@ -95,7 +95,7 @@ Polymer({ ...@@ -95,7 +95,7 @@ Polymer({
*/ */
getItemEnabled_: function(item) { getItemEnabled_: function(item) {
if (this.certList) { if (this.certList) {
var cert = /** @type {chrome.networkingPrivate.Certificate}*/ (item); const cert = /** @type {chrome.networkingPrivate.Certificate}*/ (item);
return !!cert.hash; return !!cert.hash;
} }
return true; return true;
......
...@@ -81,21 +81,21 @@ Polymer({ ...@@ -81,21 +81,21 @@ Polymer({
if (!this.networkProperties) if (!this.networkProperties)
return; return;
var properties = this.networkProperties; const properties = this.networkProperties;
if (newValue.GUID != (oldValue && oldValue.GUID)) if (newValue.GUID != (oldValue && oldValue.GUID))
this.savedStaticIp_ = undefined; this.savedStaticIp_ = undefined;
// Update the 'automatic' property. // Update the 'automatic' property.
if (properties.IPAddressConfigType) { if (properties.IPAddressConfigType) {
var ipConfigType = CrOnc.getActiveValue(properties.IPAddressConfigType); const ipConfigType = CrOnc.getActiveValue(properties.IPAddressConfigType);
this.automatic_ = (ipConfigType != CrOnc.IPConfigType.STATIC); this.automatic_ = (ipConfigType != CrOnc.IPConfigType.STATIC);
} }
if (properties.IPConfigs || properties.StaticIPConfig) { if (properties.IPConfigs || properties.StaticIPConfig) {
// Update the 'ipConfig' property. // Update the 'ipConfig' property.
var ipv4 = this.getIPConfigUIProperties_( const ipv4 = this.getIPConfigUIProperties_(
CrOnc.getIPConfigForType(properties, CrOnc.IPType.IPV4)); CrOnc.getIPConfigForType(properties, CrOnc.IPType.IPV4));
var ipv6 = this.getIPConfigUIProperties_( let ipv6 = this.getIPConfigUIProperties_(
CrOnc.getIPConfigForType(properties, CrOnc.IPType.IPV6)); CrOnc.getIPConfigForType(properties, CrOnc.IPType.IPV6));
if (properties.ConnectionState == CrOnc.ConnectionState.CONNECTED && if (properties.ConnectionState == CrOnc.ConnectionState.CONNECTED &&
ipv4 && ipv4.IPAddress) { ipv4 && ipv4.IPAddress) {
...@@ -111,7 +111,7 @@ Polymer({ ...@@ -111,7 +111,7 @@ Polymer({
/** @private */ /** @private */
onAutomaticChange_: function() { onAutomaticChange_: function() {
if (!this.automatic_) { if (!this.automatic_) {
var defaultIpv4 = { const defaultIpv4 = {
Gateway: '192.168.1.1', Gateway: '192.168.1.1',
IPAddress: '192.168.1.1', IPAddress: '192.168.1.1',
RoutingPrefix: '255.255.255.0', RoutingPrefix: '255.255.255.0',
...@@ -147,9 +147,9 @@ Polymer({ ...@@ -147,9 +147,9 @@ Polymer({
getIPConfigUIProperties_: function(ipconfig) { getIPConfigUIProperties_: function(ipconfig) {
if (!ipconfig) if (!ipconfig)
return undefined; return undefined;
var result = {}; const result = {};
for (var key in ipconfig) { for (const key in ipconfig) {
var value = ipconfig[key]; const value = ipconfig[key];
if (key == 'RoutingPrefix') if (key == 'RoutingPrefix')
result.RoutingPrefix = CrOnc.getRoutingPrefixAsNetmask(value); result.RoutingPrefix = CrOnc.getRoutingPrefixAsNetmask(value);
else else
...@@ -165,9 +165,9 @@ Polymer({ ...@@ -165,9 +165,9 @@ Polymer({
* @private * @private
*/ */
getIPConfigProperties_: function(ipconfig) { getIPConfigProperties_: function(ipconfig) {
var result = {}; const result = {};
for (var key in ipconfig) { for (const key in ipconfig) {
var value = ipconfig[key]; const value = ipconfig[key];
if (key == 'RoutingPrefix') if (key == 'RoutingPrefix')
result.RoutingPrefix = CrOnc.getRoutingPrefixAsLength(value); result.RoutingPrefix = CrOnc.getRoutingPrefixAsLength(value);
else else
...@@ -183,7 +183,7 @@ Polymer({ ...@@ -183,7 +183,7 @@ Polymer({
hasIpConfigFields_: function() { hasIpConfigFields_: function() {
if (!this.ipConfigFields_) if (!this.ipConfigFields_)
return false; return false;
for (var i = 0; i < this.ipConfigFields_.length; ++i) { for (let i = 0; i < this.ipConfigFields_.length; ++i) {
if (this.get(this.ipConfigFields_[i], this.ipConfig_) != undefined) if (this.get(this.ipConfigFields_[i], this.ipConfig_) != undefined)
return true; return true;
} }
...@@ -213,8 +213,8 @@ Polymer({ ...@@ -213,8 +213,8 @@ Polymer({
onIPChange_: function(event) { onIPChange_: function(event) {
if (!this.ipConfig_) if (!this.ipConfig_)
return; return;
var field = event.detail.field; const field = event.detail.field;
var value = event.detail.value; const value = event.detail.value;
// Note: |field| includes the 'ipv4.' prefix. // Note: |field| includes the 'ipv4.' prefix.
this.set('ipConfig_.' + field, value); this.set('ipConfig_.' + field, value);
this.sendStaticIpConfig_(); this.sendStaticIpConfig_();
......
...@@ -81,16 +81,16 @@ Polymer({ ...@@ -81,16 +81,16 @@ Polymer({
this.savedNameservers_ = []; this.savedNameservers_ = [];
// Update the 'nameservers' property. // Update the 'nameservers' property.
var nameservers = []; let nameservers = [];
var ipv4 = const ipv4 =
CrOnc.getIPConfigForType(this.networkProperties, CrOnc.IPType.IPV4); CrOnc.getIPConfigForType(this.networkProperties, CrOnc.IPType.IPV4);
if (ipv4 && ipv4.NameServers) if (ipv4 && ipv4.NameServers)
nameservers = ipv4.NameServers; nameservers = ipv4.NameServers;
// Update the 'nameserversType' property. // Update the 'nameserversType' property.
var configType = const configType =
CrOnc.getActiveValue(this.networkProperties.NameServersConfigType); CrOnc.getActiveValue(this.networkProperties.NameServersConfigType);
var type; let type;
if (configType == CrOnc.IPConfigType.STATIC) { if (configType == CrOnc.IPConfigType.STATIC) {
if (nameservers.join(',') == this.GOOGLE_NAMESERVERS.join(',')) { if (nameservers.join(',') == this.GOOGLE_NAMESERVERS.join(',')) {
type = 'google'; type = 'google';
...@@ -114,7 +114,7 @@ Polymer({ ...@@ -114,7 +114,7 @@ Polymer({
setNameservers_: function(nameserversType, nameservers, sendNameservers) { setNameservers_: function(nameserversType, nameservers, sendNameservers) {
if (nameserversType == 'custom') { if (nameserversType == 'custom') {
// Add empty entries for unset custom nameservers. // Add empty entries for unset custom nameservers.
for (var i = nameservers.length; i < this.MAX_NAMESERVERS; ++i) for (let i = nameservers.length; i < this.MAX_NAMESERVERS; ++i)
nameservers[i] = ''; nameservers[i] = '';
this.savedNameservers_ = nameservers.slice(); this.savedNameservers_ = nameservers.slice();
} }
...@@ -165,7 +165,7 @@ Polymer({ ...@@ -165,7 +165,7 @@ Polymer({
* @private * @private
*/ */
onTypeChange_: function() { onTypeChange_: function() {
var type = this.$$('#nameserverType').selected; const type = this.$$('#nameserverType').selected;
this.nameserversType_ = type; this.nameserversType_ = type;
if (type == 'custom') { if (type == 'custom') {
// Restore the saved nameservers. // Restore the saved nameservers.
...@@ -193,12 +193,12 @@ Polymer({ ...@@ -193,12 +193,12 @@ Polymer({
* @private * @private
*/ */
sendNameServers_: function() { sendNameServers_: function() {
var type = this.nameserversType_; const type = this.nameserversType_;
if (type == 'custom') { if (type == 'custom') {
var nameservers = new Array(this.MAX_NAMESERVERS); const nameservers = new Array(this.MAX_NAMESERVERS);
for (var i = 0; i < this.MAX_NAMESERVERS; ++i) { for (let i = 0; i < this.MAX_NAMESERVERS; ++i) {
var nameserverInput = this.$$('#nameserver' + i); const nameserverInput = this.$$('#nameserver' + i);
nameservers[i] = nameserverInput ? nameserverInput.value : ''; nameservers[i] = nameserverInput ? nameserverInput.value : '';
} }
this.nameservers_ = nameservers; this.nameservers_ = nameservers;
......
...@@ -75,14 +75,14 @@ Polymer({ ...@@ -75,14 +75,14 @@ Polymer({
onValueChange_: function(event) { onValueChange_: function(event) {
if (!this.propertyDict) if (!this.propertyDict)
return; return;
var key = event.target.id; const key = event.target.id;
var curValue = this.get(key, this.propertyDict); let curValue = this.get(key, this.propertyDict);
if (typeof curValue == 'object' && !Array.isArray(curValue)) { if (typeof curValue == 'object' && !Array.isArray(curValue)) {
// Extract the property from an ONC managed dictionary. // Extract the property from an ONC managed dictionary.
curValue = CrOnc.getActiveValue( curValue = CrOnc.getActiveValue(
/** @type {!CrOnc.ManagedProperty} */ (curValue)); /** @type {!CrOnc.ManagedProperty} */ (curValue));
} }
var newValue = this.getValueFromEditField_(key, event.target.value); const newValue = this.getValueFromEditField_(key, event.target.value);
if (newValue == curValue) if (newValue == curValue)
return; return;
this.fire('property-change', {field: key, value: newValue}); this.fire('property-change', {field: key, value: newValue});
...@@ -95,15 +95,15 @@ Polymer({ ...@@ -95,15 +95,15 @@ Polymer({
* @private * @private
*/ */
getPropertyLabel_: function(key, prefix) { getPropertyLabel_: function(key, prefix) {
var oncKey = 'Onc' + prefix + key; let oncKey = 'Onc' + prefix + key;
oncKey = oncKey.replace(/\./g, '-'); oncKey = oncKey.replace(/\./g, '-');
if (this.i18nExists(oncKey)) if (this.i18nExists(oncKey))
return this.i18n(oncKey); return this.i18n(oncKey);
// We do not provide translations for every possible network property key. // We do not provide translations for every possible network property key.
// For keys specific to a type, strip the type prefix. // For keys specific to a type, strip the type prefix.
var result = prefix + key; let result = prefix + key;
for (var entry in chrome.networkingPrivate.NetworkType) { for (const entry in chrome.networkingPrivate.NetworkType) {
var type = chrome.networkingPrivate.NetworkType[entry]; const type = chrome.networkingPrivate.NetworkType[entry];
if (result.startsWith(type + '.')) { if (result.startsWith(type + '.')) {
result = result.substr(type.length + 1); result = result.substr(type.length + 1);
break; break;
...@@ -123,7 +123,7 @@ Polymer({ ...@@ -123,7 +123,7 @@ Polymer({
return key => { return key => {
if (editFieldTypes.hasOwnProperty(key)) if (editFieldTypes.hasOwnProperty(key))
return true; return true;
var value = this.getPropertyValue_(key, prefix, propertyDict); const value = this.getPropertyValue_(key, prefix, propertyDict);
return value !== undefined && value !== ''; return value !== undefined && value !== '';
}; };
}, },
...@@ -135,12 +135,12 @@ Polymer({ ...@@ -135,12 +135,12 @@ Polymer({
* @private * @private
*/ */
isPropertyEditable_: function(key, propertyDict) { isPropertyEditable_: function(key, propertyDict) {
var property = /** @type {!CrOnc.ManagedProperty|undefined} */ ( const property = /** @type {!CrOnc.ManagedProperty|undefined} */ (
this.get(key, propertyDict)); this.get(key, propertyDict));
if (property === undefined) { if (property === undefined) {
// Unspecified properties in policy configurations are not user // Unspecified properties in policy configurations are not user
// modifiable. https://crbug.com/819837. // modifiable. https://crbug.com/819837.
var source = propertyDict.Source; const source = propertyDict.Source;
return source != 'UserPolicy' && source != 'DevicePolicy'; return source != 'UserPolicy' && source != 'DevicePolicy';
} }
return !this.isNetworkPolicyEnforced(property); return !this.isNetworkPolicyEnforced(property);
...@@ -153,7 +153,7 @@ Polymer({ ...@@ -153,7 +153,7 @@ Polymer({
* @private * @private
*/ */
isEditType_: function(key, editFieldTypes) { isEditType_: function(key, editFieldTypes) {
var editType = editFieldTypes[key]; const editType = editFieldTypes[key];
return editType == 'String' || editType == 'StringArray' || return editType == 'String' || editType == 'StringArray' ||
editType == 'Password'; editType == 'Password';
}, },
...@@ -198,7 +198,7 @@ Polymer({ ...@@ -198,7 +198,7 @@ Polymer({
* @private * @private
*/ */
getProperty_: function(key, propertyDict) { getProperty_: function(key, propertyDict) {
var property = this.get(key, propertyDict); const property = this.get(key, propertyDict);
if (property === undefined && propertyDict.Source) { if (property === undefined && propertyDict.Source) {
// Provide an empty property object with the network policy source. // Provide an empty property object with the network policy source.
// See https://crbug.com/819837 for more info. // See https://crbug.com/819837 for more info.
...@@ -215,7 +215,7 @@ Polymer({ ...@@ -215,7 +215,7 @@ Polymer({
* @private * @private
*/ */
getPropertyValue_: function(key, prefix, propertyDict) { getPropertyValue_: function(key, prefix, propertyDict) {
var value = this.get(key, propertyDict); let value = this.get(key, propertyDict);
if (value === undefined) if (value === undefined)
return ''; return '';
if (typeof value == 'object' && !Array.isArray(value)) { if (typeof value == 'object' && !Array.isArray(value)) {
...@@ -226,15 +226,15 @@ Polymer({ ...@@ -226,15 +226,15 @@ Polymer({
if (Array.isArray(value)) if (Array.isArray(value))
return value.join(', '); return value.join(', ');
var customValue = this.getCustomPropertyValue_(key, value); const customValue = this.getCustomPropertyValue_(key, value);
if (customValue) if (customValue)
return customValue; return customValue;
if (typeof value == 'number' || typeof value == 'boolean') if (typeof value == 'number' || typeof value == 'boolean')
return value.toString(); return value.toString();
assert(typeof value == 'string'); assert(typeof value == 'string');
var valueStr = /** @type {string} */ (value); const valueStr = /** @type {string} */ (value);
var oncKey = 'Onc' + prefix + key; let oncKey = 'Onc' + prefix + key;
oncKey = oncKey.replace(/\./g, '-'); oncKey = oncKey.replace(/\./g, '-');
oncKey += '_' + valueStr; oncKey += '_' + valueStr;
if (this.i18nExists(oncKey)) if (this.i18nExists(oncKey))
...@@ -250,7 +250,7 @@ Polymer({ ...@@ -250,7 +250,7 @@ Polymer({
* @private * @private
*/ */
getValueFromEditField_(key, fieldValue) { getValueFromEditField_(key, fieldValue) {
var editType = this.editFieldTypes[key]; const editType = this.editFieldTypes[key];
if (editType == 'StringArray') if (editType == 'StringArray')
return fieldValue.toString().split(/, */); return fieldValue.toString().split(/, */);
return fieldValue; return fieldValue;
......
...@@ -150,12 +150,12 @@ Polymer({ ...@@ -150,12 +150,12 @@ Polymer({
return; return;
/** @type {!CrOnc.ProxySettings} */ /** @type {!CrOnc.ProxySettings} */
var proxy = this.createDefaultProxySettings_(); const proxy = this.createDefaultProxySettings_();
// For shared networks with unmanaged proxy settings, ignore any saved // For shared networks with unmanaged proxy settings, ignore any saved
// proxy settings (use the default values). // proxy settings (use the default values).
if (this.isShared_()) { if (this.isShared_()) {
var property = this.getProxySettingsTypeProperty_(); const property = this.getProxySettingsTypeProperty_();
if (!this.isControlled(property) && !this.useSharedProxies) { if (!this.isControlled(property) && !this.useSharedProxies) {
this.setProxyAsync_(proxy); this.setProxyAsync_(proxy);
return; // Proxy settings will be ignored. return; // Proxy settings will be ignored.
...@@ -163,7 +163,7 @@ Polymer({ ...@@ -163,7 +163,7 @@ Polymer({
} }
/** @type {!chrome.networkingPrivate.ManagedProxySettings|undefined} */ /** @type {!chrome.networkingPrivate.ManagedProxySettings|undefined} */
var proxySettings = this.networkProperties.ProxySettings; const proxySettings = this.networkProperties.ProxySettings;
if (proxySettings) { if (proxySettings) {
proxy.Type = /** @type {!CrOnc.ProxySettingsType} */ ( proxy.Type = /** @type {!CrOnc.ProxySettingsType} */ (
CrOnc.getActiveValue(proxySettings.Type)); CrOnc.getActiveValue(proxySettings.Type));
...@@ -185,7 +185,7 @@ Polymer({ ...@@ -185,7 +185,7 @@ Polymer({
/** @type {!CrOnc.ProxyLocation|undefined} */ ( /** @type {!CrOnc.ProxyLocation|undefined} */ (
CrOnc.getActiveProperties(proxySettings.Manual.SOCKS)) || CrOnc.getActiveProperties(proxySettings.Manual.SOCKS)) ||
{Host: '', Port: 80}; {Host: '', Port: 80};
var jsonHttp = proxy.Manual.HTTPProxy; const jsonHttp = proxy.Manual.HTTPProxy;
this.useSameProxy_ = this.useSameProxy_ =
(CrOnc.proxyMatches(jsonHttp, proxy.Manual.SecureHTTPProxy) && (CrOnc.proxyMatches(jsonHttp, proxy.Manual.SecureHTTPProxy) &&
CrOnc.proxyMatches(jsonHttp, proxy.Manual.FTPProxy) && CrOnc.proxyMatches(jsonHttp, proxy.Manual.FTPProxy) &&
...@@ -206,7 +206,7 @@ Polymer({ ...@@ -206,7 +206,7 @@ Polymer({
proxy.Manual = proxy.Manual || this.savedManual_; proxy.Manual = proxy.Manual || this.savedManual_;
// Set the Web Proxy Auto Discovery URL. // Set the Web Proxy Auto Discovery URL.
var ipv4 = const ipv4 =
CrOnc.getIPConfigForType(this.networkProperties, CrOnc.IPType.IPV4); CrOnc.getIPConfigForType(this.networkProperties, CrOnc.IPType.IPV4);
this.WPAD_ = (ipv4 && ipv4.WebProxyAutoDiscoveryUrl) || this.WPAD_ = (ipv4 && ipv4.WebProxyAutoDiscoveryUrl) ||
this.i18n('networkProxyWpadNone'); this.i18n('networkProxyWpadNone');
...@@ -254,11 +254,11 @@ Polymer({ ...@@ -254,11 +254,11 @@ Polymer({
* @private * @private
*/ */
sendProxyChange_: function() { sendProxyChange_: function() {
var proxy = const proxy =
/** @type {!CrOnc.ProxySettings} */ (Object.assign({}, this.proxy_)); /** @type {!CrOnc.ProxySettings} */ (Object.assign({}, this.proxy_));
if (proxy.Type == CrOnc.ProxySettingsType.MANUAL) { if (proxy.Type == CrOnc.ProxySettingsType.MANUAL) {
var manual = proxy.Manual; const manual = proxy.Manual;
var defaultProxy = manual.HTTPProxy || {Host: '', Port: 80}; const defaultProxy = manual.HTTPProxy || {Host: '', Port: 80};
if (this.useSameProxy_) { if (this.useSameProxy_) {
proxy.Manual.SecureHTTPProxy = /** @type {!CrOnc.ProxyLocation} */ ( proxy.Manual.SecureHTTPProxy = /** @type {!CrOnc.ProxyLocation} */ (
Object.assign({}, defaultProxy)); Object.assign({}, defaultProxy));
...@@ -293,12 +293,12 @@ Polymer({ ...@@ -293,12 +293,12 @@ Polymer({
* @private * @private
*/ */
onTypeChange_: function(event) { onTypeChange_: function(event) {
var target = /** @type {!HTMLSelectElement} */ (event.target); const target = /** @type {!HTMLSelectElement} */ (event.target);
var type = /** @type {chrome.networkingPrivate.ProxySettingsType} */ ( const type = /** @type {chrome.networkingPrivate.ProxySettingsType} */ (
target.value); target.value);
this.set('proxy_.Type', type); this.set('proxy_.Type', type);
var proxyTypeChangeIsReady; let proxyTypeChangeIsReady;
var elementToFocus; let elementToFocus;
switch (type) { switch (type) {
case CrOnc.ProxySettingsType.DIRECT: case CrOnc.ProxySettingsType.DIRECT:
case CrOnc.ProxySettingsType.WPAD: case CrOnc.ProxySettingsType.WPAD:
...@@ -346,7 +346,7 @@ Polymer({ ...@@ -346,7 +346,7 @@ Polymer({
/** @private */ /** @private */
onAddProxyExclusionTap_: function() { onAddProxyExclusionTap_: function() {
var value = this.$.proxyExclusion.value; const value = this.$.proxyExclusion.value;
if (!value) if (!value)
return; return;
this.push('proxy_.ExcludeDomains', value); this.push('proxy_.ExcludeDomains', value);
...@@ -414,7 +414,7 @@ Polymer({ ...@@ -414,7 +414,7 @@ Polymer({
return false; return false;
if (!this.networkProperties.hasOwnProperty('ProxySettings')) if (!this.networkProperties.hasOwnProperty('ProxySettings'))
return true; // No proxy settings defined, so not enforced. return true; // No proxy settings defined, so not enforced.
var property = /** @type {!CrOnc.ManagedProperty|undefined} */ ( const property = /** @type {!CrOnc.ManagedProperty|undefined} */ (
this.get('ProxySettings.' + propertyName, this.networkProperties)); this.get('ProxySettings.' + propertyName, this.networkProperties));
if (!property) if (!property)
return true; return true;
...@@ -447,8 +447,8 @@ Polymer({ ...@@ -447,8 +447,8 @@ Polymer({
isSaveManualProxyEnabled_: function() { isSaveManualProxyEnabled_: function() {
if (!this.proxyIsUserModified_) if (!this.proxyIsUserModified_)
return false; return false;
var manual = this.proxy_.Manual; const manual = this.proxy_.Manual;
var httpHost = this.get('HTTPProxy.Host', manual); const httpHost = this.get('HTTPProxy.Host', manual);
if (this.useSameProxy_) if (this.useSameProxy_)
return !!httpHost; return !!httpHost;
return !!httpHost || !!this.get('SecureHTTPProxy.Host', manual) || return !!httpHost || !!this.get('SecureHTTPProxy.Host', manual) ||
......
...@@ -38,7 +38,7 @@ Polymer({ ...@@ -38,7 +38,7 @@ Polymer({
* @private * @private
*/ */
onRemoveTap_: function(event) { onRemoveTap_: function(event) {
var index = event.model.index; const index = event.model.index;
this.splice('exclusions', index, 1); this.splice('exclusions', index, 1);
this.fire('proxy-change'); this.fire('proxy-change');
} }
......
...@@ -52,7 +52,7 @@ Polymer({ ...@@ -52,7 +52,7 @@ Polymer({
* @private * @private
*/ */
onValueChange_: function() { onValueChange_: function() {
var port = parseInt(this.value.Port, 10); let port = parseInt(this.value.Port, 10);
if (isNaN(port)) if (isNaN(port))
port = 80; port = 80;
this.value.Port = port; this.value.Port = port;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
*/ */
/** @enum {string} */ /** @enum {string} */
var ErrorType = { const ErrorType = {
NONE: 'none', NONE: 'none',
INCORRECT_PIN: 'incorrect-pin', INCORRECT_PIN: 'incorrect-pin',
INCORRECT_PUK: 'incorrect-puk', INCORRECT_PUK: 'incorrect-puk',
...@@ -18,9 +18,9 @@ var ErrorType = { ...@@ -18,9 +18,9 @@ var ErrorType = {
(function() { (function() {
var PIN_MIN_LENGTH = 4; const PIN_MIN_LENGTH = 4;
var PUK_MIN_LENGTH = 8; const PUK_MIN_LENGTH = 8;
var TOGGLE_DEBOUNCE_MS = 500; const TOGGLE_DEBOUNCE_MS = 500;
Polymer({ Polymer({
is: 'network-siminfo', is: 'network-siminfo',
...@@ -161,10 +161,10 @@ Polymer({ ...@@ -161,10 +161,10 @@ Polymer({
networkPropertiesChanged_: function() { networkPropertiesChanged_: function() {
if (!this.networkProperties || !this.networkProperties.Cellular) if (!this.networkProperties || !this.networkProperties.Cellular)
return; return;
var simLockStatus = this.networkProperties.Cellular.SIMLockStatus; const simLockStatus = this.networkProperties.Cellular.SIMLockStatus;
this.pukRequired_ = this.pukRequired_ =
!!simLockStatus && simLockStatus.LockType == CrOnc.LockType.PUK; !!simLockStatus && simLockStatus.LockType == CrOnc.LockType.PUK;
var lockEnabled = !!simLockStatus && simLockStatus.LockEnabled; const lockEnabled = !!simLockStatus && simLockStatus.LockEnabled;
if (lockEnabled != this.lockEnabled_) { if (lockEnabled != this.lockEnabled_) {
this.setLockEnabled_ = lockEnabled; this.setLockEnabled_ = lockEnabled;
this.updateLockEnabled_(); this.updateLockEnabled_();
...@@ -223,7 +223,7 @@ Polymer({ ...@@ -223,7 +223,7 @@ Polymer({
// If the PUK was activated while attempting to enter or change a pin, // If the PUK was activated while attempting to enter or change a pin,
// close the dialog and open the unlock PUK dialog. // close the dialog and open the unlock PUK dialog.
var showUnlockPuk = false; let showUnlockPuk = false;
if (this.$.enterPinDialog.open) { if (this.$.enterPinDialog.open) {
this.$.enterPinDialog.close(); this.$.enterPinDialog.close();
showUnlockPuk = true; showUnlockPuk = true;
...@@ -271,7 +271,7 @@ Polymer({ ...@@ -271,7 +271,7 @@ Polymer({
* @private * @private
*/ */
setCellularSimState_: function(simState) { setCellularSimState_: function(simState) {
var guid = (this.networkProperties && this.networkProperties.GUID) || ''; const guid = (this.networkProperties && this.networkProperties.GUID) || '';
this.setInProgress_(); this.setInProgress_();
this.networkingPrivate.setCellularSimState(guid, simState, () => { this.networkingPrivate.setCellularSimState(guid, simState, () => {
this.inProgress_ = false; this.inProgress_ = false;
...@@ -292,7 +292,7 @@ Polymer({ ...@@ -292,7 +292,7 @@ Polymer({
* @private * @private
*/ */
unlockCellularSim_: function(pin, puk) { unlockCellularSim_: function(pin, puk) {
var guid = (this.networkProperties && this.networkProperties.GUID) || ''; const guid = (this.networkProperties && this.networkProperties.GUID) || '';
this.setInProgress_(); this.setInProgress_();
this.networkingPrivate.unlockCellularSim(guid, pin, puk, () => { this.networkingPrivate.unlockCellularSim(guid, pin, puk, () => {
this.inProgress_ = false; this.inProgress_ = false;
...@@ -316,10 +316,10 @@ Polymer({ ...@@ -316,10 +316,10 @@ Polymer({
event.stopPropagation(); event.stopPropagation();
if (!this.enterPinEnabled_) if (!this.enterPinEnabled_)
return; return;
var pin = this.$.enterPin.value; const pin = this.$.enterPin.value;
if (!this.validatePin_(pin)) if (!this.validatePin_(pin))
return; return;
var simState = /** @type {!CrOnc.CellularSimState} */ ({ const simState = /** @type {!CrOnc.CellularSimState} */ ({
currentPin: pin, currentPin: pin,
requirePin: this.sendSimLockEnabled_, requirePin: this.sendSimLockEnabled_,
}); });
...@@ -352,10 +352,10 @@ Polymer({ ...@@ -352,10 +352,10 @@ Polymer({
*/ */
sendChangePin_: function(event) { sendChangePin_: function(event) {
event.stopPropagation(); event.stopPropagation();
var newPin = this.$.changePinNew1.value; const newPin = this.$.changePinNew1.value;
if (!this.validatePin_(newPin, this.$.changePinNew2.value)) if (!this.validatePin_(newPin, this.$.changePinNew2.value))
return; return;
var simState = /** @type {!CrOnc.CellularSimState} */ ({ const simState = /** @type {!CrOnc.CellularSimState} */ ({
requirePin: true, requirePin: true,
currentPin: this.$.changePinOld.value, currentPin: this.$.changePinOld.value,
newPin: newPin newPin: newPin
...@@ -384,7 +384,7 @@ Polymer({ ...@@ -384,7 +384,7 @@ Polymer({
*/ */
sendUnlockPin_: function(event) { sendUnlockPin_: function(event) {
event.stopPropagation(); event.stopPropagation();
var pin = this.$.unlockPin.value; const pin = this.$.unlockPin.value;
if (!this.validatePin_(pin)) if (!this.validatePin_(pin))
return; return;
this.unlockCellularSim_(pin, ''); this.unlockCellularSim_(pin, '');
...@@ -419,10 +419,10 @@ Polymer({ ...@@ -419,10 +419,10 @@ Polymer({
*/ */
sendUnlockPuk_: function(event) { sendUnlockPuk_: function(event) {
event.stopPropagation(); event.stopPropagation();
var puk = this.$.unlockPuk.value; const puk = this.$.unlockPuk.value;
if (!this.validatePuk_(puk)) if (!this.validatePuk_(puk))
return; return;
var pin = this.$.unlockPin1.value; const pin = this.$.unlockPin1.value;
if (!this.validatePin_(pin, this.$.unlockPin2.value)) if (!this.validatePin_(pin, this.$.unlockPin2.value))
return; return;
this.unlockCellularSim_(pin, puk); this.unlockCellularSim_(pin, puk);
...@@ -457,7 +457,7 @@ Polymer({ ...@@ -457,7 +457,7 @@ Polymer({
if (this.error_ == ErrorType.NONE) if (this.error_ == ErrorType.NONE)
return ''; return '';
// TODO(stevenjb): Translate // TODO(stevenjb): Translate
var msg; let msg;
if (this.error_ == ErrorType.INCORRECT_PIN) if (this.error_ == ErrorType.INCORRECT_PIN)
msg = 'Incorrect PIN.'; msg = 'Incorrect PIN.';
else if (this.error_ == ErrorType.INCORRECT_PUK) else if (this.error_ == ErrorType.INCORRECT_PUK)
...@@ -470,7 +470,7 @@ Polymer({ ...@@ -470,7 +470,7 @@ Polymer({
msg = 'Invalid PUK.'; msg = 'Invalid PUK.';
else else
return 'UNKNOWN ERROR'; return 'UNKNOWN ERROR';
var retriesLeft = this.simUnlockSent_ && const retriesLeft = this.simUnlockSent_ &&
this.get('Cellular.SIMLockStatus.RetriesLeft', this.networkProperties); this.get('Cellular.SIMLockStatus.RetriesLeft', this.networkProperties);
if (retriesLeft) { if (retriesLeft) {
msg += ' Retries left: ' + retriesLeft.toString(); msg += ' Retries left: ' + retriesLeft.toString();
......
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