Commit 30a7d44d authored by pneubeck's avatar pneubeck Committed by Commit bot

Fix some properties on the settings page read from ONC.

- Fixed AutoConnect, which is stored in each network type's subdictionary.
- Added a Cellular.AutoConnect property to ONC.
- Fixed VPN username for L2TP-IPsec, which is stored in 'L2TP'.
- Removed reading Wimax properties from ONC, as these are not yet supported.

BUG=412807

Review URL: https://codereview.chromium.org/571123002

Cr-Commit-Position: refs/heads/master@{#294897}
parent d62ae950
......@@ -215,6 +215,10 @@ class ExtensionNetworkingPrivateApiTest
AddService("stub_cellular1", "cellular1",
shill::kTypeCellular, shill::kStateIdle);
// Note: These properties will show up in a "Cellular" object in ONC.
service_test_->SetServiceProperty(
"stub_cellular1",
shill::kAutoConnectProperty,
base::FundamentalValue(true));
service_test_->SetServiceProperty(
"stub_cellular1",
shill::kNetworkTechnologyProperty,
......
......@@ -1307,13 +1307,14 @@ cr.define('options.internet', function() {
$('prefer-network-wifi').checked = priority > 0;
$('prefer-network-wifi').disabled = !remembered;
$('auto-connect-network-wifi').checked =
onc.getActiveValue('AutoConnect');
onc.getActiveValue('WiFi.AutoConnect');
$('auto-connect-network-wifi').disabled = !remembered;
} else if (type == 'Wimax') {
OptionsPage.showTab($('wimax-network-nav-tab'));
$('wimax-restricted-connectivity').textContent = restrictedString;
$('auto-connect-network-wimax').checked =
onc.getActiveValue('AutoConnect');
onc.getActiveValue('Wimax.AutoConnect');
$('auto-connect-network-wimax').disabled = !remembered;
var identity = onc.getActiveValue('Wimax.EAP.Identity');
setOrHideParent('wimax-eap-identity', identity);
......@@ -1380,7 +1381,7 @@ cr.define('options.internet', function() {
detailsPage.initializeApnList_(onc);
}
$('auto-connect-network-cellular').checked =
onc.getActiveValue('AutoConnect');
onc.getActiveValue('Cellular.AutoConnect');
$('auto-connect-network-cellular').disabled = false;
} else if (type == 'VPN') {
OptionsPage.showTab($('vpn-nav-tab'));
......@@ -1388,9 +1389,18 @@ cr.define('options.internet', function() {
$('inet-provider-type').textContent =
onc.getTranslatedValue('VPN.Type');
var providerType = onc.getActiveValue('VPN.Type');
var providerKey = 'VPN.' + providerType;
$('inet-username').textContent =
onc.getActiveValue(providerKey + '.Username');
var usernameKey;
if (providerType == 'OpenVPN')
usernameKey = 'VPN.OpenVPN.Username';
else if (providerType == 'L2TP-IPsec')
usernameKey = 'VPN.L2TP.Username';
if (usernameKey) {
$('inet-username').parentElement.hidden = false;
$('inet-username').textContent = onc.getActiveValue(usernameKey);
} else {
$('inet-username').parentElement.hidden = true;
}
var inetServerHostname = $('inet-server-hostname');
inetServerHostname.value = onc.getActiveValue('VPN.Host');
inetServerHostname.resetHandler = function() {
......@@ -1400,7 +1410,7 @@ cr.define('options.internet', function() {
inetServerHostname.value = recommended;
};
$('auto-connect-network-vpn').checked =
onc.getActiveValue('AutoConnect');
onc.getActiveValue('VPN.AutoConnect');
$('auto-connect-network-vpn').disabled = false;
} else {
OptionsPage.showTab($('internet-nav-tab'));
......
......@@ -296,6 +296,7 @@ var availableTests = [
assertEq({ "Cellular": {
"ActivationState": "NotActivated",
"AllowRoaming": false,
"AutoConnect": true,
"Carrier": "Cellular1_Carrier",
"HomeProvider": {
"country": "us",
......
......@@ -249,6 +249,7 @@ const OncFieldSignature cellular_fields[] = {
{ ::onc::kRecommended, &kRecommendedSignature},
{ ::onc::cellular::kAPN, &kCellularApnSignature },
{ ::onc::cellular::kAPNList, &kCellularApnListSignature},
{ ::onc::vpn::kAutoConnect, &kBoolSignature},
{NULL}};
const OncFieldSignature cellular_with_state_fields[] = {
......
......@@ -154,6 +154,7 @@ const FieldTranslationEntry cellular_fields[] = {
{ ::onc::cellular::kActivationType, shill::kActivationTypeProperty},
// This field is converted during translation, see onc_translator_*.
// { ::onc::cellular::kActivationState, shill::kActivationStateProperty},
{ ::onc::vpn::kAutoConnect, shill::kAutoConnectProperty},
{ ::onc::cellular::kNetworkTechnology, shill::kNetworkTechnologyProperty},
// This field is converted during translation, see onc_translator_*.
// { ::onc::cellular::kRoamingState, shill::kRoamingStateProperty},
......
......@@ -393,6 +393,9 @@ void ShillToONCTranslator::TranslateNetworkWithState() {
if (!onc_network_type.empty()) {
onc_object_->SetStringWithoutPathExpansion(::onc::network_config::kType,
onc_network_type);
// Wimax is not supported by ONC, yet.
// TOOD(pneubeck): Wimax support is required, see https://crbug.com/414417 .
if (onc_network_type != ::onc::network_type::kWimax)
TranslateAndAddNestedObject(onc_network_type);
}
......
......@@ -6,6 +6,7 @@
"AccessPointName": "test-apn",
"Username": "test-username",
"Password": "test-password"
}
},
"AutoConnect": true
}
}
{
"AutoConnect": true,
"Type": "cellular",
"Cellular.APN": {
"apn": "test-apn",
......
{
"AutoConnect": true,
"Type": "cellular",
"Name": "Test Network",
"Cellular.ActivationState": "activated",
......
......@@ -5,6 +5,7 @@
"ActivationState": "Activated",
"ActivationType": "OTASP",
"AllowRoaming": true,
"AutoConnect": true,
"HomeProvider": {
"country": "us",
"name": "cellular_provider"
......
......@@ -1869,12 +1869,23 @@
<span class="value">Cellular</span> and the
field <span class="field">Cellular</span> must be set to an object of
type <span class="type">Cellular</span>. Currently only used for
representing an existing configuraiton; ONC configuration of
representing an existing configuration; ONC configuration of
of <span class="field">Cellular</span> networks is not yet supported.
Contains the following fields:
</p>
<dl class="field_list">
<dt class="field">AutoConnect</dt>
<dd>
<span class="field_meta">
(optional, defaults to <span class="value">false</span>)
<span class="type">boolean</span>
</span>
Indicating that the network should be connected to automatically when
possible. Note, that disabled <span class="field">AllowRoaming</span>
takes precedence over autoconnect.
</dd>
<dt class="field">APN</dt>
<dd>
<span class="field_meta">(optional)
......
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