| 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 "chrome/browser/ui/webui/chromeos/login/network_state_informer.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
| 12 #include "chrome/browser/chromeos/login/screens/network_error.h" | 12 #include "chrome/browser/chromeos/login/screens/network_error.h" |
| 13 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 13 #include "chromeos/network/network_state.h" | 14 #include "chromeos/network/network_state.h" |
| 14 #include "chromeos/network/network_state_handler.h" | 15 #include "chromeos/network/network_state_handler.h" |
| 15 #include "chromeos/network/proxy/proxy_config_handler.h" | 16 #include "chromeos/network/proxy/proxy_config_handler.h" |
| 16 #include "components/proxy_config/proxy_config_dictionary.h" | 17 #include "components/proxy_config/proxy_config_dictionary.h" |
| 17 #include "components/proxy_config/proxy_prefs.h" | 18 #include "components/proxy_config/proxy_prefs.h" |
| 18 #include "net/proxy/proxy_config.h" | 19 #include "net/proxy/proxy_config.h" |
| 19 #include "third_party/cros_system_api/dbus/service_constants.h" | 20 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 20 | 21 |
| 21 namespace chromeos { | 22 namespace chromeos { |
| 22 | 23 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 network->is_captive_portal())) | 76 network->is_captive_portal())) |
| 76 return NetworkStateInformer::CAPTIVE_PORTAL; | 77 return NetworkStateInformer::CAPTIVE_PORTAL; |
| 77 } else { | 78 } else { |
| 78 if (NetworkState::StateIsConnecting(network->connection_state())) | 79 if (NetworkState::StateIsConnecting(network->connection_state())) |
| 79 return NetworkStateInformer::CONNECTING; | 80 return NetworkStateInformer::CONNECTING; |
| 80 if (network->connection_state() == shill::kStateOnline) | 81 if (network->connection_state() == shill::kStateOnline) |
| 81 return NetworkStateInformer::ONLINE; | 82 return NetworkStateInformer::ONLINE; |
| 82 if (network->is_captive_portal()) | 83 if (network->is_captive_portal()) |
| 83 return NetworkStateInformer::CAPTIVE_PORTAL; | 84 return NetworkStateInformer::CAPTIVE_PORTAL; |
| 84 } | 85 } |
| 86 |
| 87 // If there is no connection to the internet report it as online for the |
| 88 // Active Directory devices. These devices does not have to be online to reach |
| 89 // the server. |
| 90 // TODO(rsorokin): Fix reporting network connectivity for Active Directory |
| 91 // devices. (see crbug.com/685691) |
| 92 policy::BrowserPolicyConnectorChromeOS* connector = |
| 93 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 94 if (connector->IsActiveDirectoryManaged()) |
| 95 return NetworkStateInformer::ONLINE; |
| 96 |
| 85 return NetworkStateInformer::OFFLINE; | 97 return NetworkStateInformer::OFFLINE; |
| 86 } | 98 } |
| 87 | 99 |
| 88 } // namespace | 100 } // namespace |
| 89 | 101 |
| 90 NetworkStateInformer::NetworkStateInformer() | 102 NetworkStateInformer::NetworkStateInformer() |
| 91 : state_(OFFLINE), | 103 : state_(OFFLINE), |
| 92 weak_ptr_factory_(this) { | 104 weak_ptr_factory_(this) { |
| 93 } | 105 } |
| 94 | 106 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 SendStateToObservers(NetworkError::ERROR_REASON_UPDATE); | 215 SendStateToObservers(NetworkError::ERROR_REASON_UPDATE); |
| 204 } | 216 } |
| 205 | 217 |
| 206 void NetworkStateInformer::SendStateToObservers( | 218 void NetworkStateInformer::SendStateToObservers( |
| 207 NetworkError::ErrorReason reason) { | 219 NetworkError::ErrorReason reason) { |
| 208 for (NetworkStateInformerObserver& observer : observers_) | 220 for (NetworkStateInformerObserver& observer : observers_) |
| 209 observer.UpdateState(reason); | 221 observer.UpdateState(reason); |
| 210 } | 222 } |
| 211 | 223 |
| 212 } // namespace chromeos | 224 } // namespace chromeos |
| OLD | NEW |