| 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/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "chromeos/network/network_event_log.h" | 8 #include "chromeos/network/network_event_log.h" |
| 9 #include "chromeos/network/network_profile_handler.h" | 9 #include "chromeos/network/network_profile_handler.h" |
| 10 #include "chromeos/network/network_util.h" | 10 #include "chromeos/network/network_util.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 return false; | 54 return false; |
| 55 } | 55 } |
| 56 | 56 |
| 57 } // namespace | 57 } // namespace |
| 58 | 58 |
| 59 namespace chromeos { | 59 namespace chromeos { |
| 60 | 60 |
| 61 NetworkState::NetworkState(const std::string& path) | 61 NetworkState::NetworkState(const std::string& path) |
| 62 : ManagedState(MANAGED_TYPE_NETWORK, path), | 62 : ManagedState(MANAGED_TYPE_NETWORK, path), |
| 63 auto_connect_(false), | 63 connectable_(false), |
| 64 favorite_(false), | |
| 65 priority_(0), | |
| 66 prefix_length_(0), | 64 prefix_length_(0), |
| 67 signal_strength_(0), | 65 signal_strength_(0), |
| 68 connectable_(false), | |
| 69 activate_over_non_cellular_networks_(false), | 66 activate_over_non_cellular_networks_(false), |
| 70 cellular_out_of_credits_(false), | 67 cellular_out_of_credits_(false), |
| 71 has_ca_cert_nss_(false) { | 68 has_ca_cert_nss_(false) { |
| 72 } | 69 } |
| 73 | 70 |
| 74 NetworkState::~NetworkState() { | 71 NetworkState::~NetworkState() { |
| 75 } | 72 } |
| 76 | 73 |
| 77 bool NetworkState::PropertyChanged(const std::string& key, | 74 bool NetworkState::PropertyChanged(const std::string& key, |
| 78 const base::Value& value) { | 75 const base::Value& value) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 web_proxy_auto_discovery_url_ = GURL(); | 119 web_proxy_auto_discovery_url_ = GURL(); |
| 123 } | 120 } |
| 124 } | 121 } |
| 125 return true; | 122 return true; |
| 126 } else if (key == flimflam::kActivationStateProperty) { | 123 } else if (key == flimflam::kActivationStateProperty) { |
| 127 return GetStringValue(key, value, &activation_state_); | 124 return GetStringValue(key, value, &activation_state_); |
| 128 } else if (key == flimflam::kRoamingStateProperty) { | 125 } else if (key == flimflam::kRoamingStateProperty) { |
| 129 return GetStringValue(key, value, &roaming_); | 126 return GetStringValue(key, value, &roaming_); |
| 130 } else if (key == flimflam::kSecurityProperty) { | 127 } else if (key == flimflam::kSecurityProperty) { |
| 131 return GetStringValue(key, value, &security_); | 128 return GetStringValue(key, value, &security_); |
| 132 } else if (key == flimflam::kAutoConnectProperty) { | |
| 133 return GetBooleanValue(key, value, &auto_connect_); | |
| 134 } else if (key == flimflam::kFavoriteProperty) { | |
| 135 return GetBooleanValue(key, value, &favorite_); | |
| 136 } else if (key == flimflam::kPriorityProperty) { | |
| 137 return GetIntegerValue(key, value, &priority_); | |
| 138 } else if (key == flimflam::kProxyConfigProperty) { | 129 } else if (key == flimflam::kProxyConfigProperty) { |
| 139 std::string proxy_config_str; | 130 std::string proxy_config_str; |
| 140 if (!value.GetAsString(&proxy_config_str)) { | 131 if (!value.GetAsString(&proxy_config_str)) { |
| 141 NET_LOG_ERROR("Failed to parse " + key, path()); | 132 NET_LOG_ERROR("Failed to parse " + key, path()); |
| 142 return false; | 133 return false; |
| 143 } | 134 } |
| 144 | 135 |
| 145 proxy_config_.Clear(); | 136 proxy_config_.Clear(); |
| 146 if (proxy_config_str.empty()) | 137 if (proxy_config_str.empty()) |
| 147 return true; | 138 return true; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 172 } else if (key == flimflam::kDeviceProperty) { | 163 } else if (key == flimflam::kDeviceProperty) { |
| 173 return GetStringValue(key, value, &device_path_); | 164 return GetStringValue(key, value, &device_path_); |
| 174 } else if (key == flimflam::kGuidProperty) { | 165 } else if (key == flimflam::kGuidProperty) { |
| 175 return GetStringValue(key, value, &guid_); | 166 return GetStringValue(key, value, &guid_); |
| 176 } else if (key == flimflam::kProfileProperty) { | 167 } else if (key == flimflam::kProfileProperty) { |
| 177 return GetStringValue(key, value, &profile_path_); | 168 return GetStringValue(key, value, &profile_path_); |
| 178 } else if (key == shill::kActivateOverNonCellularNetworkProperty) { | 169 } else if (key == shill::kActivateOverNonCellularNetworkProperty) { |
| 179 return GetBooleanValue(key, value, &activate_over_non_cellular_networks_); | 170 return GetBooleanValue(key, value, &activate_over_non_cellular_networks_); |
| 180 } else if (key == shill::kOutOfCreditsProperty) { | 171 } else if (key == shill::kOutOfCreditsProperty) { |
| 181 return GetBooleanValue(key, value, &cellular_out_of_credits_); | 172 return GetBooleanValue(key, value, &cellular_out_of_credits_); |
| 182 } else if (key == flimflam::kUsageURLProperty) { | |
| 183 return GetStringValue(key, value, &usage_url_); | |
| 184 } else if (key == flimflam::kPaymentPortalProperty) { | |
| 185 const DictionaryValue* dict; | |
| 186 if (!value.GetAsDictionary(&dict)) | |
| 187 return false; | |
| 188 if (!dict->GetStringWithoutPathExpansion( | |
| 189 flimflam::kPaymentPortalURL, &payment_url_) || | |
| 190 !dict->GetStringWithoutPathExpansion( | |
| 191 flimflam::kPaymentPortalMethod, &post_method_) || | |
| 192 !dict->GetStringWithoutPathExpansion( | |
| 193 flimflam::kPaymentPortalPostData, &post_data_)) { | |
| 194 return false; | |
| 195 } | |
| 196 return true; | |
| 197 } | 173 } |
| 198 return false; | 174 return false; |
| 199 } | 175 } |
| 200 | 176 |
| 201 bool NetworkState::InitialPropertiesReceived( | 177 bool NetworkState::InitialPropertiesReceived( |
| 202 const base::DictionaryValue& properties) { | 178 const base::DictionaryValue& properties) { |
| 203 NET_LOG_DEBUG("InitialPropertiesReceived", path()); | 179 NET_LOG_DEBUG("InitialPropertiesReceived", path()); |
| 204 bool changed = UpdateName(properties); | 180 bool changed = UpdateName(properties); |
| 205 bool had_ca_cert_nss = has_ca_cert_nss_; | 181 bool had_ca_cert_nss = has_ca_cert_nss_; |
| 206 has_ca_cert_nss_ = IsCaCertNssSet(properties); | 182 has_ca_cert_nss_ = IsCaCertNssSet(properties); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 225 // IPConfig properties | 201 // IPConfig properties |
| 226 base::DictionaryValue* ipconfig_properties = new base::DictionaryValue; | 202 base::DictionaryValue* ipconfig_properties = new base::DictionaryValue; |
| 227 ipconfig_properties->SetStringWithoutPathExpansion(flimflam::kAddressProperty, | 203 ipconfig_properties->SetStringWithoutPathExpansion(flimflam::kAddressProperty, |
| 228 ip_address_); | 204 ip_address_); |
| 229 ipconfig_properties->SetStringWithoutPathExpansion(flimflam::kGatewayProperty, | 205 ipconfig_properties->SetStringWithoutPathExpansion(flimflam::kGatewayProperty, |
| 230 gateway_); | 206 gateway_); |
| 231 base::ListValue* name_servers = new base::ListValue; | 207 base::ListValue* name_servers = new base::ListValue; |
| 232 name_servers->AppendStrings(dns_servers_); | 208 name_servers->AppendStrings(dns_servers_); |
| 233 ipconfig_properties->SetWithoutPathExpansion(flimflam::kNameServersProperty, | 209 ipconfig_properties->SetWithoutPathExpansion(flimflam::kNameServersProperty, |
| 234 name_servers); | 210 name_servers); |
| 235 ipconfig_properties->SetIntegerWithoutPathExpansion( | |
| 236 flimflam::kPrefixlenProperty, prefix_length_); | |
| 237 ipconfig_properties->SetStringWithoutPathExpansion( | 211 ipconfig_properties->SetStringWithoutPathExpansion( |
| 238 shill::kWebProxyAutoDiscoveryUrlProperty, | 212 shill::kWebProxyAutoDiscoveryUrlProperty, |
| 239 web_proxy_auto_discovery_url_.spec()); | 213 web_proxy_auto_discovery_url_.spec()); |
| 240 dictionary->SetWithoutPathExpansion(shill::kIPConfigProperty, | 214 dictionary->SetWithoutPathExpansion(shill::kIPConfigProperty, |
| 241 ipconfig_properties); | 215 ipconfig_properties); |
| 242 | 216 |
| 243 dictionary->SetStringWithoutPathExpansion(flimflam::kActivationStateProperty, | 217 dictionary->SetStringWithoutPathExpansion(flimflam::kActivationStateProperty, |
| 244 activation_state_); | 218 activation_state_); |
| 245 dictionary->SetStringWithoutPathExpansion(flimflam::kRoamingStateProperty, | 219 dictionary->SetStringWithoutPathExpansion(flimflam::kRoamingStateProperty, |
| 246 roaming_); | 220 roaming_); |
| 247 dictionary->SetStringWithoutPathExpansion(flimflam::kSecurityProperty, | 221 dictionary->SetStringWithoutPathExpansion(flimflam::kSecurityProperty, |
| 248 security_); | 222 security_); |
| 249 dictionary->SetBooleanWithoutPathExpansion(flimflam::kAutoConnectProperty, | |
| 250 auto_connect_); | |
| 251 dictionary->SetBooleanWithoutPathExpansion(flimflam::kFavoriteProperty, | |
| 252 favorite_); | |
| 253 dictionary->SetIntegerWithoutPathExpansion(flimflam::kPriorityProperty, | |
| 254 priority_); | |
| 255 // Proxy config and ONC source are intentionally omitted: These properties are | 223 // Proxy config and ONC source are intentionally omitted: These properties are |
| 256 // placed in NetworkState to transition ProxyConfigServiceImpl from | 224 // placed in NetworkState to transition ProxyConfigServiceImpl from |
| 257 // NetworkLibrary to the new network stack. The networking extension API | 225 // NetworkLibrary to the new network stack. The networking extension API |
| 258 // shouldn't depend on this member. Once ManagedNetworkConfigurationHandler | 226 // shouldn't depend on this member. Once ManagedNetworkConfigurationHandler |
| 259 // is used instead of NetworkLibrary, we can remove them again. | 227 // is used instead of NetworkLibrary, we can remove them again. |
| 260 dictionary->SetStringWithoutPathExpansion( | 228 dictionary->SetStringWithoutPathExpansion( |
| 261 flimflam::kNetworkTechnologyProperty, | 229 flimflam::kNetworkTechnologyProperty, |
| 262 network_technology_); | 230 network_technology_); |
| 263 dictionary->SetStringWithoutPathExpansion(flimflam::kDeviceProperty, | 231 dictionary->SetStringWithoutPathExpansion(flimflam::kDeviceProperty, |
| 264 device_path_); | 232 device_path_); |
| 265 dictionary->SetStringWithoutPathExpansion(flimflam::kGuidProperty, guid_); | 233 dictionary->SetStringWithoutPathExpansion(flimflam::kGuidProperty, guid_); |
| 266 dictionary->SetStringWithoutPathExpansion(flimflam::kProfileProperty, | 234 dictionary->SetStringWithoutPathExpansion(flimflam::kProfileProperty, |
| 267 profile_path_); | 235 profile_path_); |
| 268 dictionary->SetBooleanWithoutPathExpansion( | 236 dictionary->SetBooleanWithoutPathExpansion( |
| 269 shill::kActivateOverNonCellularNetworkProperty, | 237 shill::kActivateOverNonCellularNetworkProperty, |
| 270 activate_over_non_cellular_networks_); | 238 activate_over_non_cellular_networks_); |
| 271 dictionary->SetBooleanWithoutPathExpansion(shill::kOutOfCreditsProperty, | 239 dictionary->SetBooleanWithoutPathExpansion(shill::kOutOfCreditsProperty, |
| 272 cellular_out_of_credits_); | 240 cellular_out_of_credits_); |
| 273 base::DictionaryValue* payment_portal_properties = new DictionaryValue; | |
| 274 payment_portal_properties->SetStringWithoutPathExpansion( | |
| 275 flimflam::kPaymentPortalURL, | |
| 276 payment_url_); | |
| 277 payment_portal_properties->SetStringWithoutPathExpansion( | |
| 278 flimflam::kPaymentPortalMethod, | |
| 279 post_method_); | |
| 280 payment_portal_properties->SetStringWithoutPathExpansion( | |
| 281 flimflam::kPaymentPortalPostData, | |
| 282 post_data_); | |
| 283 dictionary->SetWithoutPathExpansion(flimflam::kPaymentPortalProperty, | |
| 284 payment_portal_properties); | |
| 285 } | 241 } |
| 286 | 242 |
| 287 bool NetworkState::IsConnectedState() const { | 243 bool NetworkState::IsConnectedState() const { |
| 288 return StateIsConnected(connection_state_); | 244 return StateIsConnected(connection_state_); |
| 289 } | 245 } |
| 290 | 246 |
| 291 bool NetworkState::IsConnectingState() const { | 247 bool NetworkState::IsConnectingState() const { |
| 292 return StateIsConnecting(connection_state_); | 248 return StateIsConnecting(connection_state_); |
| 293 } | 249 } |
| 294 | 250 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 connection_state == flimflam::kStateConfiguration || | 295 connection_state == flimflam::kStateConfiguration || |
| 340 connection_state == flimflam::kStateCarrier); | 296 connection_state == flimflam::kStateCarrier); |
| 341 } | 297 } |
| 342 | 298 |
| 343 // static | 299 // static |
| 344 std::string NetworkState::IPConfigProperty(const char* key) { | 300 std::string NetworkState::IPConfigProperty(const char* key) { |
| 345 return base::StringPrintf("%s.%s", shill::kIPConfigProperty, key); | 301 return base::StringPrintf("%s.%s", shill::kIPConfigProperty, key); |
| 346 } | 302 } |
| 347 | 303 |
| 348 } // namespace chromeos | 304 } // namespace chromeos |
| OLD | NEW |