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 d918156dfffa41db1d929970196669690b4d00fa..6ea4d09e8e34e7d7ab4f0f7bacd1de16948d5d49 100644 |
--- a/chromeos/network/onc/onc_translator_shill_to_onc.cc |
+++ b/chromeos/network/onc/onc_translator_shill_to_onc.cc |
@@ -12,8 +12,10 @@ |
#include "base/logging.h" |
#include "base/strings/string_util.h" |
#include "base/values.h" |
+#include "chromeos/network/network_handler.h" |
#include "chromeos/network/network_profile_handler.h" |
#include "chromeos/network/network_state.h" |
+#include "chromeos/network/network_state_handler.h" |
#include "chromeos/network/network_util.h" |
#include "chromeos/network/onc/onc_signature.h" |
#include "chromeos/network/onc/onc_translation_tables.h" |
@@ -44,6 +46,14 @@ scoped_ptr<base::Value> ConvertStringToValue(const std::string& str, |
return make_scoped_ptr(value); |
} |
+const NetworkState* GetNetworkStateFromGuid(const std::string& guid) { |
+ if (!NetworkHandler::IsInitialized()) |
pneubeck (no reviews)
2015/04/14 09:32:16
This is not explicit though.
If at all, please pas
|
+ return nullptr; |
+ return NetworkHandler::Get() |
+ ->network_state_handler() |
+ ->GetNetworkStateFromGuid(guid); |
+} |
+ |
// This class implements the translation of properties from the given |
// |shill_dictionary| to a new ONC object of signature |onc_signature|. Using |
// recursive calls to CreateTranslatedONCObject of new instances, nested objects |
@@ -474,6 +484,19 @@ void ShillToONCTranslator::TranslateNetworkWithState() { |
} |
} |
+ // 'ErrorState' reflects the most recent error maintained in NetworkState |
+ // (which may not match Shill's Error or PreviousError properties). Non |
+ // visible networks (with no NetworkState) do not set ErrorState. |
+ std::string guid; |
+ if (shill_dictionary_->GetStringWithoutPathExpansion(shill::kGuidProperty, |
+ &guid)) { |
+ const NetworkState* network_state = GetNetworkStateFromGuid(guid); |
+ if (network_state) { |
+ onc_object_->SetStringWithoutPathExpansion( |
+ ::onc::network_config::kErrorState, network_state->GetErrorState()); |
+ } |
+ } |
+ |
std::string profile_path; |
if (onc_source_ != ::onc::ONC_SOURCE_UNKNOWN && |
shill_dictionary_->GetStringWithoutPathExpansion(shill::kProfileProperty, |