summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/resources/options/chromeos/internet_detail.js183
-rw-r--r--chrome/browser/ui/webui/chromeos/network_config_message_handler.cc23
-rw-r--r--chrome/browser/ui/webui/chromeos/network_config_message_handler.h8
-rw-r--r--chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc115
-rw-r--r--chromeos/network/network_state.cc6
-rw-r--r--chromeos/network/network_state.h2
-rw-r--r--chromeos/network/onc/onc_signature.cc2
-rw-r--r--chromeos/network/onc/onc_translation_tables.cc3
-rw-r--r--chromeos/network/onc/onc_translator_shill_to_onc.cc4
-rw-r--r--chromeos/test/data/network/cellular.onc2
-rw-r--r--chromeos/test/data/network/translation_of_shill_cellular_with_state.onc11
-rw-r--r--components/onc/onc_constants.cc2
-rw-r--r--components/onc/onc_constants.h2
13 files changed, 183 insertions, 180 deletions
diff --git a/chrome/browser/resources/options/chromeos/internet_detail.js b/chrome/browser/resources/options/chromeos/internet_detail.js
index 62086a1..2000605 100644
--- a/chrome/browser/resources/options/chromeos/internet_detail.js
+++ b/chrome/browser/resources/options/chromeos/internet_detail.js
@@ -36,7 +36,7 @@ cr.define('options.internet', function() {
*/
function getManagedValue(data, key, type) {
var property = getManagedProperty(data, key);
- if (typeof property != 'object')
+ if (Array.isArray(property) || typeof property != 'object')
return property;
if (type == GetManagedTypes.RECOMMENDED)
return getRecommendedValue(property);
@@ -45,8 +45,12 @@ cr.define('options.internet', function() {
// Otherwise get the Active value (defalt behavior).
if ('Active' in property)
return property['Active'];
- // If no Active value is defined, return the effective value.
- return getEffectiveValue(property);
+ // If no Active value is defined, return the effective value if present.
+ var effective = getEffectiveValue(property);
+ if (effective != undefined)
+ return effective;
+ // Otherwise this is an Object but not a Managed one.
+ return property;
}
/**
@@ -101,6 +105,40 @@ cr.define('options.internet', function() {
}
/**
+ * Set the value of a property in dictionary |data| that includes ONC
+ * managed properties, e.g. setManagedValue(data, 'Name', 'MyNetwork').
+ * See notes for getManagedProperty.
+ * @param {object} data The properties dictionary.
+ * @param {string} key The property key.
+ * @param {string} value The property value to set.
+ */
+ function setManagedProperty(data, key, value) {
+ while (true) {
+ var index = key.indexOf('.');
+ if (index < 0)
+ break;
+ var keyComponent = key.substr(0, index);
+ if (!(keyComponent in data))
+ data[keyComponent] = {};
+ data = data[keyComponent];
+ key = key.substr(index + 1);
+ }
+ if (!(key in data) ||
+ (typeof data[key] != 'object') ||
+ (!('Active' in data[key]) && !('Effective' in data[key]))) {
+ data[key] = value;
+ } else {
+ var effective = data[key]['Effective'];
+ assert(effective != 'UserPolicy' || data[key]['UserEditable']);
+ assert(effective != 'DevicePolicy' || data[key]['DeviceEditable']);
+ // For now, just uodare the active value. TODO(stevenjb): Eventually we
+ // should update the 'UserSetting' and 'Effective' properties correctly
+ // and send that back to Chrome.
+ data[key]['Active'] = value;
+ }
+ }
+
+ /**
* Helper function to set hidden attribute for elements matching a selector.
* @param {string} selector CSS selector for extracting a list of elements.
* @param {bool} hidden New hidden value.
@@ -272,25 +310,25 @@ cr.define('options.internet', function() {
data.userApnIndex = -1;
}
- if (data.providerApnList.value.length > 0) {
- var iApn = 0;
- var defaultApn = data.providerApnList.value[iApn];
- data.apn.apn = stringFromValue(defaultApn.apn);
- data.apn.username = stringFromValue(defaultApn.username);
- data.apn.password = stringFromValue(defaultApn.password);
+ var activeApn;
+ var iApn = -1;
+ var apnList = getManagedValue(data, 'Cellular.APNList');
+ if (apnList != undefined && apnList.length > 0) {
+ iApn = 0;
+ var defaultApn = apnList[iApn];
+ activeApn['AccessPointName'] =
+ stringFromValue(defaultApn['AccessPointName']);
+ activeApn['Username'] = stringFromValue(defaultApn['Username']);
+ activeApn['Password'] = stringFromValue(defaultApn['Password']);
chrome.send('setApn', [data.servicePath,
- data.apn.apn,
- data.apn.username,
- data.apn.password]);
- apnSelector.selectedIndex = iApn;
- data.selectedApn = iApn;
- } else {
- data.apn.apn = '';
- data.apn.username = '';
- data.apn.password = '';
- apnSelector.selectedIndex = -1;
- data.selectedApn = -1;
+ activeApn['AccessPointName'],
+ activeApn['Username'],
+ activeApn['Password']]);
}
+ setManagedProperty(data, 'Cellular.APN', activeApn);
+ apnSelector.selectedIndex = iApn;
+ data.selectedApn = iApn;
+
updateHidden('.apn-list-view', false);
updateHidden('.apn-details-view', true);
});
@@ -302,18 +340,19 @@ cr.define('options.internet', function() {
var data = $('connection-state').data;
var apnSelector = $('select-apn');
- data.apn.apn = stringFromValue($('cellular-apn').value);
- data.apn.username = stringFromValue($('cellular-apn-username').value);
- data.apn.password = stringFromValue($('cellular-apn-password').value);
- data.userApn = {
- 'apn': data.apn.apn,
- 'username': data.apn.username,
- 'password': data.apn.password
- };
+ var activeApn = {};
+ activeApn['AccessPointName'] =
+ stringFromValue($('cellular-apn').value);
+ activeApn['Username'] =
+ stringFromValue($('cellular-apn-username').value);
+ activeApn['Password'] =
+ stringFromValue($('cellular-apn-password').value);
+ setManagedProperty(data, 'Cellular.APN', activeApn);
+ data.userApn = activeApn;
chrome.send('setApn', [data.servicePath,
- data.apn.apn,
- data.apn.username,
- data.apn.password]);
+ activeApn['AccessPointName'],
+ activeApn['Username'],
+ activeApn['Password']]);
if (data.userApnIndex != -1) {
apnSelector.remove(data.userApnIndex);
@@ -321,7 +360,7 @@ cr.define('options.internet', function() {
}
var option = document.createElement('option');
- option.textContent = data.apn.apn;
+ option.textContent = activeApn['AccessPointName'];
option.value = -1;
option.selected = true;
apnSelector.add(option, apnSelector[apnSelector.length - 1]);
@@ -341,24 +380,31 @@ cr.define('options.internet', function() {
$('select-apn').addEventListener('change', function(event) {
var data = $('connection-state').data;
var apnSelector = $('select-apn');
+ var apnDict;
if (apnSelector[apnSelector.selectedIndex].value != -1) {
- var apnList = data.providerApnList.value;
+ var apnList = getManagedValue(data, 'Cellular.APNList');
+ var apnIndex = apnSelector.selectedIndex;
+ assert(apnIndex < apnList.length);
+ apnDict = apnList[apnIndex];
chrome.send('setApn', [data.servicePath,
- stringFromValue(apnList[apnSelector.selectedIndex].apn),
- stringFromValue(apnList[apnSelector.selectedIndex].username),
- stringFromValue(apnList[apnSelector.selectedIndex].password)]
- );
- data.selectedApn = apnSelector.selectedIndex;
+ stringFromValue(apnDict['AccessPointName']),
+ stringFromValue(apnDict['Username']),
+ stringFromValue(apnDict['Password'])]);
+ data.selectedApn = apnIndex;
} else if (apnSelector.selectedIndex == data.userApnIndex) {
+ apnDict = data.userApn;
chrome.send('setApn', [data.servicePath,
- stringFromValue(data.userApn.apn),
- stringFromValue(data.userApn.username),
- stringFromValue(data.userApn.password)]);
+ stringFromValue(apnDict['AccessPointName']),
+ stringFromValue(apnDict['Username']),
+ stringFromValue(apnDict['Password'])]);
data.selectedApn = apnSelector.selectedIndex;
} else {
- $('cellular-apn').value = stringFromValue(data.apn.apn);
- $('cellular-apn-username').value = stringFromValue(data.apn.username);
- $('cellular-apn-password').value = stringFromValue(data.apn.password);
+ apnDict = getManagedValue(data, 'Cellular.APN');
+ $('cellular-apn').value = stringFromValue(apnDict['AccessPointName']);
+ $('cellular-apn-username').value =
+ stringFromValue(apnDict['Username']);
+ $('cellular-apn-password').value =
+ stringFromValue(apnDict['Password']);
updateHidden('.apn-list-view', true);
updateHidden('.apn-details-view', false);
@@ -1017,8 +1063,8 @@ cr.define('options.internet', function() {
$('details-internet-login').hidden = true;
if (detailsPage.gsm) {
- // TODO(stevenjb): Use managed properties for policy controlled values.
- var lockEnabled = data.simCardLockEnabled.value;
+ var lockEnabled =
+ getManagedValue(data, 'Cellular.SIMLockStatus.LockEnabled');
$('sim-card-lock-enabled').checked = lockEnabled;
$('change-pin').hidden = !lockEnabled;
}
@@ -1328,33 +1374,38 @@ cr.define('options.internet', function() {
var otherOption = apnSelector[0];
data.selectedApn = -1;
data.userApnIndex = -1;
- var apnList = data.providerApnList.value;
+ var activeApn = getManagedValue(data, 'Cellular.APN');
+ var lastGoodApn = getManagedValue(data, 'Cellular.LastGoodAPN');
+ var apnList = getManagedValue(data, 'Cellular.APNList');
for (var i = 0; i < apnList.length; i++) {
+ var apnDict = apnList[i];
var option = document.createElement('option');
- var localizedName = apnList[i].localizedName;
- var name = localizedName ? localizedName : apnList[i].name;
- var apn = apnList[i].apn;
- option.textContent = name ? (name + ' (' + apn + ')') : apn;
+ var localizedName = apnDict['LocalizedName'];
+ var name = localizedName ? localizedName : apnDict['Name'];
+ var accessPointName = apnDict['AccessPointName'];
+ option.textContent =
+ name ? (name + ' (' + accessPointName + ')') : accessPointName;
option.value = i;
- // data.apn and data.lastGoodApn will always be defined, however
- // data.apn.apn and data.lastGoodApn.apn may not be. This is not a
- // problem, as apnList[i].apn will always be defined and the
- // comparisons below will work as expected.
- if ((data.apn.apn == apn &&
- data.apn.username == apnList[i].username &&
- data.apn.password == apnList[i].password) ||
- (!data.apn.apn &&
- data.lastGoodApn.apn == apn &&
- data.lastGoodApn.username == apnList[i].username &&
- data.lastGoodApn.password == apnList[i].password)) {
+ // If this matches the active Apn, or LastGoodApn, set it as the
+ // selected Apn.
+ if ((activeApn != undefined &&
+ activeApn['AccessPointName'] == accessPointName &&
+ activeApn['Username'] == apnDict['Username'] &&
+ activeApn['Password'] == apnDict['Password']) ||
+ ((activeApn == undefined || !activeApn['AccessPointName']) &&
+ lastGoodApn != undefined &&
+ lastGoodApn['AccessPointName'] == accessPointName &&
+ lastGoodApn['Username'] == apnDict['Username'] &&
+ lastGoodApn['Password'] == apnDict['Password'])) {
data.selectedApn = i;
}
// Insert new option before "other" option.
apnSelector.add(option, otherOption);
}
- if (data.selectedApn == -1 && data.apn.apn) {
+ if (data.selectedApn == -1 &&
+ activeApn != undefined && activeApn['AccessPointName']) {
var option = document.createElement('option');
- option.textContent = data.apn.apn;
+ option.textContent = activeApn['AccessPointName'];
option.value = -1;
apnSelector.add(option, otherOption);
data.selectedApn = apnSelector.length - 2;
@@ -1363,8 +1414,8 @@ cr.define('options.internet', function() {
apnSelector.selectedIndex = data.selectedApn;
updateHidden('.apn-list-view', false);
updateHidden('.apn-details-view', true);
- // TODO(stevenjb): Used managed properties for policy controlled value.
- var lockEnabled = data.simCardLockEnabled.value;
+ var lockEnabled =
+ getManagedValue(data, 'Cellular.SIMLockStatus.LockEnabled');
$('sim-card-lock-enabled').checked = lockEnabled;
$('change-pin').hidden = !lockEnabled;
}
diff --git a/chrome/browser/ui/webui/chromeos/network_config_message_handler.cc b/chrome/browser/ui/webui/chromeos/network_config_message_handler.cc
index bb1feff..7d88bcd 100644
--- a/chrome/browser/ui/webui/chromeos/network_config_message_handler.cc
+++ b/chrome/browser/ui/webui/chromeos/network_config_message_handler.cc
@@ -11,6 +11,7 @@
#include "base/logging.h"
#include "base/values.h"
#include "chromeos/login/login_state.h"
+#include "chromeos/network/device_state.h"
#include "chromeos/network/managed_network_configuration_handler.h"
#include "chromeos/network/network_configuration_handler.h"
#include "chromeos/network/network_state.h"
@@ -173,12 +174,32 @@ void NetworkConfigMessageHandler::GetShillProperties(
}
NetworkHandler::Get()->network_configuration_handler()->GetProperties(
service_path,
- base::Bind(&NetworkConfigMessageHandler::GetPropertiesSuccess,
+ base::Bind(&NetworkConfigMessageHandler::GetShillPropertiesSuccess,
weak_ptr_factory_.GetWeakPtr(), callback_id),
base::Bind(&NetworkConfigMessageHandler::ErrorCallback,
weak_ptr_factory_.GetWeakPtr(), callback_id));
}
+void NetworkConfigMessageHandler::GetShillPropertiesSuccess(
+ int callback_id,
+ const std::string& service_path,
+ const base::DictionaryValue& dictionary) const {
+ scoped_ptr<base::DictionaryValue> dictionary_copy(dictionary.DeepCopy());
+
+ // Get the device properties for debugging.
+ std::string device;
+ dictionary_copy->GetStringWithoutPathExpansion(
+ shill::kDeviceProperty, &device);
+ const DeviceState* device_state =
+ NetworkHandler::Get()->network_state_handler()->GetDeviceState(device);
+ if (device_state) {
+ base::DictionaryValue* device_dictionary =
+ device_state->properties().DeepCopy();
+ dictionary_copy->Set(shill::kDeviceProperty, device_dictionary);
+ }
+ GetPropertiesSuccess(callback_id, service_path, *dictionary_copy);
+}
+
void NetworkConfigMessageHandler::InvokeCallback(
const base::ListValue& arg_list) const {
web_ui()->CallJavascriptFunction(
diff --git a/chrome/browser/ui/webui/chromeos/network_config_message_handler.h b/chrome/browser/ui/webui/chromeos/network_config_message_handler.h
index 0962919..de229c2 100644
--- a/chrome/browser/ui/webui/chromeos/network_config_message_handler.h
+++ b/chrome/browser/ui/webui/chromeos/network_config_message_handler.h
@@ -38,10 +38,16 @@ class NetworkConfigMessageHandler : public content::WebUIMessageHandler {
void GetNetworks(const base::ListValue* arg_list) const;
void GetProperties(const base::ListValue* arg_list);
void GetManagedProperties(const base::ListValue* arg_list);
- void GetShillProperties(const base::ListValue* arg_list);
void GetPropertiesSuccess(int callback_id,
const std::string& service_path,
const base::DictionaryValue& dictionary) const;
+
+ // Get Shill Properties for debugging purposes only.
+ void GetShillProperties(const base::ListValue* arg_list);
+ void GetShillPropertiesSuccess(int callback_id,
+ const std::string& service_path,
+ const base::DictionaryValue& dictionary) const;
+
void InvokeCallback(const base::ListValue& arg_list) const;
void ErrorCallback(int callback_id,
const std::string& error_name,
diff --git a/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc
index f49f63e..096afe4 100644
--- a/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc
+++ b/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc
@@ -28,6 +28,7 @@
#include "chrome/browser/chromeos/ui/mobile_config_ui.h"
#include "chrome/browser/chromeos/ui_proxy_config_service.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h"
#include "chrome/browser/ui/webui/options/chromeos/internet_options_handler_strings.h"
#include "chromeos/chromeos_switches.h"
#include "chromeos/network/device_state.h"
@@ -131,7 +132,6 @@ const char kShowMorePlanInfoMessage[] = "showMorePlanInfo";
const char kTagActivate[] = "activate";
const char kTagActivationState[] = "activationState";
const char kTagAddConnection[] = "add";
-const char kTagApn[] = "apn";
const char kTagCarrierSelectFlag[] = "showCarrierSelect";
const char kTagCarrierUrl[] = "carrierUrl";
const char kTagCellularAvailable[] = "cellularAvailable";
@@ -144,17 +144,10 @@ const char kTagDeviceConnected[] = "deviceConnected";
const char kTagDisconnect[] = "disconnect";
const char kTagErrorMessage[] = "errorMessage";
const char kTagForget[] = "forget";
-const char kTagLanguage[] = "language";
-const char kTagLastGoodApn[] = "lastGoodApn";
-const char kTagLocalizedName[] = "localizedName";
-const char kTagName[] = "name";
const char kTagNameServersGoogle[] = "nameServersGoogle";
const char kTagNameServerType[] = "nameServerType";
-const char kTagNetworkId[] = "networkId";
const char kTagOptions[] = "options";
-const char kTagPassword[] = "password";
const char kTagPolicy[] = "policy";
-const char kTagProviderApnList[] = "providerApnList";
const char kTagRecommended[] = "recommended";
const char kTagRecommendedValue[] = "recommendedValue";
const char kTagRemembered[] = "remembered";
@@ -166,10 +159,7 @@ const char kTagCurrentCarrierIndex[] = "currentCarrierIndex";
const char kTagShared[] = "shared";
const char kTagShowActivateButton[] = "showActivateButton";
const char kTagShowViewAccountButton[] = "showViewAccountButton";
-const char kTagSimCardLockEnabled[] = "simCardLockEnabled";
-const char kTagSupportUrl[] = "supportUrl";
const char kTagTrue[] = "true";
-const char kTagUsername[] = "username";
const char kTagValue[] = "value";
const char kTagVpnList[] = "vpnList";
const char kTagWifiAvailable[] = "wifiAvailable";
@@ -414,16 +404,6 @@ void SetTranslatedDictionary(const char* settings_dict_key,
dict->SetString(kTranslatedKey, translated_value);
}
-std::string CopyStringFromDictionary(const base::DictionaryValue& source,
- const std::string& src_key,
- const std::string& dest_key,
- base::DictionaryValue* dest) {
- std::string string_value;
- if (source.GetStringWithoutPathExpansion(src_key, &string_value))
- dest->SetStringWithoutPathExpansion(dest_key, string_value);
- return string_value;
-}
-
// Fills |dictionary| with the configuration details of |vpn|. |onc| is required
// for augmenting the policy-managed information.
void PopulateVPNDetails(const NetworkState* vpn,
@@ -506,24 +486,7 @@ int FindCurrentCarrierIndex(const base::ListValue* carriers,
return -1;
}
-void CreateDictionaryFromCellularApn(const base::DictionaryValue* apn,
- base::DictionaryValue* dictionary) {
- CopyStringFromDictionary(*apn, shill::kApnProperty, kTagApn, dictionary);
- CopyStringFromDictionary(
- *apn, shill::kApnNetworkIdProperty, kTagNetworkId, dictionary);
- CopyStringFromDictionary(
- *apn, shill::kApnUsernameProperty, kTagUsername, dictionary);
- CopyStringFromDictionary(
- *apn, shill::kApnPasswordProperty, kTagPassword, dictionary);
- CopyStringFromDictionary(*apn, shill::kApnNameProperty, kTagName, dictionary);
- CopyStringFromDictionary(
- *apn, shill::kApnLocalizedNameProperty, kTagLocalizedName, dictionary);
- CopyStringFromDictionary(
- *apn, shill::kApnLanguageProperty, kTagLanguage, dictionary);
-}
-
void PopulateCellularDetails(const NetworkState* cellular,
- const base::DictionaryValue& shill_properties,
base::DictionaryValue* dictionary) {
dictionary->SetBoolean(kTagCarrierSelectFlag,
CommandLine::ForCurrentProcess()->HasSwitch(
@@ -539,29 +502,6 @@ void PopulateCellularDetails(const NetworkState* cellular,
internet_options_strings::RestrictedStateString(
cellular->connection_state()));
- const base::DictionaryValue* olp = NULL;
- if (shill_properties.GetDictionaryWithoutPathExpansion(
- shill::kPaymentPortalProperty, &olp)) {
- std::string url;
- olp->GetStringWithoutPathExpansion(shill::kPaymentPortalURL, &url);
- dictionary->SetString(kTagSupportUrl, url);
- }
-
- base::DictionaryValue* apn = new base::DictionaryValue;
- const base::DictionaryValue* source_apn = NULL;
- if (shill_properties.GetDictionaryWithoutPathExpansion(
- shill::kCellularApnProperty, &source_apn)) {
- CreateDictionaryFromCellularApn(source_apn, apn);
- }
- dictionary->Set(kTagApn, apn);
-
- base::DictionaryValue* last_good_apn = new base::DictionaryValue;
- if (shill_properties.GetDictionaryWithoutPathExpansion(
- shill::kCellularLastGoodApnProperty, &source_apn)) {
- CreateDictionaryFromCellularApn(source_apn, last_good_apn);
- }
- dictionary->Set(kTagLastGoodApn, last_good_apn);
-
// These default to empty and are only set if device != NULL.
std::string carrier_id;
std::string mdn;
@@ -572,15 +512,6 @@ void PopulateCellularDetails(const NetworkState* cellular,
cellular->device_path());
if (device) {
const base::DictionaryValue& device_properties = device->properties();
- ::onc::ONCSource onc_source;
- NetworkHandler::Get()->managed_network_configuration_handler()->
- FindPolicyByGUID(LoginState::Get()->primary_user_hash(),
- cellular->guid(), &onc_source);
- const NetworkPropertyUIData cellular_property_ui_data(onc_source);
- SetValueDictionary(kTagSimCardLockEnabled,
- new base::FundamentalValue(device->sim_lock_enabled()),
- cellular_property_ui_data,
- dictionary);
carrier_id = device->home_provider_id();
device_properties.GetStringWithoutPathExpansion(shill::kMdnProperty, &mdn);
@@ -592,25 +523,6 @@ void PopulateCellularDetails(const NetworkState* cellular,
dictionary->SetString(kTagCarrierUrl, carrier->top_up_url());
}
- base::ListValue* apn_list_value = new base::ListValue();
- const base::ListValue* apn_list;
- if (device_properties.GetListWithoutPathExpansion(
- shill::kCellularApnListProperty, &apn_list)) {
- for (base::ListValue::const_iterator iter = apn_list->begin();
- iter != apn_list->end();
- ++iter) {
- const base::DictionaryValue* dict;
- if ((*iter)->GetAsDictionary(&dict)) {
- base::DictionaryValue* apn = new base::DictionaryValue;
- CreateDictionaryFromCellularApn(dict, apn);
- apn_list_value->Append(apn);
- }
- }
- }
- SetValueDictionary(kTagProviderApnList,
- apn_list_value,
- cellular_property_ui_data,
- dictionary);
const base::ListValue* supported_carriers;
if (device_properties.GetListWithoutPathExpansion(
shill::kSupportedCarriersProperty, &supported_carriers)) {
@@ -626,12 +538,9 @@ void PopulateCellularDetails(const NetworkState* cellular,
}
// Don't show any account management related buttons if the activation
- // state is unknown or no payment portal URL is available.
- std::string support_url;
- if (cellular->activation_state() == shill::kActivationStateUnknown ||
- !dictionary->GetString(kTagSupportUrl, &support_url) ||
- support_url.empty()) {
- VLOG(2) << "No support URL is available. Don't display buttons.";
+ // state is unknown.
+ if (cellular->activation_state() == shill::kActivationStateUnknown) {
+ VLOG(2) << "Activation state unknown. Don't display buttons.";
return;
}
@@ -639,15 +548,11 @@ void PopulateCellularDetails(const NetworkState* cellular,
cellular->activation_state() != shill::kActivationStateActivated) {
dictionary->SetBoolean(kTagShowActivateButton, true);
} else {
- bool may_show_portal_button = false;
-
- // If an online payment URL was provided by shill, then this means that the
- // "View Account" button should be shown for the current carrier.
- if (olp) {
- std::string url;
- olp->GetStringWithoutPathExpansion(shill::kPaymentPortalURL, &url);
- may_show_portal_button = !url.empty();
- }
+ // TODO(stevenjb): Determine if we actually need this check. The payment url
+ // property is commented as 'Deprecated' in service_constants.h and appears
+ // to be unset in Shill, but we still reference it in mobile_setup.cc.
+ bool may_show_portal_button = !cellular->payment_url().empty();
+
// If no online payment URL was provided by shill, fall back to
// MobileConfig to determine if the "View Account" should be shown.
if (!may_show_portal_button && MobileConfig::GetInstance()->IsReady()) {
@@ -721,7 +626,7 @@ scoped_ptr<base::DictionaryValue> PopulateConnectionDetails(
dictionary->SetBoolean(kTagDeviceConnected, connected_network != NULL);
if (type == shill::kTypeCellular)
- PopulateCellularDetails(network, shill_properties, dictionary.get());
+ PopulateCellularDetails(network, dictionary.get());
else if (type == shill::kTypeVPN)
PopulateVPNDetails(network, shill_properties, dictionary.get());
diff --git a/chromeos/network/network_state.cc b/chromeos/network/network_state.cc
index cb451e8..c47068b 100644
--- a/chromeos/network/network_state.cc
+++ b/chromeos/network/network_state.cc
@@ -99,6 +99,12 @@ bool NetworkState::PropertyChanged(const std::string& key,
return GetStringValue(key, value, &activation_state_);
} else if (key == shill::kRoamingStateProperty) {
return GetStringValue(key, value, &roaming_);
+ } else if (key == shill::kPaymentPortalProperty) {
+ const base::DictionaryValue* olp;
+ if (!value.GetAsDictionary(&olp))
+ return false;
+ return olp->GetStringWithoutPathExpansion(shill::kPaymentPortalURL,
+ &payment_url_);
} else if (key == shill::kSecurityProperty) {
return GetStringValue(key, value, &security_);
} else if (key == shill::kEapMethodProperty) {
diff --git a/chromeos/network/network_state.h b/chromeos/network/network_state.h
index b1a491b..5098389 100644
--- a/chromeos/network/network_state.h
+++ b/chromeos/network/network_state.h
@@ -87,6 +87,7 @@ class CHROMEOS_EXPORT NetworkState : public ManagedState {
const std::string& activation_type() const { return activation_type_; }
const std::string& activation_state() const { return activation_state_; }
const std::string& roaming() const { return roaming_; }
+ const std::string& payment_url() const { return payment_url_; }
bool cellular_out_of_credits() const { return cellular_out_of_credits_; }
// Whether this network has a CACertNSS nickname set.
@@ -169,6 +170,7 @@ class CHROMEOS_EXPORT NetworkState : public ManagedState {
std::string activation_type_;
std::string activation_state_;
std::string roaming_;
+ std::string payment_url_;
bool cellular_out_of_credits_;
// Whether a deprecated CaCertNSS property of this network is set. Required
diff --git a/chromeos/network/onc/onc_signature.cc b/chromeos/network/onc/onc_signature.cc
index 2b750fb..6b85eab 100644
--- a/chromeos/network/onc/onc_signature.cc
+++ b/chromeos/network/onc/onc_signature.cc
@@ -223,6 +223,7 @@ const OncFieldSignature cellular_provider_fields[] = {
{NULL}};
const OncFieldSignature cellular_apn_fields[] = {
+ { ::onc::cellular_apn::kAccessPointName, &kStringSignature},
{ ::onc::cellular_apn::kName, &kStringSignature},
{ ::onc::cellular_apn::kUsername, &kStringSignature},
{ ::onc::cellular_apn::kPassword, &kStringSignature},
@@ -264,6 +265,7 @@ const OncFieldSignature cellular_with_state_fields[] = {
{ ::onc::cellular::kICCID, &kStringSignature},
{ ::onc::cellular::kIMEI, &kStringSignature},
{ ::onc::cellular::kIMSI, &kStringSignature},
+ { ::onc::cellular::kLastGoodAPN, &kCellularApnSignature },
{ ::onc::cellular::kManufacturer, &kStringSignature},
{ ::onc::cellular::kMDN, &kStringSignature},
{ ::onc::cellular::kMEID, &kStringSignature},
diff --git a/chromeos/network/onc/onc_translation_tables.cc b/chromeos/network/onc/onc_translation_tables.cc
index 3cf512c..b538145 100644
--- a/chromeos/network/onc/onc_translation_tables.cc
+++ b/chromeos/network/onc/onc_translation_tables.cc
@@ -120,7 +120,8 @@ const FieldTranslationEntry wifi_fields[] = {
{NULL}};
const FieldTranslationEntry cellular_apn_fields[] = {
- { ::onc::cellular_apn::kName, shill::kApnProperty},
+ { ::onc::cellular_apn::kAccessPointName, shill::kApnProperty},
+ { ::onc::cellular_apn::kName, shill::kApnNameProperty},
{ ::onc::cellular_apn::kUsername, shill::kApnUsernameProperty},
{ ::onc::cellular_apn::kPassword, shill::kApnPasswordProperty},
{ ::onc::cellular_apn::kLocalizedName, shill::kApnLocalizedNameProperty},
diff --git a/chromeos/network/onc/onc_translator_shill_to_onc.cc b/chromeos/network/onc/onc_translator_shill_to_onc.cc
index 224e26c..1b1ba70 100644
--- a/chromeos/network/onc/onc_translator_shill_to_onc.cc
+++ b/chromeos/network/onc/onc_translator_shill_to_onc.cc
@@ -309,6 +309,10 @@ void ShillToONCTranslator::TranslateCellularWithState() {
shill::kCellularApnProperty, &dictionary)) {
TranslateAndAddNestedObject(::onc::cellular::kAPN, *dictionary);
}
+ if (shill_dictionary_->GetDictionaryWithoutPathExpansion(
+ shill::kCellularLastGoodApnProperty, &dictionary)) {
+ TranslateAndAddNestedObject(::onc::cellular::kLastGoodAPN, *dictionary);
+ }
// Merge the Device dictionary with this one (Cellular) using the
// CellularDevice signature.
const base::DictionaryValue* device_dictionary = NULL;
diff --git a/chromeos/test/data/network/cellular.onc b/chromeos/test/data/network/cellular.onc
index 582d594..4c76e3fe 100644
--- a/chromeos/test/data/network/cellular.onc
+++ b/chromeos/test/data/network/cellular.onc
@@ -3,7 +3,7 @@
"Name": "Test Network",
"Cellular": {
"APN": {
- "Name": "test-apn",
+ "AccessPointName": "test-apn",
"Username": "test-username",
"Password": "test-password"
}
diff --git a/chromeos/test/data/network/translation_of_shill_cellular_with_state.onc b/chromeos/test/data/network/translation_of_shill_cellular_with_state.onc
index d7d6b33..e57d057 100644
--- a/chromeos/test/data/network/translation_of_shill_cellular_with_state.onc
+++ b/chromeos/test/data/network/translation_of_shill_cellular_with_state.onc
@@ -15,24 +15,25 @@
"Name": "test-name"
},
"APN": {
- "Name": "test-apn",
+ "AccessPointName": "test-apn",
+ "Name": "test-apn-name",
"Username": "test-username",
"Password": "test-password"
},
"APNList": [ {
- "Name": "test-apn0",
+ "AccessPointName": "test-apn0",
"Password": "test-password0",
"Username": "test-username0"
}, {
- "Name": "test-apn1",
+ "AccessPointName": "test-apn1",
"Password": "test-password1",
"Username": "test-username1"
}, {
- "Name": "test-apn2",
+ "AccessPointName": "test-apn2",
"Password": "test-password2",
"Username": "test-username2"
}, {
- "Name": "test-apn3",
+ "AccessPointName": "test-apn3",
"Password": "test-password3",
"Username": "test-username3"
}
diff --git a/components/onc/onc_constants.cc b/components/onc/onc_constants.cc
index 4909aed..b7748b6 100644
--- a/components/onc/onc_constants.cc
+++ b/components/onc/onc_constants.cc
@@ -91,6 +91,7 @@ const char kHomeProvider[] = "HomeProvider";
const char kICCID[] = "ICCID";
const char kIMEI[] = "IMEI";
const char kIMSI[] = "IMSI";
+const char kLastGoodAPN[] = "LastGoodAPN";
const char kManufacturer[] = "Manufacturer";
const char kMDN[] = "MDN";
const char kMEID[] = "MEID";
@@ -115,6 +116,7 @@ const char kName[] = "Name";
} // namespace cellular_provider
namespace cellular_apn {
+const char kAccessPointName[] = "AccessPointName";
const char kName[] = "Name";
const char kUsername[] = "Username";
const char kPassword[] = "Password";
diff --git a/components/onc/onc_constants.h b/components/onc/onc_constants.h
index 371570c..3cea77f 100644
--- a/components/onc/onc_constants.h
+++ b/components/onc/onc_constants.h
@@ -108,6 +108,7 @@ ONC_EXPORT extern const char kHomeProvider[];
ONC_EXPORT extern const char kICCID[];
ONC_EXPORT extern const char kIMEI[];
ONC_EXPORT extern const char kIMSI[];
+ONC_EXPORT extern const char kLastGoodAPN[];
ONC_EXPORT extern const char kManufacturer[];
ONC_EXPORT extern const char kMDN[];
ONC_EXPORT extern const char kMEID[];
@@ -132,6 +133,7 @@ ONC_EXPORT extern const char kName[];
} // namespace cellular_provider
namespace cellular_apn {
+ONC_EXPORT extern const char kAccessPointName[];
ONC_EXPORT extern const char kName[];
ONC_EXPORT extern const char kUsername[];
ONC_EXPORT extern const char kPassword[];