| Index: chrome/browser/ui/webui/chromeos/login/network_state_informer.cc
|
| diff --git a/chrome/browser/ui/webui/chromeos/login/network_state_informer.cc b/chrome/browser/ui/webui/chromeos/login/network_state_informer.cc
|
| index 34d62729a1cbc27f5f1416d41c7d21f250591cac..555239d0cfcc7604261071f857ac002e691d75df 100644
|
| --- a/chrome/browser/ui/webui/chromeos/login/network_state_informer.cc
|
| +++ b/chrome/browser/ui/webui/chromeos/login/network_state_informer.cc
|
| @@ -7,10 +7,12 @@
|
| #include "base/bind.h"
|
| #include "base/logging.h"
|
| #include "base/message_loop.h"
|
| -#include "chrome/browser/chromeos/cros/cros_library.h"
|
| #include "chrome/browser/chromeos/proxy_config_service_impl.h"
|
| #include "chrome/common/chrome_notification_types.h"
|
| +#include "chromeos/network/network_state.h"
|
| +#include "chromeos/network/network_state_handler.h"
|
| #include "net/proxy/proxy_config.h"
|
| +#include "third_party/cros_system_api/dbus/service_constants.h"
|
|
|
| namespace {
|
|
|
| @@ -23,13 +25,11 @@ namespace chromeos {
|
|
|
| NetworkStateInformer::NetworkStateInformer()
|
| : state_(OFFLINE),
|
| - delegate_(NULL),
|
| - last_network_type_(TYPE_WIFI) {
|
| + delegate_(NULL) {
|
| }
|
|
|
| NetworkStateInformer::~NetworkStateInformer() {
|
| - CrosLibrary::Get()->GetNetworkLibrary()->
|
| - RemoveNetworkManagerObserver(this);
|
| + NetworkStateHandler::Get()->RemoveObserver(this);
|
| if (NetworkPortalDetector::IsEnabledInCommandLine() &&
|
| NetworkPortalDetector::GetInstance()) {
|
| NetworkPortalDetector::GetInstance()->RemoveObserver(this);
|
| @@ -37,9 +37,8 @@ NetworkStateInformer::~NetworkStateInformer() {
|
| }
|
|
|
| void NetworkStateInformer::Init() {
|
| - NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary();
|
| - UpdateState(cros);
|
| - cros->AddNetworkManagerObserver(this);
|
| + UpdateState();
|
| + NetworkStateHandler::Get()->AddObserver(this);
|
|
|
| if (NetworkPortalDetector::IsEnabledInCommandLine() &&
|
| NetworkPortalDetector::GetInstance()) {
|
| @@ -68,13 +67,14 @@ void NetworkStateInformer::RemoveObserver(
|
| observers_.RemoveObserver(observer);
|
| }
|
|
|
| -void NetworkStateInformer::OnNetworkManagerChanged(NetworkLibrary* cros) {
|
| - const Network* active_network = cros->active_network();
|
| +void NetworkStateInformer::NetworkManagerChanged() {
|
| + const NetworkState* default_network =
|
| + NetworkStateHandler::Get()->DefaultNetwork();
|
| State new_state = OFFLINE;
|
| std::string new_network_service_path;
|
| - if (active_network) {
|
| - new_state = GetNetworkState(active_network);
|
| - new_network_service_path = active_network->service_path();
|
| + if (default_network) {
|
| + new_state = GetNetworkState(default_network);
|
| + new_network_service_path = default_network->path();
|
| }
|
| if ((state_ != ONLINE && (new_state == ONLINE || new_state == CONNECTING)) ||
|
| (state_ == ONLINE && (new_state == ONLINE || new_state == CONNECTING) &&
|
| @@ -101,14 +101,16 @@ void NetworkStateInformer::OnNetworkManagerChanged(NetworkLibrary* cros) {
|
| }
|
| }
|
|
|
| +void NetworkStateInformer::DefaultNetworkChanged(const NetworkState* network) {
|
| + NetworkManagerChanged();
|
| +}
|
| +
|
| void NetworkStateInformer::OnPortalDetectionCompleted(
|
| - const Network* network,
|
| + const NetworkState* network,
|
| const NetworkPortalDetector::CaptivePortalState& state) {
|
| - if (CrosLibrary::Get() && network) {
|
| - NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary();
|
| - if (network_library && network_library->active_network() == network)
|
| - OnNetworkManagerChanged(network_library);
|
| - }
|
| + if (NetworkStateHandler::IsInitialized() &&
|
| + NetworkStateHandler::Get()->DefaultNetwork() == network)
|
| + NetworkManagerChanged();
|
| }
|
|
|
| void NetworkStateInformer::Observe(
|
| @@ -127,14 +129,15 @@ void NetworkStateInformer::OnPortalDetected() {
|
| SendStateToObservers(ErrorScreenActor::ERROR_REASON_PORTAL_DETECTED);
|
| }
|
|
|
| -bool NetworkStateInformer::UpdateState(NetworkLibrary* cros) {
|
| +bool NetworkStateInformer::UpdateState() {
|
| State new_state = OFFLINE;
|
|
|
| - const Network* active_network = cros->active_network();
|
| - if (active_network) {
|
| - new_state = GetNetworkState(active_network);
|
| - last_network_service_path_ = active_network->service_path();
|
| - last_network_type_ = active_network->type();
|
| + const NetworkState* default_network =
|
| + NetworkStateHandler::Get()->DefaultNetwork();
|
| + if (default_network) {
|
| + new_state = GetNetworkState(default_network);
|
| + last_network_service_path_ = default_network->path();
|
| + last_network_type_ = default_network->type();
|
| }
|
|
|
| bool updated = (new_state != state_) ||
|
| @@ -154,7 +157,7 @@ void NetworkStateInformer::UpdateStateAndNotify() {
|
| // Cancel pending update request if any.
|
| check_state_.Cancel();
|
|
|
| - if (UpdateState(CrosLibrary::Get()->GetNetworkLibrary()))
|
| + if (UpdateState())
|
| SendStateToObservers(ErrorScreenActor::ERROR_REASON_NETWORK_STATE_CHANGED);
|
| else
|
| SendStateToObservers(ErrorScreenActor::ERROR_REASON_UPDATE);
|
| @@ -167,7 +170,7 @@ void NetworkStateInformer::SendStateToObservers(
|
| }
|
|
|
| NetworkStateInformer::State NetworkStateInformer::GetNetworkState(
|
| - const Network* network) {
|
| + const NetworkState* network) {
|
| DCHECK(network);
|
| if (NetworkPortalDetector::IsEnabledInCommandLine() &&
|
| NetworkPortalDetector::GetInstance()) {
|
| @@ -175,14 +178,15 @@ NetworkStateInformer::State NetworkStateInformer::GetNetworkState(
|
| NetworkPortalDetector::GetInstance()->GetCaptivePortalState(network);
|
| NetworkPortalDetector::CaptivePortalStatus status = state.status;
|
| if (status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN &&
|
| - network->connecting()) {
|
| + NetworkState::StateIsConnecting(network->connection_state())) {
|
| return CONNECTING;
|
| }
|
| // For proxy-less networks rely on shill's online state if
|
| // NetworkPortalDetector's state of current network is unknown.
|
| if (status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE ||
|
| (status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN &&
|
| - !IsProxyConfigured(network) && network->online())) {
|
| + !IsProxyConfigured(network) &&
|
| + network->connection_state() == flimflam::kStateOnline)) {
|
| return ONLINE;
|
| }
|
| if (status ==
|
| @@ -192,31 +196,33 @@ NetworkStateInformer::State NetworkStateInformer::GetNetworkState(
|
| }
|
| if (status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL ||
|
| (status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN &&
|
| - network->restricted_pool()))
|
| + network->connection_state() == flimflam::kStatePortal))
|
| return CAPTIVE_PORTAL;
|
| } else {
|
| - if (network->connecting())
|
| + if (NetworkState::StateIsConnecting(network->connection_state()))
|
| return CONNECTING;
|
| - if (network->online())
|
| + if (network->connection_state() == flimflam::kStateOnline)
|
| return ONLINE;
|
| - if (network->restricted_pool())
|
| + if (network->connection_state() == flimflam::kStatePortal)
|
| return CAPTIVE_PORTAL;
|
| }
|
| return OFFLINE;
|
| }
|
|
|
| -bool NetworkStateInformer::IsProxyConfigured(const Network* network) {
|
| +bool NetworkStateInformer::IsProxyConfigured(const NetworkState* network) {
|
| DCHECK(network);
|
| - ProxyStateMap::iterator it = proxy_state_map_.find(network->unique_id());
|
| +
|
| + ProxyStateMap::iterator it = proxy_state_map_.find(network->guid());
|
| if (it != proxy_state_map_.end() &&
|
| it->second.proxy_config == network->proxy_config()) {
|
| return it->second.configured;
|
| }
|
| net::ProxyConfig proxy_config;
|
| - if (!ProxyConfigServiceImpl::ParseProxyConfig(network, &proxy_config))
|
| + if (!ProxyConfigServiceImpl::ParseProxyConfig(network->proxy_config(),
|
| + &proxy_config))
|
| return false;
|
| bool configured = !proxy_config.proxy_rules().empty();
|
| - proxy_state_map_[network->unique_id()] =
|
| + proxy_state_map_[network->guid()] =
|
| ProxyState(network->proxy_config(), configured);
|
| return configured;
|
| }
|
|
|