| 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/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 } else if (key == flimflam::kDeviceProperty) { | 151 } else if (key == flimflam::kDeviceProperty) { |
| 152 return GetStringValue(key, value, &device_path_); | 152 return GetStringValue(key, value, &device_path_); |
| 153 } else if (key == flimflam::kGuidProperty) { | 153 } else if (key == flimflam::kGuidProperty) { |
| 154 return GetStringValue(key, value, &guid_); | 154 return GetStringValue(key, value, &guid_); |
| 155 } else if (key == flimflam::kProfileProperty) { | 155 } else if (key == flimflam::kProfileProperty) { |
| 156 return GetStringValue(key, value, &profile_path_); | 156 return GetStringValue(key, value, &profile_path_); |
| 157 } else if (key == shill::kActivateOverNonCellularNetworkProperty) { | 157 } else if (key == shill::kActivateOverNonCellularNetworkProperty) { |
| 158 return GetBooleanValue(key, value, &activate_over_non_cellular_networks_); | 158 return GetBooleanValue(key, value, &activate_over_non_cellular_networks_); |
| 159 } else if (key == shill::kOutOfCreditsProperty) { | 159 } else if (key == shill::kOutOfCreditsProperty) { |
| 160 return GetBooleanValue(key, value, &cellular_out_of_credits_); | 160 return GetBooleanValue(key, value, &cellular_out_of_credits_); |
| 161 } else if (key == flimflam::kUsageURLProperty) { |
| 162 return GetStringValue(key, value, &usage_url_); |
| 163 } else if (key == flimflam::kPaymentPortalProperty) { |
| 164 const DictionaryValue& dict = static_cast<const DictionaryValue&>(value); |
| 165 if (!dict.GetStringWithoutPathExpansion(flimflam::kPaymentPortalURL, |
| 166 &payment_url_)) |
| 167 return false; |
| 168 if (!dict.GetStringWithoutPathExpansion(flimflam::kPaymentPortalMethod, |
| 169 &post_method_)) |
| 170 return false; |
| 171 if (!dict.GetStringWithoutPathExpansion(flimflam::kPaymentPortalPostData, |
| 172 &post_data_)) |
| 173 return false; |
| 174 return true; |
| 161 } else if (key == flimflam::kWifiHexSsid) { | 175 } else if (key == flimflam::kWifiHexSsid) { |
| 162 return GetStringValue(key, value, &hex_ssid_); | 176 return GetStringValue(key, value, &hex_ssid_); |
| 163 } else if (key == flimflam::kCountryProperty) { | 177 } else if (key == flimflam::kCountryProperty) { |
| 164 // TODO(stevenjb): This is currently experimental. If we find a case where | 178 // TODO(stevenjb): This is currently experimental. If we find a case where |
| 165 // base::DetectEncoding() fails in UpdateName(), where country_code_ is | 179 // base::DetectEncoding() fails in UpdateName(), where country_code_ is |
| 166 // set, figure out whether we can use country_code_ with ConvertToUtf8(). | 180 // set, figure out whether we can use country_code_ with ConvertToUtf8(). |
| 167 // crbug.com/233267. | 181 // crbug.com/233267. |
| 168 return GetStringValue(key, value, &country_code_); | 182 return GetStringValue(key, value, &country_code_); |
| 169 } | 183 } |
| 170 return false; | 184 return false; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 dictionary->SetStringWithoutPathExpansion(flimflam::kDeviceProperty, | 237 dictionary->SetStringWithoutPathExpansion(flimflam::kDeviceProperty, |
| 224 device_path_); | 238 device_path_); |
| 225 dictionary->SetStringWithoutPathExpansion(flimflam::kGuidProperty, guid_); | 239 dictionary->SetStringWithoutPathExpansion(flimflam::kGuidProperty, guid_); |
| 226 dictionary->SetStringWithoutPathExpansion(flimflam::kProfileProperty, | 240 dictionary->SetStringWithoutPathExpansion(flimflam::kProfileProperty, |
| 227 profile_path_); | 241 profile_path_); |
| 228 dictionary->SetBooleanWithoutPathExpansion( | 242 dictionary->SetBooleanWithoutPathExpansion( |
| 229 shill::kActivateOverNonCellularNetworkProperty, | 243 shill::kActivateOverNonCellularNetworkProperty, |
| 230 activate_over_non_cellular_networks_); | 244 activate_over_non_cellular_networks_); |
| 231 dictionary->SetBooleanWithoutPathExpansion(shill::kOutOfCreditsProperty, | 245 dictionary->SetBooleanWithoutPathExpansion(shill::kOutOfCreditsProperty, |
| 232 cellular_out_of_credits_); | 246 cellular_out_of_credits_); |
| 247 base::DictionaryValue* payment_portal_properties = new DictionaryValue; |
| 248 payment_portal_properties->SetStringWithoutPathExpansion( |
| 249 flimflam::kPaymentPortalURL, |
| 250 payment_url_); |
| 251 payment_portal_properties->SetStringWithoutPathExpansion( |
| 252 flimflam::kPaymentPortalMethod, |
| 253 post_method_); |
| 254 payment_portal_properties->SetStringWithoutPathExpansion( |
| 255 flimflam::kPaymentPortalPostData, |
| 256 post_data_); |
| 257 dictionary->SetWithoutPathExpansion(flimflam::kPaymentPortalProperty, |
| 258 payment_portal_properties); |
| 233 } | 259 } |
| 234 | 260 |
| 235 void NetworkState::GetConfigProperties( | 261 void NetworkState::GetConfigProperties( |
| 236 base::DictionaryValue* dictionary) const { | 262 base::DictionaryValue* dictionary) const { |
| 237 dictionary->SetStringWithoutPathExpansion(flimflam::kNameProperty, name()); | 263 dictionary->SetStringWithoutPathExpansion(flimflam::kNameProperty, name()); |
| 238 dictionary->SetStringWithoutPathExpansion(flimflam::kTypeProperty, type()); | 264 dictionary->SetStringWithoutPathExpansion(flimflam::kTypeProperty, type()); |
| 239 dictionary->SetStringWithoutPathExpansion(flimflam::kSecurityProperty, | 265 dictionary->SetStringWithoutPathExpansion(flimflam::kSecurityProperty, |
| 240 security()); | 266 security()); |
| 241 dictionary->SetStringWithoutPathExpansion(flimflam::kGuidProperty, guid()); | 267 dictionary->SetStringWithoutPathExpansion(flimflam::kGuidProperty, guid()); |
| 242 } | 268 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 connection_state == flimflam::kStateConfiguration || | 356 connection_state == flimflam::kStateConfiguration || |
| 331 connection_state == flimflam::kStateCarrier); | 357 connection_state == flimflam::kStateCarrier); |
| 332 } | 358 } |
| 333 | 359 |
| 334 // static | 360 // static |
| 335 std::string NetworkState::IPConfigProperty(const char* key) { | 361 std::string NetworkState::IPConfigProperty(const char* key) { |
| 336 return base::StringPrintf("%s.%s", shill::kIPConfigProperty, key); | 362 return base::StringPrintf("%s.%s", shill::kIPConfigProperty, key); |
| 337 } | 363 } |
| 338 | 364 |
| 339 } // namespace chromeos | 365 } // namespace chromeos |
| OLD | NEW |