Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2714)

Unified Diff: chrome/browser/chromeos/cros/onc_network_parser.cc

Issue 8734013: Resubmit CL. See 8429004. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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"
@@ -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::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,
@@ -353,7 +367,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::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 +401,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 +428,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::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::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: {

Powered by Google App Engine
This is Rietveld 408576698