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_state.h" | 5 #include "chromeos/network/network_state.h" |
6 | 6 |
7 #include "base/i18n/icu_encoding_detection.h" | 7 #include "base/i18n/icu_encoding_detection.h" |
8 #include "base/i18n/icu_string_conversions.h" | 8 #include "base/i18n/icu_string_conversions.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
13 #include "base/strings/utf_string_conversion_utils.h" | 13 #include "base/strings/utf_string_conversion_utils.h" |
14 #include "chromeos/network/network_event_log.h" | 14 #include "chromeos/network/network_event_log.h" |
15 #include "chromeos/network/network_profile_handler.h" | 15 #include "chromeos/network/network_profile_handler.h" |
16 #include "chromeos/network/network_util.h" | 16 #include "chromeos/network/network_util.h" |
17 #include "chromeos/network/onc/onc_utils.h" | 17 #include "chromeos/network/onc/onc_utils.h" |
18 #include "third_party/cros_system_api/dbus/service_constants.h" | 18 #include "third_party/cros_system_api/dbus/service_constants.h" |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
| 22 const char kErrorUnknown[] = "Unknown"; |
| 23 |
22 bool ConvertListValueToStringVector(const base::ListValue& string_list, | 24 bool ConvertListValueToStringVector(const base::ListValue& string_list, |
23 std::vector<std::string>* result) { | 25 std::vector<std::string>* result) { |
24 for (size_t i = 0; i < string_list.GetSize(); ++i) { | 26 for (size_t i = 0; i < string_list.GetSize(); ++i) { |
25 std::string str; | 27 std::string str; |
26 if (!string_list.GetString(i, &str)) | 28 if (!string_list.GetString(i, &str)) |
27 return false; | 29 return false; |
28 result->push_back(str); | 30 result->push_back(str); |
29 } | 31 } |
30 return true; | 32 return true; |
31 } | 33 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 // Keep care that these properties are the same as in |GetProperties|. | 104 // Keep care that these properties are the same as in |GetProperties|. |
103 if (ManagedStatePropertyChanged(key, value)) | 105 if (ManagedStatePropertyChanged(key, value)) |
104 return true; | 106 return true; |
105 if (key == flimflam::kSignalStrengthProperty) { | 107 if (key == flimflam::kSignalStrengthProperty) { |
106 return GetIntegerValue(key, value, &signal_strength_); | 108 return GetIntegerValue(key, value, &signal_strength_); |
107 } else if (key == flimflam::kStateProperty) { | 109 } else if (key == flimflam::kStateProperty) { |
108 return GetStringValue(key, value, &connection_state_); | 110 return GetStringValue(key, value, &connection_state_); |
109 } else if (key == flimflam::kConnectableProperty) { | 111 } else if (key == flimflam::kConnectableProperty) { |
110 return GetBooleanValue(key, value, &connectable_); | 112 return GetBooleanValue(key, value, &connectable_); |
111 } else if (key == flimflam::kErrorProperty) { | 113 } else if (key == flimflam::kErrorProperty) { |
112 return GetStringValue(key, value, &error_); | 114 if (!GetStringValue(key, value, &error_)) |
| 115 return false; |
| 116 // Shill uses "Unknown" to indicate an unset error state. |
| 117 if (error_ == kErrorUnknown) |
| 118 error_.clear(); |
| 119 return true; |
113 } else if (key == shill::kErrorDetailsProperty) { | 120 } else if (key == shill::kErrorDetailsProperty) { |
114 return GetStringValue(key, value, &error_details_); | 121 return GetStringValue(key, value, &error_details_); |
115 } else if (key == IPConfigProperty(flimflam::kAddressProperty)) { | 122 } else if (key == IPConfigProperty(flimflam::kAddressProperty)) { |
116 return GetStringValue(key, value, &ip_address_); | 123 return GetStringValue(key, value, &ip_address_); |
117 } else if (key == IPConfigProperty(flimflam::kGatewayProperty)) { | 124 } else if (key == IPConfigProperty(flimflam::kGatewayProperty)) { |
118 return GetStringValue(key, value, &gateway_); | 125 return GetStringValue(key, value, &gateway_); |
119 } else if (key == IPConfigProperty(flimflam::kNameServersProperty)) { | 126 } else if (key == IPConfigProperty(flimflam::kNameServersProperty)) { |
120 const base::ListValue* dns_servers; | 127 const base::ListValue* dns_servers; |
121 if (!value.GetAsList(&dns_servers)) | 128 if (!value.GetAsList(&dns_servers)) |
122 return false; | 129 return false; |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 } | 431 } |
425 scoped_ptr<base::DictionaryValue> ui_data_dict( | 432 scoped_ptr<base::DictionaryValue> ui_data_dict( |
426 chromeos::onc::ReadDictionaryFromJson(ui_data_str)); | 433 chromeos::onc::ReadDictionaryFromJson(ui_data_str)); |
427 if (!ui_data_dict) | 434 if (!ui_data_dict) |
428 return false; | 435 return false; |
429 *out = NetworkUIData(*ui_data_dict); | 436 *out = NetworkUIData(*ui_data_dict); |
430 return true; | 437 return true; |
431 } | 438 } |
432 | 439 |
433 } // namespace chromeos | 440 } // namespace chromeos |
OLD | NEW |