Commit 365943aa authored by Ryan Hansberry's avatar Ryan Hansberry Committed by Commit Bot

[Networking] Fix Closure errors in misc networking files.

Most fixes are simply ensuring that values are not undefined or null.

The most significant change is correctly grabbing the 'scanning' state
of the cellular DeviceState by way of injecting it into network-list
and then network-list-item (instead of shoving it into the
NetworkStateProperties). The change ensures that internet-subpage also
injects its DeviceState, which happens to fix crbug.com/1049775.

Tested by building webui_closure_compile with this CL based on top of
crrev.com/c/2006413, and manually testing with networking Settings UI.

Fixed: 1047850, 1049775
Change-Id: I370ae812430f31b7b856748c58f9f213014ecb88
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2040212Reviewed-by: default avatarAzeem Arshad <azeemarshad@chromium.org>
Commit-Queue: Ryan Hansberry <hansberry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#739204}
parent a8165b48
......@@ -137,7 +137,8 @@
<network-list id="networkList" show-buttons
show-technology-badge="[[showTechnologyBadge_]]"
networks="[[networkStateList_]]"
on-selected="onNetworkSelected_">
on-selected="onNetworkSelected_"
device-state="[[deviceState]]">
</network-list>
</template>
......
......@@ -83,7 +83,8 @@ Polymer({
getItemLabel_(item) {
if (this.certList) {
return this.getCertificateName_(
/** @type {chromeos.networkConfig.mojom.NetworkCertificate}*/ (item));
/** @type {!chromeos.networkConfig.mojom.NetworkCertificate}*/ (
item));
}
let value;
if (this.key) {
......
......@@ -235,19 +235,19 @@ Polymer({
if (!ipconfig) {
return undefined;
}
const result = {};
for (const key in ipconfig) {
const value = ipconfig[key];
if (key === 'routingPrefix') {
const netmask = getRoutingPrefixAsNetmask(value);
if (netmask !== undefined) {
result.routingPrefix = netmask;
}
} else {
result[key] = value;
// Copy |ipconfig| into a new object, |newIpconfig|.
const newIpconfig = {};
Object.assign(newIpconfig, ipconfig);
if (ipconfig.routingPrefix !== undefined) {
const netmask = getRoutingPrefixAsNetmask(ipconfig.routingPrefix);
if (netmask !== undefined) {
newIpconfig.routingPrefix = netmask;
}
}
return result;
return newIpconfig;
},
/**
......
......@@ -41,7 +41,8 @@
<network-list-item item="[[item]]"
show-technology-badge="[[showTechnologyBadge]]"
show-buttons="[[showButtons]]" tabindex$="[[tabIndex]]"
activation-unavailable="[[activationUnavailable]]">
activation-unavailable="[[activationUnavailable]]"
device-state="[[deviceState]]">
</network-list-item>
</template>
</iron-list>
......
......@@ -57,6 +57,13 @@ Polymer({
/** Whether cellular activation is unavailable in the current context. */
activationUnavailable: Boolean,
/**
* DeviceState associated with the type of |networks| listed, or undefined
* if none was provided.
* @private {!OncMojo.DeviceStateProperties|undefined} deviceState
*/
deviceState: Object,
/**
* Contains |networks| + |customItems|.
* @private {!Array<!NetworkList.NetworkListItemType>}
......
......@@ -88,7 +88,14 @@ Polymer({
activationUnavailable: {
type: Boolean,
value: false,
}
},
/**
* DeviceState associated with the network item type, or undefined if none
* was provided.
* @private {!OncMojo.DeviceStateProperties|undefined} deviceState
*/
deviceState: Object,
},
/** @override */
......@@ -267,18 +274,20 @@ Polymer({
if (!this.networkState) {
return '';
}
const connectionState = this.networkState.connectionState;
if (this.networkState.type === mojom.NetworkType.kCellular) {
if (this.shouldShowNotAvailableText_()) {
return this.i18n('networkListItemNotAvailable');
}
if (this.networkState.typeState.cellular.scanning) {
if (this.deviceState && this.deviceState.scanning) {
return this.i18n('networkListItemScanning');
}
if (this.networkState.typeState.cellular.simLocked) {
return this.i18n('networkListItemSimCardLocked');
}
}
const connectionState = this.networkState.connectionState;
if (OncMojo.connectionStateIsConnected(connectionState)) {
// TODO(khorimoto): Consider differentiating between Portal, Connected,
// and Online.
......
......@@ -122,8 +122,11 @@ Polymer({
}
// Update the 'nameserversType' property.
const configType =
OncMojo.getActiveValue(this.managedProperties.nameServersConfigType);
let configType;
if (this.managedProperties.nameServersConfigType) {
configType =
OncMojo.getActiveValue(this.managedProperties.nameServersConfigType);
}
let type;
if (configType === 'Static') {
if (this.isGoogleNameservers_(nameservers)) {
......
......@@ -74,7 +74,7 @@ Polymer({
if (typeof curValue === 'object' && !Array.isArray(curValue)) {
// Extract the property from an ONC managed dictionary.
curValue = OncMojo.getActiveValue(
/** @type{OncMojo.ManagedProperty} */ (curValue));
/** @type{!OncMojo.ManagedProperty} */ (curValue));
}
const newValue = this.getValueFromEditField_(key, event.target.value);
if (newValue === curValue) {
......
......@@ -35,7 +35,8 @@
show-buttons="[[showButtons]]"
show-technology-badge="[[showTechnologyBadge]]"
no-bottom-scroll-border="[[noBottomScrollBorder]]"
activation-unavailable="[[activationUnavailable]]">
activation-unavailable="[[activationUnavailable]]"
device-state="[[cellularDeviceState_]]">
</network-list>
</template>
<script src="network_select.js"></script>
......
......@@ -68,7 +68,7 @@ Polymer({
isScanOngoing_: {type: Boolean, value: false},
/**
* Cached Cellular Device state or undefined if there is no Cellular device.
* The cellular DeviceState, or undefined if there is no Cellular device.
* @private {!OncMojo.DeviceStateProperties|undefined} deviceState
*/
cellularDeviceState_: Object,
......@@ -258,10 +258,6 @@ Polymer({
return; // No Cellular network
}
const cellular =
OncMojo.getDefaultNetworkState(mojom.NetworkType.kCellular);
cellular.typeState.cellular.scanning = this.cellularDeviceState_.scanning;
// Note: the default connectionState is kNotConnected.
// TODO(khorimoto): Maybe set an 'initializing' CellularState property if
// the device state is initializing, see TODO in network_list_item.js.
......@@ -271,7 +267,8 @@ Polymer({
networkStates[0].type === mojom.NetworkType.kEthernet) ?
1 :
0;
networkStates.splice(idx, 0, cellular);
networkStates.splice(
idx, 0, OncMojo.getDefaultNetworkState(mojom.NetworkType.kCellular));
},
/**
......
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