| 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 15 matching lines...) Expand all Loading... |
| 26 #include "base/trace_event/trace_event.h" | 26 #include "base/trace_event/trace_event.h" |
| 27 #include "chrome/browser/browser_process.h" | 27 #include "chrome/browser/browser_process.h" |
| 28 #include "chrome/browser/browser_process_platform_part_chromeos.h" | 28 #include "chrome/browser/browser_process_platform_part_chromeos.h" |
| 29 #include "chrome/browser/browser_shutdown.h" | 29 #include "chrome/browser/browser_shutdown.h" |
| 30 #include "chrome/browser/chrome_notification_types.h" | 30 #include "chrome/browser/chrome_notification_types.h" |
| 31 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" | 31 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" |
| 32 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 32 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
| 33 #include "chrome/browser/chromeos/login/error_screens_histogram_helper.h" | 33 #include "chrome/browser/chromeos/login/error_screens_histogram_helper.h" |
| 34 #include "chrome/browser/chromeos/login/hwid_checker.h" | 34 #include "chrome/browser/chromeos/login/hwid_checker.h" |
| 35 #include "chrome/browser/chromeos/login/lock/screen_locker.h" | 35 #include "chrome/browser/chromeos/login/lock/screen_locker.h" |
| 36 #include "chrome/browser/chromeos/login/quick_unlock/pin_storage.h" |
| 37 #include "chrome/browser/chromeos/login/quick_unlock/pin_storage_factory.h" |
| 36 #include "chrome/browser/chromeos/login/reauth_stats.h" | 38 #include "chrome/browser/chromeos/login/reauth_stats.h" |
| 37 #include "chrome/browser/chromeos/login/screens/core_oobe_actor.h" | 39 #include "chrome/browser/chromeos/login/screens/core_oobe_actor.h" |
| 38 #include "chrome/browser/chromeos/login/screens/network_error.h" | 40 #include "chrome/browser/chromeos/login/screens/network_error.h" |
| 39 #include "chrome/browser/chromeos/login/startup_utils.h" | 41 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 40 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 42 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| 41 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 43 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
| 42 #include "chrome/browser/chromeos/login/ui/login_feedback.h" | 44 #include "chrome/browser/chromeos/login/ui/login_feedback.h" |
| 43 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" | 45 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" |
| 44 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" | 46 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" |
| 45 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | 47 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 registrar_.Add(this, | 263 registrar_.Add(this, |
| 262 chrome::NOTIFICATION_AUTH_NEEDED, | 264 chrome::NOTIFICATION_AUTH_NEEDED, |
| 263 content::NotificationService::AllSources()); | 265 content::NotificationService::AllSources()); |
| 264 registrar_.Add(this, | 266 registrar_.Add(this, |
| 265 chrome::NOTIFICATION_AUTH_SUPPLIED, | 267 chrome::NOTIFICATION_AUTH_SUPPLIED, |
| 266 content::NotificationService::AllSources()); | 268 content::NotificationService::AllSources()); |
| 267 registrar_.Add(this, | 269 registrar_.Add(this, |
| 268 chrome::NOTIFICATION_AUTH_CANCELLED, | 270 chrome::NOTIFICATION_AUTH_CANCELLED, |
| 269 content::NotificationService::AllSources()); | 271 content::NotificationService::AllSources()); |
| 270 | 272 |
| 273 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver( |
| 274 this); |
| 275 |
| 271 chromeos::input_method::ImeKeyboard* keyboard = | 276 chromeos::input_method::ImeKeyboard* keyboard = |
| 272 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); | 277 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); |
| 273 if (keyboard) | 278 if (keyboard) |
| 274 keyboard->AddObserver(this); | 279 keyboard->AddObserver(this); |
| 275 | 280 |
| 276 if (!chrome::IsRunningInMash()) { | 281 if (!chrome::IsRunningInMash()) { |
| 277 max_mode_delegate_.reset(new TouchViewControllerDelegate()); | 282 max_mode_delegate_.reset(new TouchViewControllerDelegate()); |
| 278 max_mode_delegate_->AddObserver(this); | 283 max_mode_delegate_->AddObserver(this); |
| 279 } else { | 284 } else { |
| 280 NOTIMPLEMENTED(); | 285 NOTIMPLEMENTED(); |
| 281 } | 286 } |
| 282 } | 287 } |
| 283 | 288 |
| 284 SigninScreenHandler::~SigninScreenHandler() { | 289 SigninScreenHandler::~SigninScreenHandler() { |
| 285 OobeUI* oobe_ui = GetOobeUI(); | 290 OobeUI* oobe_ui = GetOobeUI(); |
| 286 if (oobe_ui && oobe_ui_observer_added_) | 291 if (oobe_ui && oobe_ui_observer_added_) |
| 287 oobe_ui->RemoveObserver(this); | 292 oobe_ui->RemoveObserver(this); |
| 293 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver( |
| 294 this); |
| 288 chromeos::input_method::ImeKeyboard* keyboard = | 295 chromeos::input_method::ImeKeyboard* keyboard = |
| 289 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); | 296 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); |
| 290 if (keyboard) | 297 if (keyboard) |
| 291 keyboard->RemoveObserver(this); | 298 keyboard->RemoveObserver(this); |
| 292 weak_factory_.InvalidateWeakPtrs(); | 299 weak_factory_.InvalidateWeakPtrs(); |
| 293 if (delegate_) | 300 if (delegate_) |
| 294 delegate_->SetWebUIHandler(nullptr); | 301 delegate_->SetWebUIHandler(nullptr); |
| 295 network_state_informer_->RemoveObserver(this); | 302 network_state_informer_->RemoveObserver(this); |
| 296 if (max_mode_delegate_) { | 303 if (max_mode_delegate_) { |
| 297 max_mode_delegate_->RemoveObserver(this); | 304 max_mode_delegate_->RemoveObserver(this); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 builder->Add("unrecoverableCryptohomeErrorMessage", | 469 builder->Add("unrecoverableCryptohomeErrorMessage", |
| 463 IDS_LOGIN_UNRECOVERABLE_CRYPTOHOME_ERROR_MESSAGE); | 470 IDS_LOGIN_UNRECOVERABLE_CRYPTOHOME_ERROR_MESSAGE); |
| 464 builder->Add("unrecoverableCryptohomeErrorContinue", | 471 builder->Add("unrecoverableCryptohomeErrorContinue", |
| 465 IDS_LOGIN_UNRECOVERABLE_CRYPTOHOME_ERROR_CONTINUE); | 472 IDS_LOGIN_UNRECOVERABLE_CRYPTOHOME_ERROR_CONTINUE); |
| 466 builder->Add("unrecoverableCryptohomeErrorRecreatingProfile", | 473 builder->Add("unrecoverableCryptohomeErrorRecreatingProfile", |
| 467 IDS_LOGIN_UNRECOVERABLE_CRYPTOHOME_ERROR_WAIT_MESSAGE); | 474 IDS_LOGIN_UNRECOVERABLE_CRYPTOHOME_ERROR_WAIT_MESSAGE); |
| 468 } | 475 } |
| 469 | 476 |
| 470 void SigninScreenHandler::RegisterMessages() { | 477 void SigninScreenHandler::RegisterMessages() { |
| 471 AddCallback("authenticateUser", &SigninScreenHandler::HandleAuthenticateUser); | 478 AddCallback("authenticateUser", &SigninScreenHandler::HandleAuthenticateUser); |
| 472 AddCallback("authenticateUserWithPin", | |
| 473 &SigninScreenHandler::HandleAuthenticateUserWithPin); | |
| 474 AddCallback("launchIncognito", &SigninScreenHandler::HandleLaunchIncognito); | 479 AddCallback("launchIncognito", &SigninScreenHandler::HandleLaunchIncognito); |
| 475 AddCallback("showSupervisedUserCreationScreen", | 480 AddCallback("showSupervisedUserCreationScreen", |
| 476 &SigninScreenHandler::HandleShowSupervisedUserCreationScreen); | 481 &SigninScreenHandler::HandleShowSupervisedUserCreationScreen); |
| 477 AddCallback("launchPublicSession", | 482 AddCallback("launchPublicSession", |
| 478 &SigninScreenHandler::HandleLaunchPublicSession); | 483 &SigninScreenHandler::HandleLaunchPublicSession); |
| 479 AddRawCallback("offlineLogin", &SigninScreenHandler::HandleOfflineLogin); | 484 AddRawCallback("offlineLogin", &SigninScreenHandler::HandleOfflineLogin); |
| 480 AddCallback("rebootSystem", &SigninScreenHandler::HandleRebootSystem); | 485 AddCallback("rebootSystem", &SigninScreenHandler::HandleRebootSystem); |
| 481 AddRawCallback("showAddUser", &SigninScreenHandler::HandleShowAddUser); | 486 AddRawCallback("showAddUser", &SigninScreenHandler::HandleShowAddUser); |
| 482 AddCallback("shutdownSystem", &SigninScreenHandler::HandleShutdownSystem); | 487 AddCallback("shutdownSystem", &SigninScreenHandler::HandleShutdownSystem); |
| 483 AddCallback("loadWallpaper", &SigninScreenHandler::HandleLoadWallpaper); | 488 AddCallback("loadWallpaper", &SigninScreenHandler::HandleLoadWallpaper); |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 865 } | 870 } |
| 866 | 871 |
| 867 void SigninScreenHandler::ClearUserPodPassword() { | 872 void SigninScreenHandler::ClearUserPodPassword() { |
| 868 core_oobe_actor_->ClearUserPodPassword(); | 873 core_oobe_actor_->ClearUserPodPassword(); |
| 869 } | 874 } |
| 870 | 875 |
| 871 void SigninScreenHandler::RefocusCurrentPod() { | 876 void SigninScreenHandler::RefocusCurrentPod() { |
| 872 core_oobe_actor_->RefocusCurrentPod(); | 877 core_oobe_actor_->RefocusCurrentPod(); |
| 873 } | 878 } |
| 874 | 879 |
| 880 void SigninScreenHandler::HidePinKeyboardIfNeeded(const AccountId& account_id) { |
| 881 chromeos::PinStorage* pin_storage = |
| 882 chromeos::PinStorageFactory::GetForAccountId(account_id); |
| 883 if (pin_storage && !pin_storage->IsPinAuthenticationAvailable()) |
| 884 CallJS("login.AccountPickerScreen.disablePinKeyboardForUser", account_id); |
| 885 } |
| 886 |
| 875 void SigninScreenHandler::OnUserRemoved(const AccountId& account_id, | 887 void SigninScreenHandler::OnUserRemoved(const AccountId& account_id, |
| 876 bool last_user_removed) { | 888 bool last_user_removed) { |
| 877 CallJS("login.AccountPickerScreen.removeUser", account_id); | 889 CallJS("login.AccountPickerScreen.removeUser", account_id); |
| 878 if (last_user_removed) | 890 if (last_user_removed) |
| 879 OnShowAddUser(); | 891 OnShowAddUser(); |
| 880 } | 892 } |
| 881 | 893 |
| 882 void SigninScreenHandler::OnUserImageChanged(const user_manager::User& user) { | 894 void SigninScreenHandler::OnUserImageChanged(const user_manager::User& user) { |
| 883 if (page_is_ready()) | 895 if (page_is_ready()) |
| 884 CallJS("login.AccountPickerScreen.updateUserImage", user.GetAccountId()); | 896 CallJS("login.AccountPickerScreen.updateUserImage", user.GetAccountId()); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 // Don't reload auth extension if proxy auth dialog was cancelled. | 983 // Don't reload auth extension if proxy auth dialog was cancelled. |
| 972 has_pending_auth_ui_ = false; | 984 has_pending_auth_ui_ = false; |
| 973 update_state_closure_.Cancel(); | 985 update_state_closure_.Cancel(); |
| 974 break; | 986 break; |
| 975 } | 987 } |
| 976 default: | 988 default: |
| 977 NOTREACHED() << "Unexpected notification " << type; | 989 NOTREACHED() << "Unexpected notification " << type; |
| 978 } | 990 } |
| 979 } | 991 } |
| 980 | 992 |
| 993 void SigninScreenHandler::SuspendDone(const base::TimeDelta& sleep_duration) { |
| 994 for (user_manager::User* user : |
| 995 user_manager::UserManager::Get()->GetUnlockUsers()) { |
| 996 HidePinKeyboardIfNeeded(user->GetAccountId()); |
| 997 } |
| 998 } |
| 999 |
| 981 void SigninScreenHandler::OnMaximizeModeStarted() { | 1000 void SigninScreenHandler::OnMaximizeModeStarted() { |
| 982 CallJS("login.AccountPickerScreen.setTouchViewState", true); | 1001 CallJS("login.AccountPickerScreen.setTouchViewState", true); |
| 983 } | 1002 } |
| 984 | 1003 |
| 985 void SigninScreenHandler::OnMaximizeModeEnded() { | 1004 void SigninScreenHandler::OnMaximizeModeEnded() { |
| 986 CallJS("login.AccountPickerScreen.setTouchViewState", false); | 1005 CallJS("login.AccountPickerScreen.setTouchViewState", false); |
| 987 } | 1006 } |
| 988 | 1007 |
| 989 bool SigninScreenHandler::ShouldLoadGaia() const { | 1008 bool SigninScreenHandler::ShouldLoadGaia() const { |
| 990 // Fetching of the extension is not started before account picker page is | 1009 // Fetching of the extension is not started before account picker page is |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1002 void SigninScreenHandler::HandleAuthenticateUser(const AccountId& account_id, | 1021 void SigninScreenHandler::HandleAuthenticateUser(const AccountId& account_id, |
| 1003 const std::string& password) { | 1022 const std::string& password) { |
| 1004 if (!delegate_) | 1023 if (!delegate_) |
| 1005 return; | 1024 return; |
| 1006 DCHECK_EQ(account_id.GetUserEmail(), | 1025 DCHECK_EQ(account_id.GetUserEmail(), |
| 1007 gaia::SanitizeEmail(account_id.GetUserEmail())); | 1026 gaia::SanitizeEmail(account_id.GetUserEmail())); |
| 1008 | 1027 |
| 1009 UserContext user_context(account_id); | 1028 UserContext user_context(account_id); |
| 1010 user_context.SetKey(Key(password)); | 1029 user_context.SetKey(Key(password)); |
| 1011 delegate_->Login(user_context, SigninSpecifics()); | 1030 delegate_->Login(user_context, SigninSpecifics()); |
| 1012 } | |
| 1013 | 1031 |
| 1014 void SigninScreenHandler::HandleAuthenticateUserWithPin( | 1032 HidePinKeyboardIfNeeded(account_id); |
| 1015 const AccountId& account_id, const std::string& password) { | |
| 1016 if (!delegate_) | |
| 1017 return; | |
| 1018 DCHECK_EQ(account_id.GetUserEmail(), | |
| 1019 gaia::SanitizeEmail(account_id.GetUserEmail())); | |
| 1020 | |
| 1021 // TODO(jdufault): Implement this. | |
| 1022 NOTIMPLEMENTED(); | |
| 1023 } | 1033 } |
| 1024 | 1034 |
| 1025 void SigninScreenHandler::HandleLaunchIncognito() { | 1035 void SigninScreenHandler::HandleLaunchIncognito() { |
| 1026 UserContext context(user_manager::USER_TYPE_GUEST, EmptyAccountId()); | 1036 UserContext context(user_manager::USER_TYPE_GUEST, EmptyAccountId()); |
| 1027 if (delegate_) | 1037 if (delegate_) |
| 1028 delegate_->Login(context, SigninSpecifics()); | 1038 delegate_->Login(context, SigninSpecifics()); |
| 1029 } | 1039 } |
| 1030 | 1040 |
| 1031 void SigninScreenHandler::HandleShowSupervisedUserCreationScreen() { | 1041 void SigninScreenHandler::HandleShowSupervisedUserCreationScreen() { |
| 1032 if (!user_manager::UserManager::Get()->AreSupervisedUsersAllowed()) { | 1042 if (!user_manager::UserManager::Get()->AreSupervisedUsersAllowed()) { |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1435 } | 1445 } |
| 1436 | 1446 |
| 1437 void SigninScreenHandler::OnFeedbackFinished() { | 1447 void SigninScreenHandler::OnFeedbackFinished() { |
| 1438 CallJS("login.UnrecoverableCryptohomeErrorScreen.resumeAfterFeedbackUI"); | 1448 CallJS("login.UnrecoverableCryptohomeErrorScreen.resumeAfterFeedbackUI"); |
| 1439 | 1449 |
| 1440 // Recreate user's cryptohome after the feedkback is attempted. | 1450 // Recreate user's cryptohome after the feedkback is attempted. |
| 1441 HandleResyncUserData(); | 1451 HandleResyncUserData(); |
| 1442 } | 1452 } |
| 1443 | 1453 |
| 1444 } // namespace chromeos | 1454 } // namespace chromeos |
| OLD | NEW |