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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 // only used to show connection state and icons. | 176 // only used to show connection state and icons. |
177 std::string user_id_hash = chromeos::LoginState::Get()->primary_user_hash(); | 177 std::string user_id_hash = chromeos::LoginState::Get()->primary_user_hash(); |
178 ::onc::ONCSource onc_source = ::onc::ONC_SOURCE_NONE; | 178 ::onc::ONCSource onc_source = ::onc::ONC_SOURCE_NONE; |
179 NetworkHandler::Get() | 179 NetworkHandler::Get() |
180 ->managed_network_configuration_handler() | 180 ->managed_network_configuration_handler() |
181 ->FindPolicyByGUID(user_id_hash, network->guid(), &onc_source); | 181 ->FindPolicyByGUID(user_id_hash, network->guid(), &onc_source); |
182 | 182 |
183 scoped_ptr<base::DictionaryValue> onc_dictionary = | 183 scoped_ptr<base::DictionaryValue> onc_dictionary = |
184 TranslateShillServiceToONCPart(*shill_dictionary, onc_source, | 184 TranslateShillServiceToONCPart(*shill_dictionary, onc_source, |
185 &onc::kNetworkWithStateSignature, network); | 185 &onc::kNetworkWithStateSignature, network); |
186 return onc_dictionary.Pass(); | 186 return onc_dictionary; |
187 } | 187 } |
188 | 188 |
189 scoped_ptr<base::ListValue> TranslateNetworkListToONC( | 189 scoped_ptr<base::ListValue> TranslateNetworkListToONC( |
190 NetworkTypePattern pattern, | 190 NetworkTypePattern pattern, |
191 bool configured_only, | 191 bool configured_only, |
192 bool visible_only, | 192 bool visible_only, |
193 int limit) { | 193 int limit) { |
194 NetworkStateHandler::NetworkStateList network_states; | 194 NetworkStateHandler::NetworkStateList network_states; |
195 NetworkHandler::Get()->network_state_handler()->GetNetworkListByType( | 195 NetworkHandler::Get()->network_state_handler()->GetNetworkListByType( |
196 pattern, configured_only, visible_only, limit, &network_states); | 196 pattern, configured_only, visible_only, limit, &network_states); |
197 | 197 |
198 scoped_ptr<base::ListValue> network_properties_list(new base::ListValue); | 198 scoped_ptr<base::ListValue> network_properties_list(new base::ListValue); |
199 for (const NetworkState* state : network_states) { | 199 for (const NetworkState* state : network_states) { |
200 scoped_ptr<base::DictionaryValue> onc_dictionary = | 200 scoped_ptr<base::DictionaryValue> onc_dictionary = |
201 TranslateNetworkStateToONC(state); | 201 TranslateNetworkStateToONC(state); |
202 network_properties_list->Append(onc_dictionary.release()); | 202 network_properties_list->Append(onc_dictionary.release()); |
203 } | 203 } |
204 return network_properties_list.Pass(); | 204 return network_properties_list; |
205 } | 205 } |
206 | 206 |
207 std::string TranslateONCTypeToShill(const std::string& onc_type) { | 207 std::string TranslateONCTypeToShill(const std::string& onc_type) { |
208 if (onc_type == ::onc::network_type::kEthernet) | 208 if (onc_type == ::onc::network_type::kEthernet) |
209 return shill::kTypeEthernet; | 209 return shill::kTypeEthernet; |
210 std::string shill_type; | 210 std::string shill_type; |
211 onc::TranslateStringToShill(onc::kNetworkTypeTable, onc_type, &shill_type); | 211 onc::TranslateStringToShill(onc::kNetworkTypeTable, onc_type, &shill_type); |
212 return shill_type; | 212 return shill_type; |
213 } | 213 } |
214 | 214 |
215 std::string TranslateShillTypeToONC(const std::string& shill_type) { | 215 std::string TranslateShillTypeToONC(const std::string& shill_type) { |
216 if (shill_type == shill::kTypeEthernet) | 216 if (shill_type == shill::kTypeEthernet) |
217 return ::onc::network_type::kEthernet; | 217 return ::onc::network_type::kEthernet; |
218 std::string onc_type; | 218 std::string onc_type; |
219 onc::TranslateStringToONC(onc::kNetworkTypeTable, shill_type, &onc_type); | 219 onc::TranslateStringToONC(onc::kNetworkTypeTable, shill_type, &onc_type); |
220 return onc_type; | 220 return onc_type; |
221 } | 221 } |
222 | 222 |
223 } // namespace network_util | 223 } // namespace network_util |
224 } // namespace chromeos | 224 } // namespace chromeos |
OLD | NEW |