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_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "base/strings/string_tokenizer.h" | 8 #include "base/strings/string_tokenizer.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "chromeos/login/login_state.h" | 10 #include "chromeos/login/login_state.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 scoped_ptr<base::DictionaryValue> onc_dictionary = | 180 scoped_ptr<base::DictionaryValue> onc_dictionary = |
181 TranslateShillServiceToONCPart(*shill_dictionary, onc_source, | 181 TranslateShillServiceToONCPart(*shill_dictionary, onc_source, |
182 &onc::kNetworkWithStateSignature, network); | 182 &onc::kNetworkWithStateSignature, network); |
183 return onc_dictionary.Pass(); | 183 return onc_dictionary.Pass(); |
184 } | 184 } |
185 | 185 |
186 scoped_ptr<base::ListValue> TranslateNetworkListToONC( | 186 scoped_ptr<base::ListValue> TranslateNetworkListToONC( |
187 NetworkTypePattern pattern, | 187 NetworkTypePattern pattern, |
188 bool configured_only, | 188 bool configured_only, |
189 bool visible_only, | 189 bool visible_only, |
190 int limit, | 190 int limit) { |
191 bool debugging_properties) { | |
192 NetworkStateHandler::NetworkStateList network_states; | 191 NetworkStateHandler::NetworkStateList network_states; |
193 NetworkHandler::Get()->network_state_handler()->GetNetworkListByType( | 192 NetworkHandler::Get()->network_state_handler()->GetNetworkListByType( |
194 pattern, configured_only, visible_only, limit, &network_states); | 193 pattern, configured_only, visible_only, limit, &network_states); |
195 | 194 |
196 scoped_ptr<base::ListValue> network_properties_list(new base::ListValue); | 195 scoped_ptr<base::ListValue> network_properties_list(new base::ListValue); |
197 for (const NetworkState* state : network_states) { | 196 for (const NetworkState* state : network_states) { |
198 scoped_ptr<base::DictionaryValue> onc_dictionary = | 197 scoped_ptr<base::DictionaryValue> onc_dictionary = |
199 TranslateNetworkStateToONC(state); | 198 TranslateNetworkStateToONC(state); |
200 | |
201 if (debugging_properties) { | |
202 onc_dictionary->SetBoolean("connectable", state->connectable()); | |
203 onc_dictionary->SetBoolean("visible", state->visible()); | |
204 onc_dictionary->SetString("profile_path", state->profile_path()); | |
205 onc_dictionary->SetString("service_path", state->path()); | |
206 } | |
207 | |
208 network_properties_list->Append(onc_dictionary.release()); | 199 network_properties_list->Append(onc_dictionary.release()); |
209 } | 200 } |
210 return network_properties_list.Pass(); | 201 return network_properties_list.Pass(); |
211 } | 202 } |
212 | 203 |
213 std::string TranslateONCTypeToShill(const std::string& onc_type) { | 204 std::string TranslateONCTypeToShill(const std::string& onc_type) { |
214 if (onc_type == ::onc::network_type::kEthernet) | 205 if (onc_type == ::onc::network_type::kEthernet) |
215 return shill::kTypeEthernet; | 206 return shill::kTypeEthernet; |
216 std::string shill_type; | 207 std::string shill_type; |
217 onc::TranslateStringToShill(onc::kNetworkTypeTable, onc_type, &shill_type); | 208 onc::TranslateStringToShill(onc::kNetworkTypeTable, onc_type, &shill_type); |
218 return shill_type; | 209 return shill_type; |
219 } | 210 } |
220 | 211 |
221 std::string TranslateShillTypeToONC(const std::string& shill_type) { | 212 std::string TranslateShillTypeToONC(const std::string& shill_type) { |
222 if (shill_type == shill::kTypeEthernet) | 213 if (shill_type == shill::kTypeEthernet) |
223 return ::onc::network_type::kEthernet; | 214 return ::onc::network_type::kEthernet; |
224 std::string onc_type; | 215 std::string onc_type; |
225 onc::TranslateStringToONC(onc::kNetworkTypeTable, shill_type, &onc_type); | 216 onc::TranslateStringToONC(onc::kNetworkTypeTable, shill_type, &onc_type); |
226 return onc_type; | 217 return onc_type; |
227 } | 218 } |
228 | 219 |
229 } // namespace network_util | 220 } // namespace network_util |
230 } // namespace chromeos | 221 } // namespace chromeos |
OLD | NEW |