| 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" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 : ManagedState(MANAGED_TYPE_NETWORK, path), | 59 : ManagedState(MANAGED_TYPE_NETWORK, path), |
| 60 auto_connect_(false), | 60 auto_connect_(false), |
| 61 favorite_(false), | 61 favorite_(false), |
| 62 priority_(0), | 62 priority_(0), |
| 63 onc_source_(onc::ONC_SOURCE_NONE), | 63 onc_source_(onc::ONC_SOURCE_NONE), |
| 64 prefix_length_(0), | 64 prefix_length_(0), |
| 65 signal_strength_(0), | 65 signal_strength_(0), |
| 66 connectable_(false), | 66 connectable_(false), |
| 67 passphrase_required_(false), | 67 passphrase_required_(false), |
| 68 activate_over_non_cellular_networks_(false), | 68 activate_over_non_cellular_networks_(false), |
| 69 cellular_out_of_credits_(false) { | 69 cellular_out_of_credits_(false), |
| 70 has_eap_ca_cert_nss_(false), |
| 71 has_ipsec_ca_cert_nss_(false), |
| 72 has_openvpn_ca_cert_nss_(false) { |
| 70 } | 73 } |
| 71 | 74 |
| 72 NetworkState::~NetworkState() { | 75 NetworkState::~NetworkState() { |
| 73 } | 76 } |
| 74 | 77 |
| 75 bool NetworkState::PropertyChanged(const std::string& key, | 78 bool NetworkState::PropertyChanged(const std::string& key, |
| 76 const base::Value& value) { | 79 const base::Value& value) { |
| 77 // Keep care that these properties are the same as in |GetProperties|. | 80 // Keep care that these properties are the same as in |GetProperties|. |
| 78 if (ManagedStatePropertyChanged(key, value)) | 81 if (ManagedStatePropertyChanged(key, value)) |
| 79 return true; | 82 return true; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 } | 193 } |
| 191 return true; | 194 return true; |
| 192 } else if (key == flimflam::kWifiHexSsid) { | 195 } else if (key == flimflam::kWifiHexSsid) { |
| 193 return GetStringValue(key, value, &hex_ssid_); | 196 return GetStringValue(key, value, &hex_ssid_); |
| 194 } else if (key == flimflam::kCountryProperty) { | 197 } else if (key == flimflam::kCountryProperty) { |
| 195 // TODO(stevenjb): This is currently experimental. If we find a case where | 198 // TODO(stevenjb): This is currently experimental. If we find a case where |
| 196 // base::DetectEncoding() fails in UpdateName(), where country_code_ is | 199 // base::DetectEncoding() fails in UpdateName(), where country_code_ is |
| 197 // set, figure out whether we can use country_code_ with ConvertToUtf8(). | 200 // set, figure out whether we can use country_code_ with ConvertToUtf8(). |
| 198 // crbug.com/233267. | 201 // crbug.com/233267. |
| 199 return GetStringValue(key, value, &country_code_); | 202 return GetStringValue(key, value, &country_code_); |
| 203 } else if (key == flimflam::kEapCaCertNssProperty) { |
| 204 std::string ca_cert_nss; |
| 205 if (!value.GetAsString(&ca_cert_nss)) { |
| 206 NET_LOG_ERROR("Failed to parse " + key, path()); |
| 207 return false; |
| 208 } |
| 209 has_eap_ca_cert_nss_ = !ca_cert_nss.empty(); |
| 210 return true; |
| 211 } else if (key == flimflam::kL2tpIpsecCaCertNssProperty) { |
| 212 std::string ca_cert_nss; |
| 213 if (!value.GetAsString(&ca_cert_nss)) { |
| 214 NET_LOG_ERROR("Failed to parse " + key, path()); |
| 215 return false; |
| 216 } |
| 217 has_ipsec_ca_cert_nss_ = !ca_cert_nss.empty(); |
| 218 return true; |
| 219 } else if (key == flimflam::kProviderProperty) { |
| 220 const DictionaryValue* dict = NULL; |
| 221 value.GetAsDictionary(&dict); |
| 222 if (!dict) { |
| 223 NET_LOG_ERROR("Failed to parse " + key, path()); |
| 224 return false; |
| 225 } |
| 226 |
| 227 std::string ca_cert_nss; |
| 228 dict->GetStringWithoutPathExpansion(flimflam::kOpenVPNCaCertNSSProperty, |
| 229 &ca_cert_nss); |
| 230 has_openvpn_ca_cert_nss_ = !ca_cert_nss.empty(); |
| 231 return true; |
| 200 } | 232 } |
| 201 return false; | 233 return false; |
| 202 } | 234 } |
| 203 | 235 |
| 204 void NetworkState::InitialPropertiesReceived() { | 236 void NetworkState::InitialPropertiesReceived() { |
| 205 UpdateName(); | 237 UpdateName(); |
| 206 } | 238 } |
| 207 | 239 |
| 208 void NetworkState::GetProperties(base::DictionaryValue* dictionary) const { | 240 void NetworkState::GetProperties(base::DictionaryValue* dictionary) const { |
| 209 // Keep care that these properties are the same as in |PropertyChanged|. | 241 // Keep care that these properties are the same as in |PropertyChanged|. |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 } | 462 } |
| 431 scoped_ptr<base::DictionaryValue> ui_data_dict( | 463 scoped_ptr<base::DictionaryValue> ui_data_dict( |
| 432 onc::ReadDictionaryFromJson(ui_data_str)); | 464 onc::ReadDictionaryFromJson(ui_data_str)); |
| 433 if (!ui_data_dict) | 465 if (!ui_data_dict) |
| 434 return false; | 466 return false; |
| 435 *out = NetworkUIData(*ui_data_dict).onc_source(); | 467 *out = NetworkUIData(*ui_data_dict).onc_source(); |
| 436 return true; | 468 return true; |
| 437 } | 469 } |
| 438 | 470 |
| 439 } // namespace chromeos | 471 } // namespace chromeos |
| OLD | NEW |