Chromium Code Reviews| Index: chromeos/network/network_util.cc | 
| diff --git a/chromeos/network/network_util.cc b/chromeos/network/network_util.cc | 
| index 1d84adf0af02d144b0ff1905bd662488112631ef..92a86f341cddc95725002583840c800e4d515587 100644 | 
| --- a/chromeos/network/network_util.cc | 
| +++ b/chromeos/network/network_util.cc | 
| @@ -7,8 +7,11 @@ | 
| #include "base/strings/string_tokenizer.h" | 
| #include "base/strings/string_util.h" | 
| #include "base/strings/stringprintf.h" | 
| +#include "chromeos/login/login_state.h" | 
| +#include "chromeos/network/managed_network_configuration_handler.h" | 
| #include "chromeos/network/network_state.h" | 
| #include "chromeos/network/network_state_handler.h" | 
| +#include "chromeos/network/network_ui_data.h" | 
| #include "chromeos/network/onc/onc_signature.h" | 
| #include "chromeos/network/onc/onc_translation_tables.h" | 
| #include "chromeos/network/onc/onc_translator.h" | 
| @@ -145,10 +148,22 @@ scoped_ptr<base::DictionaryValue> TranslateNetworkStateToONC( | 
| // Get the properties from the NetworkState. | 
| base::DictionaryValue shill_dictionary; | 
| network->GetStateProperties(&shill_dictionary); | 
| + // Set the Profile property so that Source gets translated. | 
| + shill_dictionary.SetStringWithoutPathExpansion(shill::kProfileProperty, | 
| 
 
pneubeck (no reviews)
2015/02/17 18:00:49
why not adding this in NetworkState::GetStatePrope
 
stevenjb
2015/02/17 18:23:30
Done.
 
 | 
| + network->profile_path()); | 
| + | 
| + // NetworkState is always associated with the primary user profile, regardless | 
| + // of what profile is associated with the page that calls this method. We do | 
| + // not expose any sensitive properties in the resulting dictionary, it is | 
| + // only used to show connection state and icons. | 
| + std::string user_id_hash = chromeos::LoginState::Get()->primary_user_hash(); | 
| + ::onc::ONCSource onc_source; | 
| 
 
pneubeck (no reviews)
2015/02/17 18:00:49
pls initialize explicitly to ONC_SOURCE_NONE to pr
 
stevenjb
2015/02/17 18:23:31
Done.
 
 | 
| + NetworkHandler::Get() | 
| + ->managed_network_configuration_handler() | 
| + ->FindPolicyByGUID(user_id_hash, network->guid(), &onc_source); | 
| scoped_ptr<base::DictionaryValue> onc_dictionary = | 
| - TranslateShillServiceToONCPart(shill_dictionary, | 
| - ::onc::ONC_SOURCE_UNKNOWN, | 
| + TranslateShillServiceToONCPart(shill_dictionary, onc_source, | 
| &onc::kNetworkWithStateSignature); | 
| return onc_dictionary.Pass(); | 
| } | 
| @@ -164,18 +179,15 @@ scoped_ptr<base::ListValue> TranslateNetworkListToONC( | 
| pattern, configured_only, visible_only, limit, &network_states); | 
| scoped_ptr<base::ListValue> network_properties_list(new base::ListValue); | 
| - for (NetworkStateHandler::NetworkStateList::iterator it = | 
| - network_states.begin(); | 
| - it != network_states.end(); | 
| - ++it) { | 
| + for (auto state : network_states) { | 
| 
 
pneubeck (no reviews)
2015/02/17 18:00:49
optional nit: I usually prefer keeping the element
 
stevenjb
2015/02/17 18:23:30
Done.
 
 | 
| scoped_ptr<base::DictionaryValue> onc_dictionary = | 
| - TranslateNetworkStateToONC(*it); | 
| + TranslateNetworkStateToONC(state); | 
| if (debugging_properties) { | 
| - onc_dictionary->SetBoolean("connectable", (*it)->connectable()); | 
| - onc_dictionary->SetBoolean("visible", (*it)->visible()); | 
| - onc_dictionary->SetString("profile_path", (*it)->profile_path()); | 
| - onc_dictionary->SetString("service_path", (*it)->path()); | 
| + onc_dictionary->SetBoolean("connectable", state->connectable()); | 
| + onc_dictionary->SetBoolean("visible", state->visible()); | 
| + onc_dictionary->SetString("profile_path", state->profile_path()); | 
| + onc_dictionary->SetString("service_path", state->path()); | 
| } | 
| network_properties_list->Append(onc_dictionary.release()); |