Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/network_state_informer.cc

Issue 242483003: Move CaptivePortalDetector to src/components/captive_portal (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move CaptivePortalDetector to a component Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 NetworkStateInformer::State GetStateForDefaultNetwork() { 44 NetworkStateInformer::State GetStateForDefaultNetwork() {
45 const NetworkState* network = 45 const NetworkState* network =
46 NetworkHandler::Get()->network_state_handler()->DefaultNetwork(); 46 NetworkHandler::Get()->network_state_handler()->DefaultNetwork();
47 if (!network) 47 if (!network)
48 return NetworkStateInformer::OFFLINE; 48 return NetworkStateInformer::OFFLINE;
49 49
50 if (NetworkPortalDetector::Get()->IsEnabled()) { 50 if (NetworkPortalDetector::Get()->IsEnabled()) {
51 NetworkPortalDetector::CaptivePortalState state = 51 NetworkPortalDetector::CaptivePortalState state =
52 NetworkPortalDetector::Get()->GetCaptivePortalState(network->path()); 52 NetworkPortalDetector::Get()->GetCaptivePortalState(network->path());
53 NetworkPortalDetector::CaptivePortalStatus status = state.status; 53 captive_portal::CaptivePortalStatus status = state.status;
54 if (status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN && 54 if (status == captive_portal::CAPTIVE_PORTAL_STATUS_UNKNOWN &&
55 NetworkState::StateIsConnecting(network->connection_state())) { 55 NetworkState::StateIsConnecting(network->connection_state())) {
56 return NetworkStateInformer::CONNECTING; 56 return NetworkStateInformer::CONNECTING;
57 } 57 }
58 // For proxy-less networks rely on shill's online state if 58 // For proxy-less networks rely on shill's online state if
59 // NetworkPortalDetector's state of current network is unknown. 59 // NetworkPortalDetector's state of current network is unknown.
60 if (status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE || 60 if (status == captive_portal::CAPTIVE_PORTAL_STATUS_ONLINE ||
61 (status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN && 61 (status == captive_portal::CAPTIVE_PORTAL_STATUS_UNKNOWN &&
62 !HasDefaultNetworkProxyConfigured() && 62 !HasDefaultNetworkProxyConfigured() &&
63 network->connection_state() == shill::kStateOnline)) { 63 network->connection_state() == shill::kStateOnline)) {
64 return NetworkStateInformer::ONLINE; 64 return NetworkStateInformer::ONLINE;
65 } 65 }
66 if (status == 66 if (status ==
67 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED && 67 captive_portal::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED &&
68 HasDefaultNetworkProxyConfigured()) { 68 HasDefaultNetworkProxyConfigured()) {
69 return NetworkStateInformer::PROXY_AUTH_REQUIRED; 69 return NetworkStateInformer::PROXY_AUTH_REQUIRED;
70 } 70 }
71 if (status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL || 71 if (status == captive_portal::CAPTIVE_PORTAL_STATUS_PORTAL ||
72 (status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN && 72 (status == captive_portal::CAPTIVE_PORTAL_STATUS_UNKNOWN &&
73 network->connection_state() == shill::kStatePortal)) 73 network->connection_state() == shill::kStatePortal))
74 return NetworkStateInformer::CAPTIVE_PORTAL; 74 return NetworkStateInformer::CAPTIVE_PORTAL;
75 } else { 75 } else {
76 if (NetworkState::StateIsConnecting(network->connection_state())) 76 if (NetworkState::StateIsConnecting(network->connection_state()))
77 return NetworkStateInformer::CONNECTING; 77 return NetworkStateInformer::CONNECTING;
78 if (network->connection_state() == shill::kStateOnline) 78 if (network->connection_state() == shill::kStateOnline)
79 return NetworkStateInformer::ONLINE; 79 return NetworkStateInformer::ONLINE;
80 if (network->connection_state() == shill::kStatePortal) 80 if (network->connection_state() == shill::kStatePortal)
81 return NetworkStateInformer::CAPTIVE_PORTAL; 81 return NetworkStateInformer::CAPTIVE_PORTAL;
82 } 82 }
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 SendStateToObservers(ErrorScreenActor::ERROR_REASON_UPDATE); 201 SendStateToObservers(ErrorScreenActor::ERROR_REASON_UPDATE);
202 } 202 }
203 203
204 void NetworkStateInformer::SendStateToObservers( 204 void NetworkStateInformer::SendStateToObservers(
205 ErrorScreenActor::ErrorReason reason) { 205 ErrorScreenActor::ErrorReason reason) {
206 FOR_EACH_OBSERVER(NetworkStateInformerObserver, observers_, 206 FOR_EACH_OBSERVER(NetworkStateInformerObserver, observers_,
207 UpdateState(reason)); 207 UpdateState(reason));
208 } 208 }
209 209
210 } // namespace chromeos 210 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698