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 7796c2afcbd8b6844e21718cede425c699a1dcd9..fc9712999257f72e9a88eb165dfef597ed3dc6db 100644 |
| --- a/chromeos/network/onc/onc_translator_shill_to_onc.cc |
| +++ b/chromeos/network/onc/onc_translator_shill_to_onc.cc |
| @@ -136,6 +136,12 @@ class ShillToONCTranslator { |
| const StringTranslationEntry table[], |
| const std::string& onc_field_name); |
| + // Same as above but for nested properties. |
| + bool TranslateWithTableAndSetNested(const std::string& shill_property_name, |
| + const StringTranslationEntry table[], |
| + const std::string& onc_dictionary_name, |
| + const std::string& onc_field_name); |
| + |
| // Returns the name of the Shill service provided in |shill_dictionary_| |
| // for debugging. |
| std::string GetName(); |
| @@ -359,6 +365,20 @@ void ShillToONCTranslator::TranslateWiFiWithState() { |
| CopyPropertiesAccordingToSignature(); |
| TranslateAndAddNestedObject(::onc::wifi::kEAP); |
| + |
| + // Translate EAP Outer and Inner values. Note: Shill provides an empty |
| + // EAP property for non EAP networks, so check that before appmpting to |
| + // translate. |
| + std::string eap; |
|
tbarzic
2017/05/01 18:05:56
Could this be done as part of TranslateAndAddNeste
stevenjb
2017/05/01 20:12:04
Yes, thanks, I've been out of this code for too lo
|
| + shill_dictionary_->GetStringWithoutPathExpansion(shill::kEapMethodProperty, |
| + &eap); |
| + if (!eap.empty() && |
| + TranslateWithTableAndSetNested(shill::kEapMethodProperty, kEAPOuterTable, |
| + ::onc::wifi::kEAP, ::onc::eap::kOuter)) { |
| + TranslateWithTableAndSetNested(shill::kEapPhase2AuthProperty, |
| + kEAP_TTLS_InnerTable, ::onc::wifi::kEAP, |
| + ::onc::eap::kInner); |
| + } |
| } |
| void ShillToONCTranslator::TranslateWiMAXWithState() { |
| @@ -762,6 +782,27 @@ void ShillToONCTranslator::TranslateWithTableAndSet( |
| << shill_value << " couldn't be translated to ONC: " << GetName(); |
| } |
| +bool ShillToONCTranslator::TranslateWithTableAndSetNested( |
| + const std::string& shill_property_name, |
| + const StringTranslationEntry table[], |
| + const std::string& onc_dictionary_name, |
| + const std::string& onc_field_name) { |
| + std::string shill_value; |
| + if (!shill_dictionary_->GetStringWithoutPathExpansion(shill_property_name, |
| + &shill_value)) { |
| + return false; |
| + } |
| + std::string onc_value; |
| + if (TranslateStringToONC(table, shill_value, &onc_value)) { |
| + SetNestedOncValue(onc_dictionary_name, onc_field_name, |
| + base::Value(onc_value)); |
| + return true; |
| + } |
| + LOG(ERROR) << "Shill property '" << shill_property_name << "' with value " |
| + << shill_value << " couldn't be translated to ONC: " << GetName(); |
| + return false; |
| +} |
| + |
| std::string ShillToONCTranslator::GetName() { |
| DCHECK(shill_dictionary_); |
| std::string name; |