Commit 64cdc5df authored by Steven Bennetts's avatar Steven Bennetts Committed by Commit Bot

Add PortalState to cros_network_config.mojom

This replaces the restricted_connectivity property to a more versitale
portal_state property and enum.

Bug: 1133376
Change-Id: I2229e2675b95ceea7184bdfd773b85be12e3217d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2490252
Commit-Queue: Steven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarKartik Hegde <khegde@chromium.org>
Reviewed-by: default avatarAzeem Arshad <azeemarshad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821409}
parent 97824893
...@@ -1758,17 +1758,29 @@ ...@@ -1758,17 +1758,29 @@
<message name="IDS_ONC_EAP_USER_CERT" desc="ONC Property label for EAP User Certs"> <message name="IDS_ONC_EAP_USER_CERT" desc="ONC Property label for EAP User Certs">
User certificate User certificate
</message> </message>
<message name="IDS_ONC_NOT_CONNECTED" desc="Settings > Internet, text in network summary when a network is not connecting or connected.">
Not Connected
</message>
<message name="IDS_ONC_MAC_ADDRESS" desc="ONC Property label for MacAddress"> <message name="IDS_ONC_MAC_ADDRESS" desc="ONC Property label for MacAddress">
MAC address MAC address
</message> </message>
<message name="IDS_ONC_NAME" desc="ONC Property label for the network Name (displayed when configuring a VPN service name)"> <message name="IDS_ONC_NAME" desc="ONC Property label for the network Name (displayed when configuring a VPN service name)">
Service name Service name
</message> </message>
<message name="IDS_ONC_RESTRICTED_CONNECTIVITY" desc="ONC Property label for RestrictedConnectivity"> <message name="IDS_ONC_NOT_CONNECTED" desc="Settings > Internet, text in network summary when a network is not connecting or connected.">
Restricted IP Not Connected
</message>
<message name="IDS_ONC_PORTAL_STATE" desc="Settings > Internet, label in network details page for the captive portal state.">
Portal State
</message>
<message name="IDS_ONC_PORTAL_STATE_NO_INTERNET" desc="Settings > Internet, text in network details page when no internet connection is avialable.">
No internet
</message>
<message name="IDS_ONC_PORTAL_STATE_PORTAL" desc="Settings > Internet, text in network details page when a portal state was detected.">
Captive portal detected
</message>
<message name="IDS_ONC_PORTAL_STATE_PORTAL_SUSPECTED" desc="Settings > Internet, text in network details page when a portal state is suspected.">
Captive portal suspected
</message>
<message name="IDS_ONC_PORTAL_STATE_PROXY_AUTH" desc="Settings > Internet, text in network details page when a portal state was detected.">
Proxy authentication required
</message> </message>
<message name="IDS_ONC_TETHER_BATTERY_PERCENTAGE" desc="Settings > Internet > Title of section which displays the battery percentage of another device which provides a tether hotspot for the current device to connect to."> <message name="IDS_ONC_TETHER_BATTERY_PERCENTAGE" desc="Settings > Internet > Title of section which displays the battery percentage of another device which provides a tether hotspot for the current device to connect to.">
Battery Battery
......
86385167aec69ce008588c0eda591bcf69243366
\ No newline at end of file
24c4fd2f748fb8aa5bf621e1ca5118313f515872
\ No newline at end of file
86385167aec69ce008588c0eda591bcf69243366
\ No newline at end of file
ad5a66b764be2ff8b1bfd9b835c1b03de46f00ee
\ No newline at end of file
390894787d570f43938804ecf1b638b0fe77e882
\ No newline at end of file
...@@ -82,7 +82,17 @@ void CaptivePortalRoutine::OnManagedPropertiesReceived( ...@@ -82,7 +82,17 @@ void CaptivePortalRoutine::OnManagedPropertiesReceived(
AnalyzeResultsAndExecuteCallback(); AnalyzeResultsAndExecuteCallback();
return; return;
} }
restricted_connectivity_ = managed_properties->restricted_connectivity; switch (managed_properties->portal_state) {
case network_config::mojom::PortalState::kUnknown:
case network_config::mojom::PortalState::kOnline:
break;
case network_config::mojom::PortalState::kPortalSuspected:
case network_config::mojom::PortalState::kPortal:
case network_config::mojom::PortalState::kProxyAuthRequired:
case network_config::mojom::PortalState::kNoInternet:
restricted_connectivity_ = true;
break;
}
AnalyzeResultsAndExecuteCallback(); AnalyzeResultsAndExecuteCallback();
} }
......
...@@ -534,17 +534,15 @@ Polymer({ ...@@ -534,17 +534,15 @@ Polymer({
fields.push( fields.push(
'cellular.activationState', 'cellular.servingOperator.name', 'cellular.activationState', 'cellular.servingOperator.name',
'cellular.roamingState'); 'cellular.roamingState');
if (this.managedProperties_.restrictedConnectivity) { }
fields.push('restrictedConnectivity'); if (OncMojo.isRestrictedConnectivity(this.managedProperties_.portalState)) {
} fields.push('portalState');
}
if (type == chromeos.networkConfig.mojom.NetworkType.kCellular) {
fields.push( fields.push(
'cellular.homeProvider.name', 'cellular.meid', 'cellular.esn', 'cellular.homeProvider.name', 'cellular.meid', 'cellular.esn',
'cellular.iccid', 'cellular.imei', 'cellular.imsi', 'cellular.mdn', 'cellular.iccid', 'cellular.imei', 'cellular.imsi', 'cellular.mdn',
'cellular.min'); 'cellular.min');
} else if (type == chromeos.networkConfig.mojom.NetworkType.kWiFi) {
if (this.managedProperties_.restrictedConnectivity) {
fields.push('restrictedConnectivity');
}
} }
return fields; return fields;
}, },
......
...@@ -1887,9 +1887,6 @@ Polymer({ ...@@ -1887,9 +1887,6 @@ Polymer({
case chromeos.networkConfig.mojom.NetworkType.kCellular: case chromeos.networkConfig.mojom.NetworkType.kCellular:
fields.push( fields.push(
'cellular.activationState', 'cellular.servingOperator.name'); 'cellular.activationState', 'cellular.servingOperator.name');
if (this.managedProperties_.restrictedConnectivity) {
fields.push('restrictedConnectivity');
}
break; break;
case chromeos.networkConfig.mojom.NetworkType.kTether: case chromeos.networkConfig.mojom.NetworkType.kTether:
fields.push( fields.push(
...@@ -1917,11 +1914,11 @@ Polymer({ ...@@ -1917,11 +1914,11 @@ Polymer({
} }
break; break;
case chromeos.networkConfig.mojom.NetworkType.kWiFi: case chromeos.networkConfig.mojom.NetworkType.kWiFi:
if (this.managedProperties_.restrictedConnectivity) {
fields.push('restrictedConnectivity');
}
break; break;
} }
if (OncMojo.isRestrictedConnectivity(this.managedProperties_.portalState)) {
fields.push('portalState');
}
return fields; return fields;
}, },
......
...@@ -158,7 +158,11 @@ void AddOncLocalizedStrings(content::WebUIDataSource* html_source) { ...@@ -158,7 +158,11 @@ void AddOncLocalizedStrings(content::WebUIDataSource* html_source) {
{"OncMacAddress", IDS_ONC_MAC_ADDRESS}, {"OncMacAddress", IDS_ONC_MAC_ADDRESS},
{"OncName", IDS_ONC_NAME}, {"OncName", IDS_ONC_NAME},
{"OncNotConnected", IDS_ONC_NOT_CONNECTED}, {"OncNotConnected", IDS_ONC_NOT_CONNECTED},
{"OncRestrictedConnectivity", IDS_ONC_RESTRICTED_CONNECTIVITY}, {"OncPortalState", IDS_ONC_PORTAL_STATE},
{"OncPortalState_NoInternet", IDS_ONC_PORTAL_STATE_NO_INTERNET},
{"OncPortalState_Portal", IDS_ONC_PORTAL_STATE_PORTAL},
{"OncPortalState_PortalSuspected", IDS_ONC_PORTAL_STATE_PORTAL_SUSPECTED},
{"OncPortalState_ProxyAuthRequired", IDS_ONC_PORTAL_STATE_PROXY_AUTH},
{"OncTether-BatteryPercentage", IDS_ONC_TETHER_BATTERY_PERCENTAGE}, {"OncTether-BatteryPercentage", IDS_ONC_TETHER_BATTERY_PERCENTAGE},
{"OncTether-BatteryPercentage_Value", {"OncTether-BatteryPercentage_Value",
IDS_ONC_TETHER_BATTERY_PERCENTAGE_VALUE}, IDS_ONC_TETHER_BATTERY_PERCENTAGE_VALUE},
......
...@@ -224,6 +224,26 @@ mojom::DeviceStateType GetMojoDeviceStateType( ...@@ -224,6 +224,26 @@ mojom::DeviceStateType GetMojoDeviceStateType(
return mojom::DeviceStateType::kUnavailable; return mojom::DeviceStateType::kUnavailable;
} }
mojom::PortalState GetMojoPortalState(
const NetworkState::PortalState portal_state) {
switch (portal_state) {
case NetworkState::PortalState::kUnknown:
return mojom::PortalState::kUnknown;
case NetworkState::PortalState::kOnline:
return mojom::PortalState::kOnline;
case NetworkState::PortalState::kPortalSuspected:
return mojom::PortalState::kPortalSuspected;
case NetworkState::PortalState::kPortal:
return mojom::PortalState::kPortal;
case NetworkState::PortalState::kProxyAuthRequired:
return mojom::PortalState::kProxyAuthRequired;
case NetworkState::PortalState::kNoInternet:
return mojom::PortalState::kNoInternet;
}
NOTREACHED();
return mojom::PortalState::kUnknown;
}
mojom::OncSource GetMojoOncSource(const NetworkState* network) { mojom::OncSource GetMojoOncSource(const NetworkState* network) {
::onc::ONCSource source = network->onc_source(); ::onc::ONCSource source = network->onc_source();
switch (source) { switch (source) {
...@@ -310,6 +330,7 @@ mojom::NetworkStatePropertiesPtr NetworkStateToMojo( ...@@ -310,6 +330,7 @@ mojom::NetworkStatePropertiesPtr NetworkStateToMojo(
result->error_state = network->GetError(); result->error_state = network->GetError();
result->guid = network->guid(); result->guid = network->guid();
result->name = network->name(); result->name = network->name();
result->portal_state = GetMojoPortalState(network->portal_state());
result->priority = network->priority(); result->priority = network->priority();
result->prohibited_by_policy = network->blocked_by_policy(); result->prohibited_by_policy = network->blocked_by_policy();
result->source = GetMojoOncSource(network); result->source = GetMojoOncSource(network);
...@@ -1216,8 +1237,7 @@ mojom::ManagedPropertiesPtr ManagedPropertiesToMojo( ...@@ -1216,8 +1237,7 @@ mojom::ManagedPropertiesPtr ManagedPropertiesToMojo(
ip_configs.push_back(GetIPConfig(&ip_config_value)); ip_configs.push_back(GetIPConfig(&ip_config_value));
result->ip_configs = std::move(ip_configs); result->ip_configs = std::move(ip_configs);
} }
result->restricted_connectivity = result->portal_state = GetMojoPortalState(network_state->portal_state());
GetBoolean(properties, ::onc::network_config::kRestrictedConnectivity);
const base::Value* saved_ip_config = const base::Value* saved_ip_config =
GetDictionary(properties, ::onc::network_config::kSavedIPConfig); GetDictionary(properties, ::onc::network_config::kSavedIPConfig);
if (saved_ip_config) if (saved_ip_config)
......
...@@ -187,6 +187,8 @@ struct NetworkStateProperties { ...@@ -187,6 +187,8 @@ struct NetworkStateProperties {
string guid; string guid;
// The human readable name of the network, e.g. WiFi SSID or network type. // The human readable name of the network, e.g. WiFi SSID or network type.
string name; string name;
// The captive portal state when connectionState == kPortal.
PortalState portal_state = kUnknown;
// The relative priority of the network. Larger values have higher priority. // The relative priority of the network. Larger values have higher priority.
int32 priority; int32 priority;
// The proxy mode affecting this network. Includes any settings that affect // The proxy mode affecting this network. Includes any settings that affect
...@@ -575,7 +577,7 @@ struct ManagedProperties { ...@@ -575,7 +577,7 @@ struct ManagedProperties {
ManagedString? name_servers_config_type; ManagedString? name_servers_config_type;
ManagedInt32? priority; ManagedInt32? priority;
ManagedProxySettings? proxy_settings; ManagedProxySettings? proxy_settings;
bool restricted_connectivity = false; PortalState portal_state = kUnknown;
ManagedIPConfigProperties? static_ip_config; ManagedIPConfigProperties? static_ip_config;
IPConfigProperties? saved_ip_config; IPConfigProperties? saved_ip_config;
// |type| is explicitly provided here to simplify UI code and will always // |type| is explicitly provided here to simplify UI code and will always
......
...@@ -73,3 +73,21 @@ enum PolicySource { ...@@ -73,3 +73,21 @@ enum PolicySource {
// The property value came from an extension. // The property value came from an extension.
kActiveExtension, kActiveExtension,
}; };
// The captive portal state. Provides additional details when the connection
// state is kPortal.
enum PortalState {
// The network is not connected or the portal state is not available.
kUnknown,
// The network is connected and no portal is detected.
kOnline,
// A portal is suspected but no redirect was provided.
kPortalSuspected,
// The network is in a portal state with a redirect URL.
kPortal,
// A proxy requiring authentication is detected.
kProxyAuthRequired,
// The network is connected but no internet is available and no proxy was
// detected.
kNoInternet,
};
...@@ -303,6 +303,9 @@ Polymer({ ...@@ -303,6 +303,9 @@ Polymer({
valueStr = OncMojo.getActivationStateTypeString( valueStr = OncMojo.getActivationStateTypeString(
/** @type{!chromeos.networkConfig.mojom.ActivationStateType}*/ ( /** @type{!chromeos.networkConfig.mojom.ActivationStateType}*/ (
value)); value));
} else if (key === 'portalState') {
valueStr = OncMojo.getPortalStateString(
/** @type{!chromeos.networkConfig.mojom.PortalState}*/ (value));
} else if (key === 'vpn.type') { } else if (key === 'vpn.type') {
valueStr = OncMojo.getVpnTypeString( valueStr = OncMojo.getVpnTypeString(
/** @type{!chromeos.networkConfig.mojom.VpnType}*/ (value)); /** @type{!chromeos.networkConfig.mojom.VpnType}*/ (value));
......
...@@ -81,6 +81,30 @@ ...@@ -81,6 +81,30 @@
return ActivationStateType.kUnknown; return ActivationStateType.kUnknown;
} }
/**
* @param {!chromeos.networkConfig.mojom.PortalState} value
* @return {string}
*/
static getPortalStateString(value) {
const PortalState = chromeos.networkConfig.mojom.PortalState;
switch (value) {
case PortalState.kUnknown:
return 'Unknown';
case PortalState.kOnline:
return 'Online';
case PortalState.kPortalSuspected:
return 'PortalSuspected';
case PortalState.kPortal:
return 'Portal';
case PortalState.kProxyAuthRequired:
return 'ProxyAuthRequired';
case PortalState.kNoInternet:
return 'NoInternet';
}
assertNotReached('Unexpected enum value: ' + OncMojo.getEnumString(value));
return '';
}
/** /**
* @param {!chromeos.networkConfig.mojom.ConnectionStateType} value * @param {!chromeos.networkConfig.mojom.ConnectionStateType} value
* @return {string} * @return {string}
...@@ -555,6 +579,7 @@ ...@@ -555,6 +579,7 @@
connectionState: mojom.ConnectionStateType.kNotConnected, connectionState: mojom.ConnectionStateType.kNotConnected,
guid: opt_name ? (opt_name + '_guid') : '', guid: opt_name ? (opt_name + '_guid') : '',
name: opt_name || '', name: opt_name || '',
portalState: mojom.PortalState.kUnknown,
priority: 0, priority: 0,
proxyMode: mojom.ProxyMode.kDirect, proxyMode: mojom.ProxyMode.kDirect,
prohibitedByPolicy: false, prohibitedByPolicy: false,
...@@ -692,7 +717,7 @@ ...@@ -692,7 +717,7 @@
connectable: false, connectable: false,
guid: guid, guid: guid,
name: OncMojo.createManagedString(name), name: OncMojo.createManagedString(name),
restrictedConnectivity: false, portalState: mojom.PortalState.kUnknown,
}; };
switch (type) { switch (type) {
case mojom.NetworkType.kCellular: case mojom.NetworkType.kCellular:
...@@ -1134,6 +1159,30 @@ ...@@ -1134,6 +1159,30 @@
} }
return a.every((apn, index) => OncMojo.apnMatch(apn, b[index])); return a.every((apn, index) => OncMojo.apnMatch(apn, b[index]));
} }
/**
* Returns true if the portal state has restricted connectivity.
* @param {!chromeos.networkConfig.mojom.PortalState|undefined} portal
* @return {boolean}
*/
static isRestrictedConnectivity(portal) {
if (portal === undefined) {
return false;
}
const PortalState = chromeos.networkConfig.mojom.PortalState;
switch (portal) {
case PortalState.kUnknown:
case PortalState.kOnline:
return false;
case PortalState.kPortalSuspected:
case PortalState.kPortal:
case PortalState.kProxyAuthRequired:
case PortalState.kNoInternet:
return true;
}
assertNotReached();
return false;
}
} }
/** @typedef {chromeos.networkConfig.mojom.DeviceStateProperties} */ /** @typedef {chromeos.networkConfig.mojom.DeviceStateProperties} */
......
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