| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 shill::kHostProperty, &third_party_vpn_provider_extension_id_)) { | 194 shill::kHostProperty, &third_party_vpn_provider_extension_id_)) { |
| 195 NET_LOG(ERROR) << "Failed to parse " << path() << "." << key; | 195 NET_LOG(ERROR) << "Failed to parse " << path() << "." << key; |
| 196 return false; | 196 return false; |
| 197 } | 197 } |
| 198 } else { | 198 } else { |
| 199 third_party_vpn_provider_extension_id_.clear(); | 199 third_party_vpn_provider_extension_id_.clear(); |
| 200 } | 200 } |
| 201 | 201 |
| 202 vpn_provider_type_ = vpn_provider_type; | 202 vpn_provider_type_ = vpn_provider_type; |
| 203 return true; | 203 return true; |
| 204 } else if (key == shill::kTetheringProperty) { |
| 205 return GetStringValue(key, value, &tethering_state_); |
| 204 } | 206 } |
| 205 return false; | 207 return false; |
| 206 } | 208 } |
| 207 | 209 |
| 208 bool NetworkState::InitialPropertiesReceived( | 210 bool NetworkState::InitialPropertiesReceived( |
| 209 const base::DictionaryValue& properties) { | 211 const base::DictionaryValue& properties) { |
| 210 NET_LOG(EVENT) << "InitialPropertiesReceived: " << path() << ": " << name() | 212 NET_LOG(EVENT) << "InitialPropertiesReceived: " << path() << ": " << name() |
| 211 << " State: " << connection_state_ << " Visible: " << visible_; | 213 << " State: " << connection_state_ << " Visible: " << visible_; |
| 212 if (!properties.HasKey(shill::kTypeProperty)) { | 214 if (!properties.HasKey(shill::kTypeProperty)) { |
| 213 NET_LOG(ERROR) << "NetworkState has no type: " | 215 NET_LOG(ERROR) << "NetworkState has no type: " |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 if (!visible()) | 359 if (!visible()) |
| 358 return shill::kStateDisconnect; | 360 return shill::kStateDisconnect; |
| 359 return connection_state_; | 361 return connection_state_; |
| 360 } | 362 } |
| 361 | 363 |
| 362 void NetworkState::set_connection_state(const std::string connection_state) { | 364 void NetworkState::set_connection_state(const std::string connection_state) { |
| 363 last_connection_state_ = connection_state_; | 365 last_connection_state_ = connection_state_; |
| 364 connection_state_ = connection_state; | 366 connection_state_ = connection_state; |
| 365 } | 367 } |
| 366 | 368 |
| 369 bool NetworkState::IsUsingMobileData() const { |
| 370 return type() == shill::kTypeCellular || type() == chromeos::kTypeTether || |
| 371 tethering_state() == shill::kTetheringConfirmedState; |
| 372 } |
| 373 |
| 367 bool NetworkState::IsDynamicWep() const { | 374 bool NetworkState::IsDynamicWep() const { |
| 368 return security_class_ == shill::kSecurityWep && | 375 return security_class_ == shill::kSecurityWep && |
| 369 eap_key_mgmt_ == shill::kKeyManagementIEEE8021X; | 376 eap_key_mgmt_ == shill::kKeyManagementIEEE8021X; |
| 370 } | 377 } |
| 371 | 378 |
| 372 bool NetworkState::IsConnectedState() const { | 379 bool NetworkState::IsConnectedState() const { |
| 373 return visible() && StateIsConnected(connection_state_); | 380 return visible() && StateIsConnected(connection_state_); |
| 374 } | 381 } |
| 375 | 382 |
| 376 bool NetworkState::IsConnectingState() const { | 383 bool NetworkState::IsConnectingState() const { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 return IsCaptivePortalState(shill_properties, false /* log */); | 471 return IsCaptivePortalState(shill_properties, false /* log */); |
| 465 } | 472 } |
| 466 | 473 |
| 467 // static | 474 // static |
| 468 bool NetworkState::ErrorIsValid(const std::string& error) { | 475 bool NetworkState::ErrorIsValid(const std::string& error) { |
| 469 // Shill uses "Unknown" to indicate an unset or cleared error state. | 476 // Shill uses "Unknown" to indicate an unset or cleared error state. |
| 470 return !error.empty() && error != kErrorUnknown; | 477 return !error.empty() && error != kErrorUnknown; |
| 471 } | 478 } |
| 472 | 479 |
| 473 } // namespace chromeos | 480 } // namespace chromeos |
| OLD | NEW |