Commit d3fb8e80 authored by Steven Bennetts's avatar Steven Bennetts Committed by Commit Bot

Fix onc_mojo.js with more strict type checking enabled

Bug: 1047812
Change-Id: I68513f609e42db54fa0d76c7a127970f4b123e00
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2042316
Commit-Queue: Steven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarJon Mann <jonmann@chromium.org>
Reviewed-by: default avatarAzeem Arshad <azeemarshad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#739238}
parent 88085d16
...@@ -647,7 +647,7 @@ class OncMojo { ...@@ -647,7 +647,7 @@ class OncMojo {
case mojom.NetworkType.kVPN: case mojom.NetworkType.kVPN:
networkState.typeState.vpn.providerName = networkState.typeState.vpn.providerName =
properties.typeProperties.vpn.providerName; properties.typeProperties.vpn.providerName;
networkState.typeState.vpn.vpnType = properties.typeProperties.vpn.type; networkState.typeState.vpn.type = properties.typeProperties.vpn.type;
break; break;
case mojom.NetworkType.kWiFi: case mojom.NetworkType.kWiFi:
const wifiProperties = properties.typeProperties.wifi; const wifiProperties = properties.typeProperties.wifi;
...@@ -690,8 +690,6 @@ class OncMojo { ...@@ -690,8 +690,6 @@ class OncMojo {
cellular: { cellular: {
activationState: mojom.ActivationStateType.kUnknown, activationState: mojom.ActivationStateType.kUnknown,
allowRoaming: false, allowRoaming: false,
prlVersion: 0,
scanning: false,
signalStrength: 0, signalStrength: 0,
supportNetworkScan: false, supportNetworkScan: false,
} }
...@@ -717,7 +715,6 @@ class OncMojo { ...@@ -717,7 +715,6 @@ class OncMojo {
vpn: { vpn: {
providerName: '', providerName: '',
type: mojom.VpnType.kOpenVPN, type: mojom.VpnType.kOpenVPN,
openVpn: {},
} }
}; };
break; break;
...@@ -794,7 +791,8 @@ class OncMojo { ...@@ -794,7 +791,8 @@ class OncMojo {
* !chromeos.networkConfig.mojom.ManagedInt32| * !chromeos.networkConfig.mojom.ManagedInt32|
* !chromeos.networkConfig.mojom.ManagedString| * !chromeos.networkConfig.mojom.ManagedString|
* !chromeos.networkConfig.mojom.ManagedStringList| * !chromeos.networkConfig.mojom.ManagedStringList|
* !chromeos.networkConfig.mojom.ManagedApnList|undefined} property * !chromeos.networkConfig.mojom.ManagedApnList|
* null|undefined} property
* @return {boolean|number|string|!Array<string>| * @return {boolean|number|string|!Array<string>|
* !Array<!chromeos.networkConfig.mojom.ApnProperties>|undefined} * !Array<!chromeos.networkConfig.mojom.ApnProperties>|undefined}
*/ */
...@@ -806,7 +804,7 @@ class OncMojo { ...@@ -806,7 +804,7 @@ class OncMojo {
} }
/** /**
* @param {!chromeos.networkConfig.mojom.ManagedString|undefined} property * @param {?chromeos.networkConfig.mojom.ManagedString|undefined} property
* @return {string} * @return {string}
*/ */
static getActiveString(property) { static getActiveString(property) {
...@@ -874,33 +872,27 @@ class OncMojo { ...@@ -874,33 +872,27 @@ class OncMojo {
} }
/** /**
* Compares the IP config properties of a new unmanaged dictionary to the * Compares two IP config property dictionaries. Returns true if all
* corresponding IP properties in an existing managed dictionary. Returns true * properties specified in the new dictionary match the values in the existing
* if all properties specified in the new dictionary match the values in the * dictionary.
* existing dictionary. * @param {!chromeos.networkConfig.mojom.IPConfigProperties} staticValue
* @param {!chromeos.networkConfig.mojom.ManagedIPConfigProperties}
* staticValue
* @param {!chromeos.networkConfig.mojom.IPConfigProperties} newValue * @param {!chromeos.networkConfig.mojom.IPConfigProperties} newValue
* @return {boolean} True if all properties set in |newValue| are equal to * @return {boolean} True if all properties set in |newValue| are equal to
* the corresponding properties in |staticValue|. * the corresponding properties in |staticValue|.
*/ */
static ipConfigPropertiesMatch(staticValue, newValue) { static ipConfigPropertiesMatch(staticValue, newValue) {
// If the existing type is unset, or the types do not match, return false. if (staticValue.type !== newValue.type) {
if (!staticValue.type || staticValue.type.activeValue !== newValue.type) {
return false; return false;
} }
if (newValue.gateway !== undefined && if (newValue.gateway !== undefined &&
(!staticValue.gateway || (staticValue.gateway !== newValue.gateway)) {
staticValue.gateway.activeValue !== newValue.gateway)) {
return false; return false;
} }
if (newValue.ipAddress !== undefined && if (newValue.ipAddress !== undefined &&
(!staticValue.ipAddress || staticValue.ipAddress !== newValue.ipAddress) {
staticValue.ipAddress.activeValue !== newValue.ipAddress)) {
return false; return false;
} }
if (!staticValue.routingPrefix || if (staticValue.routingPrefix !== newValue.routingPrefix) {
staticValue.routingPrefix.activeValue !== newValue.routingPrefix) {
return false; return false;
} }
return true; return true;
...@@ -1006,7 +998,7 @@ class OncMojo { ...@@ -1006,7 +998,7 @@ class OncMojo {
/** /**
* @param {string} s * @param {string} s
* @return {chromeos.networkConfig.mojom.ManagedString} * @return {!chromeos.networkConfig.mojom.ManagedString}
*/ */
static createManagedString(s) { static createManagedString(s) {
return { return {
...@@ -1018,7 +1010,7 @@ class OncMojo { ...@@ -1018,7 +1010,7 @@ class OncMojo {
/** /**
* @param {number} n * @param {number} n
* @return {chromeos.networkConfig.mojom.ManagedInt32} * @return {!chromeos.networkConfig.mojom.ManagedInt32}
*/ */
static createManagedInt(n) { static createManagedInt(n) {
return { return {
...@@ -1030,7 +1022,7 @@ class OncMojo { ...@@ -1030,7 +1022,7 @@ class OncMojo {
/** /**
* @param {boolean} b * @param {boolean} b
* @return {chromeos.networkConfig.mojom.ManagedBoolean} * @return {!chromeos.networkConfig.mojom.ManagedBoolean}
*/ */
static createManagedBool(b) { static createManagedBool(b) {
return { return {
......
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