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(
......
...@@ -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