| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 } | 250 } |
| 251 | 251 |
| 252 void LoginScreenContext::Init() { | 252 void LoginScreenContext::Init() { |
| 253 oobe_ui_ = false; | 253 oobe_ui_ = false; |
| 254 } | 254 } |
| 255 | 255 |
| 256 // SigninScreenHandler implementation ------------------------------------------ | 256 // SigninScreenHandler implementation ------------------------------------------ |
| 257 | 257 |
| 258 SigninScreenHandler::SigninScreenHandler( | 258 SigninScreenHandler::SigninScreenHandler( |
| 259 const scoped_refptr<NetworkStateInformer>& network_state_informer, | 259 const scoped_refptr<NetworkStateInformer>& network_state_informer, |
| 260 NetworkErrorModel* network_error_model, | 260 ErrorScreen* error_screen, |
| 261 CoreOobeActor* core_oobe_actor, | 261 CoreOobeActor* core_oobe_actor, |
| 262 GaiaScreenHandler* gaia_screen_handler) | 262 GaiaScreenHandler* gaia_screen_handler) |
| 263 : network_state_informer_(network_state_informer), | 263 : network_state_informer_(network_state_informer), |
| 264 network_error_model_(network_error_model), | 264 error_screen_(error_screen), |
| 265 core_oobe_actor_(core_oobe_actor), | 265 core_oobe_actor_(core_oobe_actor), |
| 266 caps_lock_enabled_(chromeos::input_method::InputMethodManager::Get() | 266 caps_lock_enabled_(chromeos::input_method::InputMethodManager::Get() |
| 267 ->GetImeKeyboard() | 267 ->GetImeKeyboard() |
| 268 ->CapsLockIsEnabled()), | 268 ->CapsLockIsEnabled()), |
| 269 proxy_auth_dialog_reload_times_(kMaxGaiaReloadForProxyAuthDialog), | 269 proxy_auth_dialog_reload_times_(kMaxGaiaReloadForProxyAuthDialog), |
| 270 gaia_screen_handler_(gaia_screen_handler), | 270 gaia_screen_handler_(gaia_screen_handler), |
| 271 touch_view_binding_(this), | 271 touch_view_binding_(this), |
| 272 histogram_helper_(new ErrorScreensHistogramHelper("Signin")), | 272 histogram_helper_(new ErrorScreensHistogramHelper("Signin")), |
| 273 weak_factory_(this) { | 273 weak_factory_(this) { |
| 274 DCHECK(network_state_informer_.get()); | 274 DCHECK(network_state_informer_.get()); |
| 275 DCHECK(network_error_model_); | 275 DCHECK(error_screen_); |
| 276 DCHECK(core_oobe_actor_); | 276 DCHECK(core_oobe_actor_); |
| 277 gaia_screen_handler_->set_signin_screen_handler(this); | 277 gaia_screen_handler_->set_signin_screen_handler(this); |
| 278 network_state_informer_->AddObserver(this); | 278 network_state_informer_->AddObserver(this); |
| 279 | 279 |
| 280 registrar_.Add(this, | 280 registrar_.Add(this, |
| 281 chrome::NOTIFICATION_AUTH_NEEDED, | 281 chrome::NOTIFICATION_AUTH_NEEDED, |
| 282 content::NotificationService::AllSources()); | 282 content::NotificationService::AllSources()); |
| 283 registrar_.Add(this, | 283 registrar_.Add(this, |
| 284 chrome::NOTIFICATION_AUTH_SUPPLIED, | 284 chrome::NOTIFICATION_AUTH_SUPPLIED, |
| 285 content::NotificationService::AllSources()); | 285 content::NotificationService::AllSources()); |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 last_network_state_ = state; | 760 last_network_state_ = state; |
| 761 proxy_auth_dialog_need_reload_ = | 761 proxy_auth_dialog_need_reload_ = |
| 762 (reason == NetworkError::ERROR_REASON_NETWORK_STATE_CHANGED) && | 762 (reason == NetworkError::ERROR_REASON_NETWORK_STATE_CHANGED) && |
| 763 (state == NetworkStateInformer::PROXY_AUTH_REQUIRED) && | 763 (state == NetworkStateInformer::PROXY_AUTH_REQUIRED) && |
| 764 (proxy_auth_dialog_reload_times_ > 0); | 764 (proxy_auth_dialog_reload_times_ > 0); |
| 765 | 765 |
| 766 CallOnReturn reload_gaia(base::Bind( | 766 CallOnReturn reload_gaia(base::Bind( |
| 767 &SigninScreenHandler::ReloadGaia, weak_factory_.GetWeakPtr(), true)); | 767 &SigninScreenHandler::ReloadGaia, weak_factory_.GetWeakPtr(), true)); |
| 768 | 768 |
| 769 if (is_online || !is_behind_captive_portal) | 769 if (is_online || !is_behind_captive_portal) |
| 770 network_error_model_->HideCaptivePortal(); | 770 error_screen_->HideCaptivePortal(); |
| 771 | 771 |
| 772 // Hide offline message (if needed) and return if current screen is | 772 // Hide offline message (if needed) and return if current screen is |
| 773 // not a Gaia frame. | 773 // not a Gaia frame. |
| 774 if (!is_gaia_signin) { | 774 if (!is_gaia_signin) { |
| 775 if (!IsSigninScreenHiddenByError()) | 775 if (!IsSigninScreenHiddenByError()) |
| 776 HideOfflineMessage(state, reason); | 776 HideOfflineMessage(state, reason); |
| 777 return; | 777 return; |
| 778 } | 778 } |
| 779 | 779 |
| 780 // Use the online login page if the user has not used the machine for awhile. | 780 // Use the online login page if the user has not used the machine for awhile. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 void SigninScreenHandler::SetupAndShowOfflineMessage( | 833 void SigninScreenHandler::SetupAndShowOfflineMessage( |
| 834 NetworkStateInformer::State state, | 834 NetworkStateInformer::State state, |
| 835 NetworkError::ErrorReason reason) { | 835 NetworkError::ErrorReason reason) { |
| 836 const std::string network_path = network_state_informer_->network_path(); | 836 const std::string network_path = network_state_informer_->network_path(); |
| 837 const bool is_behind_captive_portal = IsBehindCaptivePortal(state, reason); | 837 const bool is_behind_captive_portal = IsBehindCaptivePortal(state, reason); |
| 838 const bool is_proxy_error = IsProxyError(state, reason, FrameError()); | 838 const bool is_proxy_error = IsProxyError(state, reason, FrameError()); |
| 839 const bool is_gaia_loading_timeout = | 839 const bool is_gaia_loading_timeout = |
| 840 (reason == NetworkError::ERROR_REASON_LOADING_TIMEOUT); | 840 (reason == NetworkError::ERROR_REASON_LOADING_TIMEOUT); |
| 841 | 841 |
| 842 if (is_proxy_error) { | 842 if (is_proxy_error) { |
| 843 network_error_model_->SetErrorState(NetworkError::ERROR_STATE_PROXY, | 843 error_screen_->SetErrorState(NetworkError::ERROR_STATE_PROXY, |
| 844 std::string()); | 844 std::string()); |
| 845 } else if (is_behind_captive_portal) { | 845 } else if (is_behind_captive_portal) { |
| 846 // Do not bother a user with obsessive captive portal showing. This | 846 // Do not bother a user with obsessive captive portal showing. This |
| 847 // check makes captive portal being shown only once: either when error | 847 // check makes captive portal being shown only once: either when error |
| 848 // screen is shown for the first time or when switching from another | 848 // screen is shown for the first time or when switching from another |
| 849 // error screen (offline, proxy). | 849 // error screen (offline, proxy). |
| 850 if (IsGaiaVisible() || (network_error_model_->GetErrorState() != | 850 if (IsGaiaVisible() || |
| 851 NetworkError::ERROR_STATE_PORTAL)) { | 851 (error_screen_->GetErrorState() != NetworkError::ERROR_STATE_PORTAL)) { |
| 852 network_error_model_->FixCaptivePortal(); | 852 error_screen_->FixCaptivePortal(); |
| 853 } | 853 } |
| 854 const std::string network_name = GetNetworkName(network_path); | 854 const std::string network_name = GetNetworkName(network_path); |
| 855 network_error_model_->SetErrorState(NetworkError::ERROR_STATE_PORTAL, | 855 error_screen_->SetErrorState(NetworkError::ERROR_STATE_PORTAL, |
| 856 network_name); | 856 network_name); |
| 857 } else if (is_gaia_loading_timeout) { | 857 } else if (is_gaia_loading_timeout) { |
| 858 network_error_model_->SetErrorState( | 858 error_screen_->SetErrorState(NetworkError::ERROR_STATE_AUTH_EXT_TIMEOUT, |
| 859 NetworkError::ERROR_STATE_AUTH_EXT_TIMEOUT, std::string()); | 859 std::string()); |
| 860 } else { | 860 } else { |
| 861 network_error_model_->SetErrorState(NetworkError::ERROR_STATE_OFFLINE, | 861 error_screen_->SetErrorState(NetworkError::ERROR_STATE_OFFLINE, |
| 862 std::string()); | 862 std::string()); |
| 863 } | 863 } |
| 864 | 864 |
| 865 const bool guest_signin_allowed = | 865 const bool guest_signin_allowed = |
| 866 IsGuestSigninAllowed() && | 866 IsGuestSigninAllowed() && |
| 867 IsSigninScreenError(network_error_model_->GetErrorState()); | 867 IsSigninScreenError(error_screen_->GetErrorState()); |
| 868 network_error_model_->AllowGuestSignin(guest_signin_allowed); | 868 error_screen_->AllowGuestSignin(guest_signin_allowed); |
| 869 | 869 |
| 870 const bool offline_login_allowed = | 870 const bool offline_login_allowed = |
| 871 IsSigninScreenError(network_error_model_->GetErrorState()) && | 871 IsSigninScreenError(error_screen_->GetErrorState()) && |
| 872 network_error_model_->GetErrorState() != | 872 error_screen_->GetErrorState() != |
| 873 NetworkError::ERROR_STATE_AUTH_EXT_TIMEOUT; | 873 NetworkError::ERROR_STATE_AUTH_EXT_TIMEOUT; |
| 874 network_error_model_->AllowOfflineLogin(offline_login_allowed); | 874 error_screen_->AllowOfflineLogin(offline_login_allowed); |
| 875 | 875 |
| 876 if (GetCurrentScreen() != OobeScreen::SCREEN_ERROR_MESSAGE) { | 876 if (GetCurrentScreen() != OobeScreen::SCREEN_ERROR_MESSAGE) { |
| 877 network_error_model_->SetUIState(NetworkError::UI_STATE_SIGNIN); | 877 error_screen_->SetUIState(NetworkError::UI_STATE_SIGNIN); |
| 878 network_error_model_->SetParentScreen(OobeScreen::SCREEN_GAIA_SIGNIN); | 878 error_screen_->SetParentScreen(OobeScreen::SCREEN_GAIA_SIGNIN); |
| 879 network_error_model_->Show(); | 879 error_screen_->Show(); |
| 880 histogram_helper_->OnErrorShow(network_error_model_->GetErrorState()); | 880 histogram_helper_->OnErrorShow(error_screen_->GetErrorState()); |
| 881 } | 881 } |
| 882 } | 882 } |
| 883 | 883 |
| 884 void SigninScreenHandler::HideOfflineMessage(NetworkStateInformer::State state, | 884 void SigninScreenHandler::HideOfflineMessage(NetworkStateInformer::State state, |
| 885 NetworkError::ErrorReason reason) { | 885 NetworkError::ErrorReason reason) { |
| 886 if (!IsSigninScreenHiddenByError()) | 886 if (!IsSigninScreenHiddenByError()) |
| 887 return; | 887 return; |
| 888 | 888 |
| 889 gaia_reload_reason_ = NetworkError::ERROR_REASON_NONE; | 889 gaia_reload_reason_ = NetworkError::ERROR_REASON_NONE; |
| 890 | 890 |
| 891 network_error_model_->Hide(); | 891 error_screen_->Hide(); |
| 892 histogram_helper_->OnErrorHide(); | 892 histogram_helper_->OnErrorHide(); |
| 893 | 893 |
| 894 // Forces a reload for Gaia screen on hiding error message. | 894 // Forces a reload for Gaia screen on hiding error message. |
| 895 if (IsGaiaVisible() || IsGaiaHiddenByError()) | 895 if (IsGaiaVisible() || IsGaiaHiddenByError()) |
| 896 ReloadGaia(reason == NetworkError::ERROR_REASON_NETWORK_STATE_CHANGED); | 896 ReloadGaia(reason == NetworkError::ERROR_REASON_NETWORK_STATE_CHANGED); |
| 897 } | 897 } |
| 898 | 898 |
| 899 void SigninScreenHandler::ReloadGaia(bool force_reload) { | 899 void SigninScreenHandler::ReloadGaia(bool force_reload) { |
| 900 gaia_screen_handler_->ReloadGaia(force_reload); | 900 gaia_screen_handler_->ReloadGaia(force_reload); |
| 901 } | 901 } |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1514 ui_state_ == UI_STATE_GAIA_SIGNIN; | 1514 ui_state_ == UI_STATE_GAIA_SIGNIN; |
| 1515 } | 1515 } |
| 1516 | 1516 |
| 1517 bool SigninScreenHandler::IsGaiaHiddenByError() const { | 1517 bool SigninScreenHandler::IsGaiaHiddenByError() const { |
| 1518 return IsSigninScreenHiddenByError() && | 1518 return IsSigninScreenHiddenByError() && |
| 1519 ui_state_ == UI_STATE_GAIA_SIGNIN; | 1519 ui_state_ == UI_STATE_GAIA_SIGNIN; |
| 1520 } | 1520 } |
| 1521 | 1521 |
| 1522 bool SigninScreenHandler::IsSigninScreenHiddenByError() const { | 1522 bool SigninScreenHandler::IsSigninScreenHiddenByError() const { |
| 1523 return (GetCurrentScreen() == OobeScreen::SCREEN_ERROR_MESSAGE) && | 1523 return (GetCurrentScreen() == OobeScreen::SCREEN_ERROR_MESSAGE) && |
| 1524 (IsSigninScreen(network_error_model_->GetParentScreen())); | 1524 (IsSigninScreen(error_screen_->GetParentScreen())); |
| 1525 } | 1525 } |
| 1526 | 1526 |
| 1527 bool SigninScreenHandler::IsGuestSigninAllowed() const { | 1527 bool SigninScreenHandler::IsGuestSigninAllowed() const { |
| 1528 CrosSettings* cros_settings = CrosSettings::Get(); | 1528 CrosSettings* cros_settings = CrosSettings::Get(); |
| 1529 if (!cros_settings) | 1529 if (!cros_settings) |
| 1530 return false; | 1530 return false; |
| 1531 bool allow_guest; | 1531 bool allow_guest; |
| 1532 cros_settings->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); | 1532 cros_settings->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); |
| 1533 return allow_guest; | 1533 return allow_guest; |
| 1534 } | 1534 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1549 } | 1549 } |
| 1550 | 1550 |
| 1551 void SigninScreenHandler::OnFeedbackFinished() { | 1551 void SigninScreenHandler::OnFeedbackFinished() { |
| 1552 CallJS("login.UnrecoverableCryptohomeErrorScreen.resumeAfterFeedbackUI"); | 1552 CallJS("login.UnrecoverableCryptohomeErrorScreen.resumeAfterFeedbackUI"); |
| 1553 | 1553 |
| 1554 // Recreate user's cryptohome after the feedback is attempted. | 1554 // Recreate user's cryptohome after the feedback is attempted. |
| 1555 HandleResyncUserData(); | 1555 HandleResyncUserData(); |
| 1556 } | 1556 } |
| 1557 | 1557 |
| 1558 } // namespace chromeos | 1558 } // namespace chromeos |
| OLD | NEW |