| Index: chrome/browser/chromeos/cros/onc_network_parser.cc
|
| ===================================================================
|
| --- chrome/browser/chromeos/cros/onc_network_parser.cc (revision 112004)
|
| +++ chrome/browser/chromeos/cros/onc_network_parser.cc (working copy)
|
| @@ -9,6 +9,7 @@
|
| #include "base/stringprintf.h"
|
| #include "base/values.h"
|
| #include "chrome/browser/chromeos/cros/native_network_constants.h"
|
| +#include "chrome/browser/chromeos/cros/native_network_parser.h"
|
| #include "chrome/browser/chromeos/cros/network_library.h"
|
| #include "net/base/cert_database.h"
|
| #include "net/base/crypto_module.h"
|
| @@ -27,7 +28,7 @@
|
| { "Remove", PROPERTY_INDEX_REMOVE },
|
| { "ProxyURL", PROPERTY_INDEX_PROXY_CONFIG },
|
| { "Type", PROPERTY_INDEX_TYPE },
|
| - { "SSID", PROPERTY_INDEX_NAME },
|
| + { "SSID", PROPERTY_INDEX_SSID },
|
| { "Passphrase", PROPERTY_INDEX_PASSPHRASE },
|
| { "AutoConnect", PROPERTY_INDEX_AUTO_CONNECT },
|
| { "HiddenSSID", PROPERTY_INDEX_HIDDEN_SSID },
|
| @@ -149,7 +150,6 @@
|
| }
|
|
|
| Network* OncNetworkParser::ParseNetwork(int n) {
|
| - // TODO(chocobo): Change this to parse network into a dictionary.
|
| if (!network_configs_)
|
| return NULL;
|
| DictionaryValue* info = NULL;
|
| @@ -166,6 +166,10 @@
|
| if (type == TYPE_UNKNOWN) // Return NULL if cannot parse network type.
|
| return NULL;
|
| scoped_ptr<Network> network(CreateNewNetwork(type, service_path));
|
| + // Update property with native value for type.
|
| + std::string str = NativeNetworkParser::network_type_mapper()->GetKey(type);
|
| + scoped_ptr<StringValue> val(Value::CreateStringValue(str));
|
| + network->UpdatePropertyMap(PROPERTY_INDEX_TYPE, *val.get());
|
|
|
| // Get the child dictionary with properties for the network.
|
| // And copy all the values from this network type dictionary to parent.
|
| @@ -173,6 +177,9 @@
|
| if (!info.GetDictionary(GetTypeFromDictionary(info), &dict))
|
| return NULL;
|
|
|
| + // Add GUID from the parent dictionary.
|
| + dict->SetString("GUID", GetGuidFromDictionary(info));
|
| +
|
| UpdateNetworkFromInfo(*dict, network.get());
|
| VLOG(2) << "Created Network '" << network->name()
|
| << "' from info. Path:" << service_path
|
| @@ -208,6 +215,13 @@
|
| return type_string;
|
| }
|
|
|
| +std::string OncNetworkParser::GetGuidFromDictionary(
|
| + const base::DictionaryValue& info) {
|
| + std::string guid_string;
|
| + info.GetString("GUID", &guid_string);
|
| + return guid_string;
|
| +}
|
| +
|
| bool OncNetworkParser::ParseServerOrCaCertificate(
|
| int cert_index,
|
| const std::string& cert_type,
|
| @@ -339,8 +353,12 @@
|
| DCHECK_EQ(TYPE_WIFI, network->type());
|
| WifiNetwork* wifi_network = static_cast<WifiNetwork*>(network);
|
| switch (index) {
|
| - case PROPERTY_INDEX_NAME: {
|
| - return OncWirelessNetworkParser::ParseValue(index, value, network);
|
| + case PROPERTY_INDEX_SSID: {
|
| + std::string ssid;
|
| + if (!value.GetAsString(&ssid))
|
| + break;
|
| + wifi_network->SetName(ssid);
|
| + return true;
|
| }
|
| case PROPERTY_INDEX_GUID: {
|
| std::string unique_id;
|
| @@ -353,7 +371,13 @@
|
| std::string security_string;
|
| if (!value.GetAsString(&security_string))
|
| break;
|
| - wifi_network->set_encryption(ParseSecurity(security_string));
|
| + ConnectionSecurity security = ParseSecurity(security_string);
|
| + wifi_network->set_encryption(security);
|
| + // Also update property with native value for security.
|
| + std::string str =
|
| + NativeNetworkParser::network_security_mapper()->GetKey(security);
|
| + scoped_ptr<StringValue> val(Value::CreateStringValue(str));
|
| + wifi_network->UpdatePropertyMap(index, *val.get());
|
| return true;
|
| }
|
| case PROPERTY_INDEX_PASSPHRASE: {
|
| @@ -381,6 +405,7 @@
|
| DCHECK(res);
|
| if (res) {
|
| PropertyIndex index = mapper().Get(key);
|
| + wifi_network->UpdatePropertyMap(index, *eap_value);
|
| if (!ParseEAPValue(index, *eap_value, wifi_network))
|
| VLOG(1) << network->name() << ": EAP unhandled key: " << key
|
| << " Type: " << eap_value->GetType();
|
| @@ -407,17 +432,29 @@
|
| return true;
|
| }
|
| case PROPERTY_INDEX_EAP_METHOD: {
|
| - std::string eap_method;
|
| - if (!value.GetAsString(&eap_method))
|
| + std::string eap_method_str;
|
| + if (!value.GetAsString(&eap_method_str))
|
| break;
|
| - wifi_network->set_eap_method(ParseEAPMethod(eap_method));
|
| + EAPMethod eap_method = ParseEAPMethod(eap_method_str);
|
| + wifi_network->set_eap_method(eap_method);
|
| + // Also update property with native value for EAP method.
|
| + std::string str =
|
| + NativeNetworkParser::network_eap_method_mapper()->GetKey(eap_method);
|
| + scoped_ptr<StringValue> val(Value::CreateStringValue(str));
|
| + wifi_network->UpdatePropertyMap(index, *val.get());
|
| return true;
|
| }
|
| case PROPERTY_INDEX_EAP_PHASE_2_AUTH: {
|
| - std::string eap_phase_2_auth;
|
| - if (!value.GetAsString(&eap_phase_2_auth))
|
| + std::string eap_phase_2_auth_str;
|
| + if (!value.GetAsString(&eap_phase_2_auth_str))
|
| break;
|
| - wifi_network->set_eap_phase_2_auth(ParseEAPPhase2Auth(eap_phase_2_auth));
|
| + EAPPhase2Auth eap_phase_2_auth = ParseEAPPhase2Auth(eap_phase_2_auth_str);
|
| + wifi_network->set_eap_phase_2_auth(eap_phase_2_auth);
|
| + // Also update property with native value for EAP phase 2 auth.
|
| + std::string str = NativeNetworkParser::network_eap_auth_mapper()->GetKey(
|
| + eap_phase_2_auth);
|
| + scoped_ptr<StringValue> val(Value::CreateStringValue(str));
|
| + wifi_network->UpdatePropertyMap(index, *val.get());
|
| return true;
|
| }
|
| case PROPERTY_INDEX_EAP_ANONYMOUS_IDENTITY: {
|
|
|