OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/signin_screen_handler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/metrics/histogram.h" |
12 #include "base/string16.h" | 13 #include "base/string16.h" |
13 #include "base/string_util.h" | 14 #include "base/string_util.h" |
14 #include "base/stringprintf.h" | 15 #include "base/stringprintf.h" |
15 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
16 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
17 #include "chrome/browser/browser_shutdown.h" | 18 #include "chrome/browser/browser_shutdown.h" |
18 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 19 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
19 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 20 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
20 #include "chrome/browser/chromeos/cros/cros_library.h" | 21 #include "chrome/browser/chromeos/cros/cros_library.h" |
21 #include "chrome/browser/chromeos/cros/network_library.h" | 22 #include "chrome/browser/chromeos/cros/network_library.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 // Returns captive portal state for a network by its service path. | 189 // Returns captive portal state for a network by its service path. |
189 NetworkPortalDetector::CaptivePortalState GetCaptivePortalState( | 190 NetworkPortalDetector::CaptivePortalState GetCaptivePortalState( |
190 const std::string& service_path) { | 191 const std::string& service_path) { |
191 NetworkPortalDetector* detector = NetworkPortalDetector::GetInstance(); | 192 NetworkPortalDetector* detector = NetworkPortalDetector::GetInstance(); |
192 Network* network = FindNetworkByPath(service_path); | 193 Network* network = FindNetworkByPath(service_path); |
193 if (!detector || !network) | 194 if (!detector || !network) |
194 return NetworkPortalDetector::CaptivePortalState(); | 195 return NetworkPortalDetector::CaptivePortalState(); |
195 return detector->GetCaptivePortalState(network); | 196 return detector->GetCaptivePortalState(network); |
196 } | 197 } |
197 | 198 |
| 199 void RecordDiscrepancyWithShill( |
| 200 const Network* network, |
| 201 const NetworkPortalDetector::CaptivePortalStatus status) { |
| 202 if (network->online()) { |
| 203 UMA_HISTOGRAM_ENUMERATION( |
| 204 "CaptivePortal.OOBE.DiscrepancyWithShill.Online", |
| 205 status, |
| 206 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT); |
| 207 } else if (network->restricted_pool()) { |
| 208 UMA_HISTOGRAM_ENUMERATION( |
| 209 "CaptivePortal.OOBE.DiscrepancyWithShill.RestrictedPool", |
| 210 status, |
| 211 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT); |
| 212 } else { |
| 213 UMA_HISTOGRAM_ENUMERATION( |
| 214 "CaptivePortal.OOBE.DiscrepancyWithShill.Offline", |
| 215 status, |
| 216 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT); |
| 217 } |
| 218 } |
| 219 |
| 220 // Record state and descripancies with shill (e.g. shill thinks that |
| 221 // network is online but NetworkPortalDetector claims that it's behind |
| 222 // portal) for the network identified by |service_path|. |
| 223 void RecordNetworkPortalDetectorStats(const std::string& service_path) { |
| 224 const Network* network = FindNetworkByPath(service_path); |
| 225 if (!network) |
| 226 return; |
| 227 NetworkPortalDetector::CaptivePortalState state = |
| 228 GetCaptivePortalState(service_path); |
| 229 if (state.status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN) |
| 230 return; |
| 231 |
| 232 UMA_HISTOGRAM_ENUMERATION("CaptivePortal.OOBE.DetectionResult", |
| 233 state.status, |
| 234 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT); |
| 235 |
| 236 switch (state.status) { |
| 237 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN: |
| 238 NOTREACHED(); |
| 239 break; |
| 240 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_OFFLINE: |
| 241 if (network->online() || network->restricted_pool()) |
| 242 RecordDiscrepancyWithShill(network, state.status); |
| 243 break; |
| 244 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE: |
| 245 if (!network->online()) |
| 246 RecordDiscrepancyWithShill(network, state.status); |
| 247 break; |
| 248 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL: |
| 249 if (!network->restricted_pool()) |
| 250 RecordDiscrepancyWithShill(network, state.status); |
| 251 break; |
| 252 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED: |
| 253 if (!network->online()) |
| 254 RecordDiscrepancyWithShill(network, state.status); |
| 255 break; |
| 256 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT: |
| 257 NOTREACHED(); |
| 258 break; |
| 259 } |
| 260 } |
| 261 |
198 } // namespace | 262 } // namespace |
199 | 263 |
200 // SigninScreenHandler implementation ------------------------------------------ | 264 // SigninScreenHandler implementation ------------------------------------------ |
201 | 265 |
202 SigninScreenHandler::SigninScreenHandler( | 266 SigninScreenHandler::SigninScreenHandler( |
203 const scoped_refptr<NetworkStateInformer>& network_state_informer, | 267 const scoped_refptr<NetworkStateInformer>& network_state_informer, |
204 ErrorScreenActor* error_screen_actor) | 268 ErrorScreenActor* error_screen_actor) |
205 : ui_state_(UI_STATE_UNKNOWN), | 269 : ui_state_(UI_STATE_UNKNOWN), |
206 delegate_(NULL), | 270 delegate_(NULL), |
207 native_window_delegate_(NULL), | 271 native_window_delegate_(NULL), |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 } | 609 } |
546 | 610 |
547 if (is_online || !is_under_captive_portal) | 611 if (is_online || !is_under_captive_portal) |
548 error_screen_actor_->HideCaptivePortal(); | 612 error_screen_actor_->HideCaptivePortal(); |
549 | 613 |
550 if (!is_online && is_gaia_signin && !offline_login_active_) { | 614 if (!is_online && is_gaia_signin && !offline_login_active_) { |
551 LOG(WARNING) << "Show offline message: state=" << state << ", " | 615 LOG(WARNING) << "Show offline message: state=" << state << ", " |
552 << "network_id=" << network_id << ", " | 616 << "network_id=" << network_id << ", " |
553 << "reason=" << reason << ", " | 617 << "reason=" << reason << ", " |
554 << "is_under_captive_portal=" << is_under_captive_portal; | 618 << "is_under_captive_portal=" << is_under_captive_portal; |
| 619 |
| 620 // Record portal detection stats only if we're going to show or |
| 621 // change state of the error screen. |
| 622 RecordNetworkPortalDetectorStats(service_path); |
| 623 |
555 if (is_proxy_error) { | 624 if (is_proxy_error) { |
556 error_screen_actor_->ShowProxyError(); | 625 error_screen_actor_->ShowProxyError(); |
557 } else if (is_under_captive_portal) { | 626 } else if (is_under_captive_portal) { |
558 // Do not bother a user with obsessive captive portal showing. This | 627 // Do not bother a user with obsessive captive portal showing. This |
559 // check makes captive portal being shown only once: either when error | 628 // check makes captive portal being shown only once: either when error |
560 // screen is shown for the first time or when switching from another | 629 // screen is shown for the first time or when switching from another |
561 // error screen (offline, proxy). | 630 // error screen (offline, proxy). |
562 if (!IsGaiaLogin() || | 631 if (!IsGaiaLogin() || |
563 (error_screen_actor_->state() != | 632 (error_screen_actor_->state() != |
564 ErrorScreenActor::STATE_CAPTIVE_PORTAL_ERROR)) { | 633 ErrorScreenActor::STATE_CAPTIVE_PORTAL_ERROR)) { |
(...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1660 if (!cros_settings) | 1729 if (!cros_settings) |
1661 return false; | 1730 return false; |
1662 | 1731 |
1663 // Offline login is allowed only when user pods are hidden. | 1732 // Offline login is allowed only when user pods are hidden. |
1664 bool show_pods; | 1733 bool show_pods; |
1665 cros_settings->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, &show_pods); | 1734 cros_settings->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, &show_pods); |
1666 return !show_pods; | 1735 return !show_pods; |
1667 } | 1736 } |
1668 | 1737 |
1669 } // namespace chromeos | 1738 } // namespace chromeos |
OLD | NEW |