| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chromeos/network/network_util.h" | 5 #include "chromeos/network/network_util.h" |
| 6 | 6 |
| 7 #include "base/strings/string_tokenizer.h" | 7 #include "base/strings/string_tokenizer.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "chromeos/login/login_state.h" | 10 #include "chromeos/login/login_state.h" |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 onc_dictionary->SetBoolean("visible", state->visible()); | 203 onc_dictionary->SetBoolean("visible", state->visible()); |
| 204 onc_dictionary->SetString("profile_path", state->profile_path()); | 204 onc_dictionary->SetString("profile_path", state->profile_path()); |
| 205 onc_dictionary->SetString("service_path", state->path()); | 205 onc_dictionary->SetString("service_path", state->path()); |
| 206 } | 206 } |
| 207 | 207 |
| 208 network_properties_list->Append(onc_dictionary.release()); | 208 network_properties_list->Append(onc_dictionary.release()); |
| 209 } | 209 } |
| 210 return network_properties_list.Pass(); | 210 return network_properties_list.Pass(); |
| 211 } | 211 } |
| 212 | 212 |
| 213 scoped_ptr<base::DictionaryValue> TranslateShillPropertiesToONC( |
| 214 const std::string& service_path, |
| 215 const base::DictionaryValue& shill_properties, |
| 216 ::onc::ONCSource onc_source) { |
| 217 scoped_ptr<base::DictionaryValue> shill_dictionary( |
| 218 shill_properties.DeepCopy()); |
| 219 // Shill's 'Error' property is transient. Use NetworkState::GetErrorState() |
| 220 // instead. |
| 221 const NetworkState* network_state = |
| 222 NetworkHandler::Get()->network_state_handler()->GetNetworkState( |
| 223 service_path); |
| 224 if (network_state) { |
| 225 std::string error_state = network_state->GetErrorState(); |
| 226 shill_dictionary->SetStringWithoutPathExpansion(shill::kErrorProperty, |
| 227 error_state); |
| 228 } |
| 229 return TranslateShillServiceToONCPart(*shill_dictionary, onc_source, |
| 230 &onc::kNetworkWithStateSignature); |
| 231 } |
| 232 |
| 213 std::string TranslateONCTypeToShill(const std::string& onc_type) { | 233 std::string TranslateONCTypeToShill(const std::string& onc_type) { |
| 214 if (onc_type == ::onc::network_type::kEthernet) | 234 if (onc_type == ::onc::network_type::kEthernet) |
| 215 return shill::kTypeEthernet; | 235 return shill::kTypeEthernet; |
| 216 std::string shill_type; | 236 std::string shill_type; |
| 217 onc::TranslateStringToShill(onc::kNetworkTypeTable, onc_type, &shill_type); | 237 onc::TranslateStringToShill(onc::kNetworkTypeTable, onc_type, &shill_type); |
| 218 return shill_type; | 238 return shill_type; |
| 219 } | 239 } |
| 220 | 240 |
| 221 std::string TranslateShillTypeToONC(const std::string& shill_type) { | 241 std::string TranslateShillTypeToONC(const std::string& shill_type) { |
| 222 if (shill_type == shill::kTypeEthernet) | 242 if (shill_type == shill::kTypeEthernet) |
| 223 return ::onc::network_type::kEthernet; | 243 return ::onc::network_type::kEthernet; |
| 224 std::string onc_type; | 244 std::string onc_type; |
| 225 onc::TranslateStringToONC(onc::kNetworkTypeTable, shill_type, &onc_type); | 245 onc::TranslateStringToONC(onc::kNetworkTypeTable, shill_type, &onc_type); |
| 226 return onc_type; | 246 return onc_type; |
| 227 } | 247 } |
| 228 | 248 |
| 229 } // namespace network_util | 249 } // namespace network_util |
| 230 } // namespace chromeos | 250 } // namespace chromeos |
| OLD | NEW |