| 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/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 | 117 |
| 118 namespace { | 118 namespace { |
| 119 | 119 |
| 120 bool IsOnline(NetworkStateInformer::State state, | 120 bool IsOnline(NetworkStateInformer::State state, |
| 121 ErrorScreenActor::ErrorReason reason) { | 121 ErrorScreenActor::ErrorReason reason) { |
| 122 return state == NetworkStateInformer::ONLINE && | 122 return state == NetworkStateInformer::ONLINE && |
| 123 reason != ErrorScreenActor::ERROR_REASON_PORTAL_DETECTED && | 123 reason != ErrorScreenActor::ERROR_REASON_PORTAL_DETECTED && |
| 124 reason != ErrorScreenActor::ERROR_REASON_LOADING_TIMEOUT; | 124 reason != ErrorScreenActor::ERROR_REASON_LOADING_TIMEOUT; |
| 125 } | 125 } |
| 126 | 126 |
| 127 bool IsUnderCaptivePortal(NetworkStateInformer::State state, | 127 bool IsBehindCaptivePortal(NetworkStateInformer::State state, |
| 128 ErrorScreenActor::ErrorReason reason) { | 128 ErrorScreenActor::ErrorReason reason) { |
| 129 return state == NetworkStateInformer::CAPTIVE_PORTAL || | 129 return state == NetworkStateInformer::CAPTIVE_PORTAL || |
| 130 reason == ErrorScreenActor::ERROR_REASON_PORTAL_DETECTED; | 130 reason == ErrorScreenActor::ERROR_REASON_PORTAL_DETECTED; |
| 131 } | 131 } |
| 132 | 132 |
| 133 bool IsProxyError(NetworkStateInformer::State state, | 133 bool IsProxyError(NetworkStateInformer::State state, |
| 134 ErrorScreenActor::ErrorReason reason, | 134 ErrorScreenActor::ErrorReason reason, |
| 135 net::Error frame_error) { | 135 net::Error frame_error) { |
| 136 return state == NetworkStateInformer::PROXY_AUTH_REQUIRED || | 136 return state == NetworkStateInformer::PROXY_AUTH_REQUIRED || |
| 137 reason == ErrorScreenActor::ERROR_REASON_PROXY_AUTH_CANCELLED || | 137 reason == ErrorScreenActor::ERROR_REASON_PROXY_AUTH_CANCELLED || |
| 138 reason == ErrorScreenActor::ERROR_REASON_PROXY_CONNECTION_FAILED || | 138 reason == ErrorScreenActor::ERROR_REASON_PROXY_CONNECTION_FAILED || |
| (...skipping 16 matching lines...) Expand all Loading... |
| 155 | 155 |
| 156 // Returns network name by service path. | 156 // Returns network name by service path. |
| 157 std::string GetNetworkName(const std::string& service_path) { | 157 std::string GetNetworkName(const std::string& service_path) { |
| 158 const NetworkState* network = NetworkHandler::Get()->network_state_handler()-> | 158 const NetworkState* network = NetworkHandler::Get()->network_state_handler()-> |
| 159 GetNetworkState(service_path); | 159 GetNetworkState(service_path); |
| 160 if (!network) | 160 if (!network) |
| 161 return std::string(); | 161 return std::string(); |
| 162 return network->name(); | 162 return network->name(); |
| 163 } | 163 } |
| 164 | 164 |
| 165 // Returns captive portal state for a network by its service path. | |
| 166 NetworkPortalDetector::CaptivePortalState GetCaptivePortalState( | |
| 167 const std::string& service_path) { | |
| 168 NetworkPortalDetector* detector = NetworkPortalDetector::Get(); | |
| 169 const NetworkState* network = NetworkHandler::Get()->network_state_handler()-> | |
| 170 GetNetworkState(service_path); | |
| 171 if (!detector || !network) | |
| 172 return NetworkPortalDetector::CaptivePortalState(); | |
| 173 return detector->GetCaptivePortalState(network); | |
| 174 } | |
| 175 | |
| 176 void RecordDiscrepancyWithShill( | |
| 177 const NetworkState* network, | |
| 178 const NetworkPortalDetector::CaptivePortalStatus status) { | |
| 179 if (network->connection_state() == shill::kStateOnline) { | |
| 180 UMA_HISTOGRAM_ENUMERATION( | |
| 181 "CaptivePortal.OOBE.DiscrepancyWithShill_Online", | |
| 182 status, | |
| 183 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT); | |
| 184 } else if (network->connection_state() == shill::kStatePortal) { | |
| 185 UMA_HISTOGRAM_ENUMERATION( | |
| 186 "CaptivePortal.OOBE.DiscrepancyWithShill_RestrictedPool", | |
| 187 status, | |
| 188 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT); | |
| 189 } else { | |
| 190 UMA_HISTOGRAM_ENUMERATION( | |
| 191 "CaptivePortal.OOBE.DiscrepancyWithShill_Offline", | |
| 192 status, | |
| 193 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT); | |
| 194 } | |
| 195 } | |
| 196 | |
| 197 // Record state and descripancies with shill (e.g. shill thinks that | |
| 198 // network is online but NetworkPortalDetector claims that it's behind | |
| 199 // portal) for the network identified by |service_path|. | |
| 200 void RecordNetworkPortalDetectorStats(const std::string& service_path) { | |
| 201 const NetworkState* network = NetworkHandler::Get()->network_state_handler()-> | |
| 202 GetNetworkState(service_path); | |
| 203 if (!network) | |
| 204 return; | |
| 205 NetworkPortalDetector::CaptivePortalState state = | |
| 206 GetCaptivePortalState(service_path); | |
| 207 if (state.status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN) | |
| 208 return; | |
| 209 | |
| 210 UMA_HISTOGRAM_ENUMERATION("CaptivePortal.OOBE.DetectionResult", | |
| 211 state.status, | |
| 212 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT); | |
| 213 | |
| 214 switch (state.status) { | |
| 215 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN: | |
| 216 NOTREACHED(); | |
| 217 break; | |
| 218 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_OFFLINE: | |
| 219 if (network->connection_state() == shill::kStateOnline || | |
| 220 network->connection_state() == shill::kStatePortal) | |
| 221 RecordDiscrepancyWithShill(network, state.status); | |
| 222 break; | |
| 223 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE: | |
| 224 if (network->connection_state() != shill::kStateOnline) | |
| 225 RecordDiscrepancyWithShill(network, state.status); | |
| 226 break; | |
| 227 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL: | |
| 228 if (network->connection_state() != shill::kStatePortal) | |
| 229 RecordDiscrepancyWithShill(network, state.status); | |
| 230 break; | |
| 231 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED: | |
| 232 if (network->connection_state() != shill::kStateOnline) | |
| 233 RecordDiscrepancyWithShill(network, state.status); | |
| 234 break; | |
| 235 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT: | |
| 236 NOTREACHED(); | |
| 237 break; | |
| 238 } | |
| 239 } | |
| 240 | |
| 241 static bool SetUserInputMethodImpl( | 165 static bool SetUserInputMethodImpl( |
| 242 const std::string& username, | 166 const std::string& username, |
| 243 chromeos::input_method::InputMethodManager* manager) { | 167 chromeos::input_method::InputMethodManager* manager) { |
| 244 PrefService* const local_state = g_browser_process->local_state(); | 168 PrefService* const local_state = g_browser_process->local_state(); |
| 245 | 169 |
| 246 const base::DictionaryValue* users_lru_input_methods = | 170 const base::DictionaryValue* users_lru_input_methods = |
| 247 local_state->GetDictionary(prefs::kUsersLRUInputMethod); | 171 local_state->GetDictionary(prefs::kUsersLRUInputMethod); |
| 248 | 172 |
| 249 if (users_lru_input_methods == NULL) { | 173 if (users_lru_input_methods == NULL) { |
| 250 DLOG(WARNING) << "SetUserInputMethod('" << username | 174 DLOG(WARNING) << "SetUserInputMethod('" << username |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 base::MessageLoop::current()->PostDelayedTask( | 523 base::MessageLoop::current()->PostDelayedTask( |
| 600 FROM_HERE, | 524 FROM_HERE, |
| 601 connecting_closure_.callback(), | 525 connecting_closure_.callback(), |
| 602 base::TimeDelta::FromSeconds(kConnectingTimeoutSec)); | 526 base::TimeDelta::FromSeconds(kConnectingTimeoutSec)); |
| 603 } | 527 } |
| 604 return; | 528 return; |
| 605 } | 529 } |
| 606 connecting_closure_.Cancel(); | 530 connecting_closure_.Cancel(); |
| 607 | 531 |
| 608 const bool is_online = IsOnline(state, reason); | 532 const bool is_online = IsOnline(state, reason); |
| 609 const bool is_under_captive_portal = IsUnderCaptivePortal(state, reason); | 533 const bool is_behind_captive_portal = IsBehindCaptivePortal(state, reason); |
| 610 const bool is_gaia_loading_timeout = | 534 const bool is_gaia_loading_timeout = |
| 611 (reason == ErrorScreenActor::ERROR_REASON_LOADING_TIMEOUT); | 535 (reason == ErrorScreenActor::ERROR_REASON_LOADING_TIMEOUT); |
| 612 const bool is_gaia_error = | 536 const bool is_gaia_error = |
| 613 FrameError() != net::OK && FrameError() != net::ERR_NETWORK_CHANGED; | 537 FrameError() != net::OK && FrameError() != net::ERR_NETWORK_CHANGED; |
| 614 const bool is_gaia_signin = IsGaiaVisible() || IsGaiaHiddenByError(); | 538 const bool is_gaia_signin = IsGaiaVisible() || IsGaiaHiddenByError(); |
| 615 const bool error_screen_should_overlay = | 539 const bool error_screen_should_overlay = |
| 616 !offline_login_active_ && IsGaiaVisible(); | 540 !offline_login_active_ && IsGaiaVisible(); |
| 617 const bool from_not_online_to_online_transition = | 541 const bool from_not_online_to_online_transition = |
| 618 is_online && last_network_state_ != NetworkStateInformer::ONLINE; | 542 is_online && last_network_state_ != NetworkStateInformer::ONLINE; |
| 619 last_network_state_ = state; | 543 last_network_state_ = state; |
| 620 | 544 |
| 621 if (is_online || !is_under_captive_portal) | 545 if (is_online || !is_behind_captive_portal) |
| 622 error_screen_actor_->HideCaptivePortal(); | 546 error_screen_actor_->HideCaptivePortal(); |
| 623 | 547 |
| 624 // Hide offline message (if needed) and return if current screen is | 548 // Hide offline message (if needed) and return if current screen is |
| 625 // not a Gaia frame. | 549 // not a Gaia frame. |
| 626 if (!is_gaia_signin) { | 550 if (!is_gaia_signin) { |
| 627 if (!IsSigninScreenHiddenByError()) | 551 if (!IsSigninScreenHiddenByError()) |
| 628 HideOfflineMessage(state, reason); | 552 HideOfflineMessage(state, reason); |
| 629 return; | 553 return; |
| 630 } | 554 } |
| 631 | 555 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 656 SetupAndShowOfflineMessage(state, reason); | 580 SetupAndShowOfflineMessage(state, reason); |
| 657 } else { | 581 } else { |
| 658 HideOfflineMessage(state, reason); | 582 HideOfflineMessage(state, reason); |
| 659 } | 583 } |
| 660 } | 584 } |
| 661 | 585 |
| 662 void SigninScreenHandler::SetupAndShowOfflineMessage( | 586 void SigninScreenHandler::SetupAndShowOfflineMessage( |
| 663 NetworkStateInformer:: State state, | 587 NetworkStateInformer:: State state, |
| 664 ErrorScreenActor::ErrorReason reason) { | 588 ErrorScreenActor::ErrorReason reason) { |
| 665 const std::string network_path = network_state_informer_->network_path(); | 589 const std::string network_path = network_state_informer_->network_path(); |
| 666 const bool is_under_captive_portal = IsUnderCaptivePortal(state, reason); | 590 const bool is_behind_captive_portal = IsBehindCaptivePortal(state, reason); |
| 667 const bool is_proxy_error = IsProxyError(state, reason, FrameError()); | 591 const bool is_proxy_error = IsProxyError(state, reason, FrameError()); |
| 668 const bool is_gaia_loading_timeout = | 592 const bool is_gaia_loading_timeout = |
| 669 (reason == ErrorScreenActor::ERROR_REASON_LOADING_TIMEOUT); | 593 (reason == ErrorScreenActor::ERROR_REASON_LOADING_TIMEOUT); |
| 670 | 594 |
| 671 // Record portal detection stats only if we're going to show or | |
| 672 // change state of the error screen. | |
| 673 RecordNetworkPortalDetectorStats(network_path); | |
| 674 | |
| 675 if (is_proxy_error) { | 595 if (is_proxy_error) { |
| 676 error_screen_actor_->SetErrorState(ErrorScreen::ERROR_STATE_PROXY, | 596 error_screen_actor_->SetErrorState(ErrorScreen::ERROR_STATE_PROXY, |
| 677 std::string()); | 597 std::string()); |
| 678 } else if (is_under_captive_portal) { | 598 } else if (is_behind_captive_portal) { |
| 679 // Do not bother a user with obsessive captive portal showing. This | 599 // Do not bother a user with obsessive captive portal showing. This |
| 680 // check makes captive portal being shown only once: either when error | 600 // check makes captive portal being shown only once: either when error |
| 681 // screen is shown for the first time or when switching from another | 601 // screen is shown for the first time or when switching from another |
| 682 // error screen (offline, proxy). | 602 // error screen (offline, proxy). |
| 683 if (IsGaiaVisible() || | 603 if (IsGaiaVisible() || |
| 684 (error_screen_actor_->error_state() != | 604 (error_screen_actor_->error_state() != |
| 685 ErrorScreen::ERROR_STATE_PORTAL)) { | 605 ErrorScreen::ERROR_STATE_PORTAL)) { |
| 686 error_screen_actor_->FixCaptivePortal(); | 606 error_screen_actor_->FixCaptivePortal(); |
| 687 } | 607 } |
| 688 const std::string network_name = GetNetworkName(network_path); | 608 const std::string network_name = GetNetworkName(network_path); |
| (...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1705 DCHECK(gaia_screen_handler_); | 1625 DCHECK(gaia_screen_handler_); |
| 1706 return gaia_screen_handler_->frame_state(); | 1626 return gaia_screen_handler_->frame_state(); |
| 1707 } | 1627 } |
| 1708 | 1628 |
| 1709 net::Error SigninScreenHandler::FrameError() const { | 1629 net::Error SigninScreenHandler::FrameError() const { |
| 1710 DCHECK(gaia_screen_handler_); | 1630 DCHECK(gaia_screen_handler_); |
| 1711 return gaia_screen_handler_->frame_error(); | 1631 return gaia_screen_handler_->frame_error(); |
| 1712 } | 1632 } |
| 1713 | 1633 |
| 1714 } // namespace chromeos | 1634 } // namespace chromeos |
| OLD | NEW |