| 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/net/proxy_config_handler.h" | 13 #include "chrome/browser/chromeos/net/proxy_config_handler.h" |
| 13 #include "chrome/browser/prefs/proxy_config_dictionary.h" | 14 #include "chrome/browser/prefs/proxy_config_dictionary.h" |
| 14 #include "chrome/browser/prefs/proxy_prefs.h" | 15 #include "chrome/browser/prefs/proxy_prefs.h" |
| 15 #include "chromeos/network/network_state.h" | 16 #include "chromeos/network/network_state.h" |
| 16 #include "chromeos/network/network_state_handler.h" | 17 #include "chromeos/network/network_state_handler.h" |
| 17 #include "net/proxy/proxy_config.h" | 18 #include "net/proxy/proxy_config.h" |
| 18 #include "third_party/cros_system_api/dbus/service_constants.h" | 19 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 19 | 20 |
| 20 namespace chromeos { | 21 namespace chromeos { |
| 21 | 22 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 UpdateStateAndNotify(); | 134 UpdateStateAndNotify(); |
| 134 } | 135 } |
| 135 | 136 |
| 136 void NetworkStateInformer::Observe( | 137 void NetworkStateInformer::Observe( |
| 137 int type, | 138 int type, |
| 138 const content::NotificationSource& source, | 139 const content::NotificationSource& source, |
| 139 const content::NotificationDetails& details) { | 140 const content::NotificationDetails& details) { |
| 140 if (type == chrome::NOTIFICATION_SESSION_STARTED) | 141 if (type == chrome::NOTIFICATION_SESSION_STARTED) |
| 141 registrar_.RemoveAll(); | 142 registrar_.RemoveAll(); |
| 142 else if (type == chrome::NOTIFICATION_LOGIN_PROXY_CHANGED) | 143 else if (type == chrome::NOTIFICATION_LOGIN_PROXY_CHANGED) |
| 143 SendStateToObservers(ErrorScreenActor::ERROR_REASON_PROXY_CONFIG_CHANGED); | 144 SendStateToObservers(NetworkError::ERROR_REASON_PROXY_CONFIG_CHANGED); |
| 144 else | 145 else |
| 145 NOTREACHED() << "Unknown notification: " << type; | 146 NOTREACHED() << "Unknown notification: " << type; |
| 146 } | 147 } |
| 147 | 148 |
| 148 void NetworkStateInformer::OnPortalDetected() { | 149 void NetworkStateInformer::OnPortalDetected() { |
| 149 UpdateStateAndNotify(); | 150 UpdateStateAndNotify(); |
| 150 } | 151 } |
| 151 | 152 |
| 152 // static | 153 // static |
| 153 const char* NetworkStateInformer::StatusString(State state) { | 154 const char* NetworkStateInformer::StatusString(State state) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 if (updated && state_ == ONLINE) { | 190 if (updated && state_ == ONLINE) { |
| 190 FOR_EACH_OBSERVER(NetworkStateInformerObserver, observers_, | 191 FOR_EACH_OBSERVER(NetworkStateInformerObserver, observers_, |
| 191 OnNetworkReady()); | 192 OnNetworkReady()); |
| 192 } | 193 } |
| 193 | 194 |
| 194 return updated; | 195 return updated; |
| 195 } | 196 } |
| 196 | 197 |
| 197 void NetworkStateInformer::UpdateStateAndNotify() { | 198 void NetworkStateInformer::UpdateStateAndNotify() { |
| 198 if (UpdateState()) | 199 if (UpdateState()) |
| 199 SendStateToObservers(ErrorScreenActor::ERROR_REASON_NETWORK_STATE_CHANGED); | 200 SendStateToObservers(NetworkError::ERROR_REASON_NETWORK_STATE_CHANGED); |
| 200 else | 201 else |
| 201 SendStateToObservers(ErrorScreenActor::ERROR_REASON_UPDATE); | 202 SendStateToObservers(NetworkError::ERROR_REASON_UPDATE); |
| 202 } | 203 } |
| 203 | 204 |
| 204 void NetworkStateInformer::SendStateToObservers( | 205 void NetworkStateInformer::SendStateToObservers( |
| 205 ErrorScreenActor::ErrorReason reason) { | 206 NetworkError::ErrorReason reason) { |
| 206 FOR_EACH_OBSERVER(NetworkStateInformerObserver, observers_, | 207 FOR_EACH_OBSERVER(NetworkStateInformerObserver, observers_, |
| 207 UpdateState(reason)); | 208 UpdateState(reason)); |
| 208 } | 209 } |
| 209 | 210 |
| 210 } // namespace chromeos | 211 } // namespace chromeos |
| OLD | NEW |