Chromium Code Reviews| Index: chromeos/network/onc/onc_translator_shill_to_onc.cc |
| diff --git a/chromeos/network/onc/onc_translator_shill_to_onc.cc b/chromeos/network/onc/onc_translator_shill_to_onc.cc |
| index 7b0fb9ec974a350122c1465f61acd556703a41ac..e0d77da0a582891c12c4d09c0bd44a7ebc5b3348 100644 |
| --- a/chromeos/network/onc/onc_translator_shill_to_onc.cc |
| +++ b/chromeos/network/onc/onc_translator_shill_to_onc.cc |
| @@ -115,6 +115,12 @@ class ShillToONCTranslator { |
| // entry from |shill_dictionary_| to |onc_object_| if it exists. |
| void CopyProperty(const OncFieldSignature* field_signature); |
|
armansito
2014/09/03 21:45:02
Can you include the new fields below in the unit t
stevenjb
2014/09/08 18:14:11
Addressed in a separate CL.
|
| + // If |shill_property_name| exists in |shill_dictionary_|, copy it to |
| + // |onc_field_name| in |dictionary|. |
| + void CopyPropertyToDictionary(const std::string& shill_property_name, |
| + const std::string& onc_field_name, |
| + base::DictionaryValue* dictionary); |
| + |
| // If existent, translates the entry at |shill_property_name| in |
| // |shill_dictionary_| using |table|. It is an error if no matching table |
| // entry is found. Writes the result as entry at |onc_field_name| in |
| @@ -424,6 +430,43 @@ void ShillToONCTranslator::TranslateNetworkWithState() { |
| TranslateAndAddListOfObjects(::onc::network_config::kIPConfigs, |
| *shill_ipconfigs); |
| } |
| + |
| + // Convert StaticIP and SavedIP properties to dictionary format. |
| + scoped_ptr<base::DictionaryValue> static_ip(new base::DictionaryValue); |
| + CopyPropertyToDictionary(shill::kStaticIPAddressProperty, |
| + ::onc::ipconfig::kIPAddress, |
| + static_ip.get()); |
| + CopyPropertyToDictionary(shill::kStaticIPGatewayProperty, |
| + ::onc::ipconfig::kGateway, |
| + static_ip.get()); |
| + CopyPropertyToDictionary(shill::kStaticIPNameServersProperty, |
| + ::onc::ipconfig::kNameServers, |
| + static_ip.get()); |
| + CopyPropertyToDictionary(shill::kStaticIPPrefixlenProperty, |
| + ::onc::ipconfig::kRoutingPrefix, |
| + static_ip.get()); |
| + if (!static_ip->empty()) { |
| + onc_object_->SetWithoutPathExpansion(::onc::network_config::kStaticIPConfig, |
| + static_ip.release()); |
| + } |
| + |
| + scoped_ptr<base::DictionaryValue> saved_ip(new base::DictionaryValue); |
| + CopyPropertyToDictionary(shill::kSavedIPAddressProperty, |
| + ::onc::ipconfig::kIPAddress, |
| + saved_ip.get()); |
| + CopyPropertyToDictionary(shill::kSavedIPGatewayProperty, |
| + ::onc::ipconfig::kGateway, |
| + saved_ip.get()); |
| + CopyPropertyToDictionary(shill::kSavedIPNameServersProperty, |
| + ::onc::ipconfig::kNameServers, |
| + saved_ip.get()); |
| + CopyPropertyToDictionary(shill::kSavedIPPrefixlenProperty, |
| + ::onc::ipconfig::kRoutingPrefix, |
| + saved_ip.get()); |
| + if (!saved_ip->empty()) { |
| + onc_object_->SetWithoutPathExpansion(::onc::network_config::kSavedIPConfig, |
| + saved_ip.release()); |
| + } |
| } |
| void ShillToONCTranslator::TranslateIPConfig() { |
| @@ -557,6 +600,19 @@ void ShillToONCTranslator::CopyProperty( |
| shill_value->DeepCopy()); |
| } |
| +void ShillToONCTranslator::CopyPropertyToDictionary( |
| + const std::string& shill_property_name, |
| + const std::string& onc_field_name, |
| + base::DictionaryValue* dictionary) { |
| + const base::Value* shill_value; |
| + if (!shill_dictionary_->GetWithoutPathExpansion(shill_property_name, |
| + &shill_value)) { |
| + return; |
| + } |
| + dictionary->SetWithoutPathExpansion(onc_field_name, |
| + shill_value->DeepCopy()); |
| +} |
| + |
| void ShillToONCTranslator::TranslateWithTableAndSet( |
| const std::string& shill_property_name, |
| const StringTranslationEntry table[], |