| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "chrome/browser/chromeos/login/screen_locker.h" | 35 #include "chrome/browser/chromeos/login/screen_locker.h" |
| 36 #include "chrome/browser/chromeos/login/screens/core_oobe_actor.h" | 36 #include "chrome/browser/chromeos/login/screens/core_oobe_actor.h" |
| 37 #include "chrome/browser/chromeos/login/user.h" | 37 #include "chrome/browser/chromeos/login/user.h" |
| 38 #include "chrome/browser/chromeos/login/wallpaper_manager.h" | 38 #include "chrome/browser/chromeos/login/wallpaper_manager.h" |
| 39 #include "chrome/browser/chromeos/login/webui_login_display.h" | 39 #include "chrome/browser/chromeos/login/webui_login_display.h" |
| 40 #include "chrome/browser/chromeos/login/wizard_controller.h" | 40 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 41 #include "chrome/browser/chromeos/net/network_portal_detector.h" | 41 #include "chrome/browser/chromeos/net/network_portal_detector.h" |
| 42 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 42 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 43 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 43 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 44 #include "chrome/browser/chromeos/settings/cros_settings.h" | 44 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 45 #include "chrome/browser/extensions/api/screenlock_private/screenlock_private_ap
i.h" |
| 45 #include "chrome/browser/io_thread.h" | 46 #include "chrome/browser/io_thread.h" |
| 46 #include "chrome/browser/profiles/profile.h" | 47 #include "chrome/browser/profiles/profile.h" |
| 47 #include "chrome/browser/ui/webui/chromeos/login/authenticated_user_email_retrie
ver.h" | 48 #include "chrome/browser/ui/webui/chromeos/login/authenticated_user_email_retrie
ver.h" |
| 48 #include "chrome/browser/ui/webui/chromeos/login/error_screen_handler.h" | 49 #include "chrome/browser/ui/webui/chromeos/login/error_screen_handler.h" |
| 49 #include "chrome/browser/ui/webui/chromeos/login/native_window_delegate.h" | 50 #include "chrome/browser/ui/webui/chromeos/login/native_window_delegate.h" |
| 50 #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h" | 51 #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h" |
| 51 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 52 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
| 52 #include "chrome/common/chrome_switches.h" | 53 #include "chrome/common/chrome_switches.h" |
| 53 #include "chrome/common/pref_names.h" | 54 #include "chrome/common/pref_names.h" |
| 54 #include "chrome/common/url_constants.h" | 55 #include "chrome/common/url_constants.h" |
| 55 #include "chromeos/chromeos_switches.h" | 56 #include "chromeos/chromeos_switches.h" |
| 56 #include "chromeos/dbus/dbus_thread_manager.h" | 57 #include "chromeos/dbus/dbus_thread_manager.h" |
| 57 #include "chromeos/dbus/power_manager_client.h" | 58 #include "chromeos/dbus/power_manager_client.h" |
| 58 #include "chromeos/ime/ime_keyboard.h" | 59 #include "chromeos/ime/ime_keyboard.h" |
| 59 #include "chromeos/ime/input_method_manager.h" | 60 #include "chromeos/ime/input_method_manager.h" |
| 60 #include "chromeos/network/network_state.h" | 61 #include "chromeos/network/network_state.h" |
| 61 #include "chromeos/network/network_state_handler.h" | 62 #include "chromeos/network/network_state_handler.h" |
| 62 #include "content/public/browser/browser_thread.h" | 63 #include "content/public/browser/browser_thread.h" |
| 63 #include "content/public/browser/render_frame_host.h" | 64 #include "content/public/browser/render_frame_host.h" |
| 64 #include "content/public/browser/web_contents.h" | 65 #include "content/public/browser/web_contents.h" |
| 65 #include "google_apis/gaia/gaia_auth_util.h" | 66 #include "google_apis/gaia/gaia_auth_util.h" |
| 66 #include "grit/chromium_strings.h" | 67 #include "grit/chromium_strings.h" |
| 67 #include "grit/generated_resources.h" | 68 #include "grit/generated_resources.h" |
| 68 #include "net/url_request/url_request_context_getter.h" | 69 #include "net/url_request/url_request_context_getter.h" |
| 69 #include "third_party/cros_system_api/dbus/service_constants.h" | 70 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 71 #include "ui/base/webui/web_ui_util.h" |
| 70 | 72 |
| 71 #if defined(USE_AURA) | 73 #if defined(USE_AURA) |
| 72 #include "ash/shell.h" | 74 #include "ash/shell.h" |
| 73 #include "ash/wm/lock_state_controller.h" | 75 #include "ash/wm/lock_state_controller.h" |
| 74 #endif | 76 #endif |
| 75 | 77 |
| 76 using content::BrowserThread; | 78 using content::BrowserThread; |
| 77 | 79 |
| 78 namespace { | 80 namespace { |
| 79 | 81 |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 chrome::NOTIFICATION_AUTH_CANCELLED, | 341 chrome::NOTIFICATION_AUTH_CANCELLED, |
| 340 content::NotificationService::AllSources()); | 342 content::NotificationService::AllSources()); |
| 341 } | 343 } |
| 342 | 344 |
| 343 SigninScreenHandler::~SigninScreenHandler() { | 345 SigninScreenHandler::~SigninScreenHandler() { |
| 344 ash::Shell::GetInstance()->RemovePreTargetHandler(this); | 346 ash::Shell::GetInstance()->RemovePreTargetHandler(this); |
| 345 weak_factory_.InvalidateWeakPtrs(); | 347 weak_factory_.InvalidateWeakPtrs(); |
| 346 if (delegate_) | 348 if (delegate_) |
| 347 delegate_->SetWebUIHandler(NULL); | 349 delegate_->SetWebUIHandler(NULL); |
| 348 network_state_informer_->RemoveObserver(this); | 350 network_state_informer_->RemoveObserver(this); |
| 351 ScreenlockBridge::Get()->SetLockHandler(NULL); |
| 349 } | 352 } |
| 350 | 353 |
| 351 void SigninScreenHandler::DeclareLocalizedValues( | 354 void SigninScreenHandler::DeclareLocalizedValues( |
| 352 LocalizedValuesBuilder* builder) { | 355 LocalizedValuesBuilder* builder) { |
| 353 builder->Add("passwordHint", IDS_LOGIN_POD_EMPTY_PASSWORD_TEXT); | 356 builder->Add("passwordHint", IDS_LOGIN_POD_EMPTY_PASSWORD_TEXT); |
| 354 builder->Add("podMenuButtonAccessibleName", | 357 builder->Add("podMenuButtonAccessibleName", |
| 355 IDS_LOGIN_POD_MENU_BUTTON_ACCESSIBLE_NAME); | 358 IDS_LOGIN_POD_MENU_BUTTON_ACCESSIBLE_NAME); |
| 356 builder->Add("podMenuRemoveItemAccessibleName", | 359 builder->Add("podMenuRemoveItemAccessibleName", |
| 357 IDS_LOGIN_POD_MENU_REMOVE_ITEM_ACCESSIBLE_NAME); | 360 IDS_LOGIN_POD_MENU_REMOVE_ITEM_ACCESSIBLE_NAME); |
| 358 builder->Add("passwordFieldAccessibleName", | 361 builder->Add("passwordFieldAccessibleName", |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 return NULL; | 744 return NULL; |
| 742 } | 745 } |
| 743 | 746 |
| 744 void SigninScreenHandler::RegisterMessages() { | 747 void SigninScreenHandler::RegisterMessages() { |
| 745 AddCallback("usingSAMLAPI", &SigninScreenHandler::HandleUsingSAMLAPI); | 748 AddCallback("usingSAMLAPI", &SigninScreenHandler::HandleUsingSAMLAPI); |
| 746 AddCallback("scrapedPasswordCount", | 749 AddCallback("scrapedPasswordCount", |
| 747 &SigninScreenHandler::HandleScrapedPasswordCount); | 750 &SigninScreenHandler::HandleScrapedPasswordCount); |
| 748 AddCallback("scrapedPasswordVerificationFailed", | 751 AddCallback("scrapedPasswordVerificationFailed", |
| 749 &SigninScreenHandler::HandleScrapedPasswordVerificationFailed); | 752 &SigninScreenHandler::HandleScrapedPasswordVerificationFailed); |
| 750 AddCallback("authenticateUser", &SigninScreenHandler::HandleAuthenticateUser); | 753 AddCallback("authenticateUser", &SigninScreenHandler::HandleAuthenticateUser); |
| 754 AddCallback("attemptUnlock", &SigninScreenHandler::HandleAttemptUnlock); |
| 751 AddCallback("completeLogin", &SigninScreenHandler::HandleCompleteLogin); | 755 AddCallback("completeLogin", &SigninScreenHandler::HandleCompleteLogin); |
| 752 AddCallback("completeAuthentication", | 756 AddCallback("completeAuthentication", |
| 753 &SigninScreenHandler::HandleCompleteAuthentication); | 757 &SigninScreenHandler::HandleCompleteAuthentication); |
| 754 AddCallback("getUsers", &SigninScreenHandler::HandleGetUsers); | 758 AddCallback("getUsers", &SigninScreenHandler::HandleGetUsers); |
| 755 AddCallback("launchDemoUser", &SigninScreenHandler::HandleLaunchDemoUser); | 759 AddCallback("launchDemoUser", &SigninScreenHandler::HandleLaunchDemoUser); |
| 756 AddCallback("launchIncognito", &SigninScreenHandler::HandleLaunchIncognito); | 760 AddCallback("launchIncognito", &SigninScreenHandler::HandleLaunchIncognito); |
| 757 AddCallback("showLocallyManagedUserCreationScreen", | 761 AddCallback("showLocallyManagedUserCreationScreen", |
| 758 &SigninScreenHandler::HandleShowLocallyManagedUserCreationScreen); | 762 &SigninScreenHandler::HandleShowLocallyManagedUserCreationScreen); |
| 759 AddCallback("launchPublicAccount", | 763 AddCallback("launchPublicAccount", |
| 760 &SigninScreenHandler::HandleLaunchPublicAccount); | 764 &SigninScreenHandler::HandleLaunchPublicAccount); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 785 AddCallback("resyncUserData", &SigninScreenHandler::HandleResyncUserData); | 789 AddCallback("resyncUserData", &SigninScreenHandler::HandleResyncUserData); |
| 786 AddCallback("loginUIStateChanged", | 790 AddCallback("loginUIStateChanged", |
| 787 &SigninScreenHandler::HandleLoginUIStateChanged); | 791 &SigninScreenHandler::HandleLoginUIStateChanged); |
| 788 AddCallback("unlockOnLoginSuccess", | 792 AddCallback("unlockOnLoginSuccess", |
| 789 &SigninScreenHandler::HandleUnlockOnLoginSuccess); | 793 &SigninScreenHandler::HandleUnlockOnLoginSuccess); |
| 790 AddCallback("showLoadingTimeoutError", | 794 AddCallback("showLoadingTimeoutError", |
| 791 &SigninScreenHandler::HandleShowLoadingTimeoutError); | 795 &SigninScreenHandler::HandleShowLoadingTimeoutError); |
| 792 AddCallback("updateOfflineLogin", | 796 AddCallback("updateOfflineLogin", |
| 793 &SigninScreenHandler::HandleUpdateOfflineLogin); | 797 &SigninScreenHandler::HandleUpdateOfflineLogin); |
| 794 AddCallback("focusPod", &SigninScreenHandler::HandleFocusPod); | 798 AddCallback("focusPod", &SigninScreenHandler::HandleFocusPod); |
| 795 AddCallback("customButtonClicked", | |
| 796 &SigninScreenHandler::HandleCustomButtonClicked); | |
| 797 AddCallback("retrieveAuthenticatedUserEmail", | 799 AddCallback("retrieveAuthenticatedUserEmail", |
| 798 &SigninScreenHandler::HandleRetrieveAuthenticatedUserEmail); | 800 &SigninScreenHandler::HandleRetrieveAuthenticatedUserEmail); |
| 799 | 801 |
| 800 // This message is sent by the kiosk app menu, but is handled here | 802 // This message is sent by the kiosk app menu, but is handled here |
| 801 // so we can tell the delegate to launch the app. | 803 // so we can tell the delegate to launch the app. |
| 802 AddCallback("launchKioskApp", &SigninScreenHandler::HandleLaunchKioskApp); | 804 AddCallback("launchKioskApp", &SigninScreenHandler::HandleLaunchKioskApp); |
| 803 } | 805 } |
| 804 | 806 |
| 805 void SigninScreenHandler::RegisterPrefs(PrefRegistrySimple* registry) { | 807 void SigninScreenHandler::RegisterPrefs(PrefRegistrySimple* registry) { |
| 806 registry->RegisterDictionaryPref(prefs::kUsersLRUInputMethod); | 808 registry->RegisterDictionaryPref(prefs::kUsersLRUInputMethod); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 SendUserList(false); | 854 SendUserList(false); |
| 853 UpdateUIState(UI_STATE_ACCOUNT_PICKER, NULL); | 855 UpdateUIState(UI_STATE_ACCOUNT_PICKER, NULL); |
| 854 } | 856 } |
| 855 preferences_changed_delayed_ = false; | 857 preferences_changed_delayed_ = false; |
| 856 } | 858 } |
| 857 | 859 |
| 858 void SigninScreenHandler::ResetSigninScreenHandlerDelegate() { | 860 void SigninScreenHandler::ResetSigninScreenHandlerDelegate() { |
| 859 SetDelegate(NULL); | 861 SetDelegate(NULL); |
| 860 } | 862 } |
| 861 | 863 |
| 862 void SigninScreenHandler::ShowBannerMessage(const std::string& message) { | |
| 863 CallJS("login.AccountPickerScreen.showBannerMessage", message); | |
| 864 } | |
| 865 | |
| 866 void SigninScreenHandler::ShowUserPodButton( | |
| 867 const std::string& username, | |
| 868 const std::string& iconURL, | |
| 869 const base::Closure& click_callback) { | |
| 870 user_pod_button_callback_map_[username] = click_callback; | |
| 871 CallJS("login.AccountPickerScreen.showUserPodButton", username, iconURL); | |
| 872 | |
| 873 // TODO(tengs): Move this code once we move unlocking to native code. | |
| 874 if (ScreenLocker::default_screen_locker()) { | |
| 875 UserManager* user_manager = UserManager::Get(); | |
| 876 const User* user = user_manager->FindUser(username); | |
| 877 if (!user) | |
| 878 return; | |
| 879 PrefService* profile_prefs = | |
| 880 user_manager->GetProfileByUser(user)->GetPrefs(); | |
| 881 if (profile_prefs->GetBoolean(prefs::kEasyUnlockShowTutorial)) { | |
| 882 CallJS("login.AccountPickerScreen.showEasyUnlockBubble"); | |
| 883 profile_prefs->SetBoolean(prefs::kEasyUnlockShowTutorial, false); | |
| 884 } | |
| 885 } | |
| 886 } | |
| 887 | |
| 888 void SigninScreenHandler::HideUserPodButton(const std::string& username) { | |
| 889 CallJS("login.AccountPickerScreen.hideUserPodButton", username); | |
| 890 } | |
| 891 | |
| 892 void SigninScreenHandler::SetAuthType(const std::string& username, | |
| 893 LoginDisplay::AuthType auth_type, | |
| 894 const std::string& initial_value) { | |
| 895 user_auth_type_map_[username] = auth_type; | |
| 896 CallJS("login.AccountPickerScreen.setAuthType", | |
| 897 username, | |
| 898 static_cast<int>(auth_type), | |
| 899 base::StringValue(initial_value)); | |
| 900 } | |
| 901 | |
| 902 LoginDisplay::AuthType SigninScreenHandler::GetAuthType( | |
| 903 const std::string& username) const { | |
| 904 if (user_auth_type_map_.find(username) == user_auth_type_map_.end()) | |
| 905 return LoginDisplay::OFFLINE_PASSWORD; | |
| 906 return user_auth_type_map_.find(username)->second; | |
| 907 } | |
| 908 | |
| 909 void SigninScreenHandler::ShowError(int login_attempts, | 864 void SigninScreenHandler::ShowError(int login_attempts, |
| 910 const std::string& error_text, | 865 const std::string& error_text, |
| 911 const std::string& help_link_text, | 866 const std::string& help_link_text, |
| 912 HelpAppLauncher::HelpTopic help_topic_id) { | 867 HelpAppLauncher::HelpTopic help_topic_id) { |
| 913 core_oobe_actor_->ShowSignInError(login_attempts, error_text, help_link_text, | 868 core_oobe_actor_->ShowSignInError(login_attempts, error_text, help_link_text, |
| 914 help_topic_id); | 869 help_topic_id); |
| 915 } | 870 } |
| 916 | 871 |
| 917 void SigninScreenHandler::ShowErrorScreen(LoginDisplay::SigninError error_id) { | 872 void SigninScreenHandler::ShowErrorScreen(LoginDisplay::SigninError error_id) { |
| 918 switch (error_id) { | 873 switch (error_id) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 932 void SigninScreenHandler::ShowControlBar(bool show) { | 887 void SigninScreenHandler::ShowControlBar(bool show) { |
| 933 core_oobe_actor_->ShowControlBar(show); | 888 core_oobe_actor_->ShowControlBar(show); |
| 934 } | 889 } |
| 935 | 890 |
| 936 void SigninScreenHandler::ShowGaiaPasswordChanged(const std::string& username) { | 891 void SigninScreenHandler::ShowGaiaPasswordChanged(const std::string& username) { |
| 937 email_ = username; | 892 email_ = username; |
| 938 password_changed_for_.insert(email_); | 893 password_changed_for_.insert(email_); |
| 939 core_oobe_actor_->ShowSignInUI(email_); | 894 core_oobe_actor_->ShowSignInUI(email_); |
| 940 CallJS("login.setAuthType", | 895 CallJS("login.setAuthType", |
| 941 username, | 896 username, |
| 942 static_cast<int>(LoginDisplay::ONLINE_SIGN_IN), | 897 static_cast<int>(ONLINE_SIGN_IN), |
| 943 base::StringValue("")); | 898 base::StringValue("")); |
| 944 } | 899 } |
| 945 | 900 |
| 946 void SigninScreenHandler::ShowPasswordChangedDialog(bool show_password_error) { | 901 void SigninScreenHandler::ShowPasswordChangedDialog(bool show_password_error) { |
| 947 core_oobe_actor_->ShowPasswordChangedScreen(show_password_error); | 902 core_oobe_actor_->ShowPasswordChangedScreen(show_password_error); |
| 948 } | 903 } |
| 949 | 904 |
| 950 void SigninScreenHandler::ShowSigninScreenForCreds( | 905 void SigninScreenHandler::ShowSigninScreenForCreds( |
| 951 const std::string& username, | 906 const std::string& username, |
| 952 const std::string& password) { | 907 const std::string& password) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1000 // Don't reload auth extension if proxy auth dialog was cancelled. | 955 // Don't reload auth extension if proxy auth dialog was cancelled. |
| 1001 has_pending_auth_ui_ = false; | 956 has_pending_auth_ui_ = false; |
| 1002 update_state_closure_.Cancel(); | 957 update_state_closure_.Cancel(); |
| 1003 break; | 958 break; |
| 1004 } | 959 } |
| 1005 default: | 960 default: |
| 1006 NOTREACHED() << "Unexpected notification " << type; | 961 NOTREACHED() << "Unexpected notification " << type; |
| 1007 } | 962 } |
| 1008 } | 963 } |
| 1009 | 964 |
| 965 void SigninScreenHandler::ShowBannerMessage(const std::string& message) { |
| 966 CallJS("login.AccountPickerScreen.showBannerMessage", message); |
| 967 } |
| 968 |
| 969 void SigninScreenHandler::ShowUserPodCustomIcon( |
| 970 const std::string& username, |
| 971 const gfx::Image& icon) { |
| 972 GURL icon_url(webui::GetBitmapDataUrl(icon.AsBitmap())); |
| 973 CallJS("login.AccountPickerScreen.showUserPodCustomIcon", |
| 974 username, icon_url.spec()); |
| 975 |
| 976 // TODO(tengs): Move this code once we move unlocking to native code. |
| 977 if (ScreenLocker::default_screen_locker()) { |
| 978 UserManager* user_manager = UserManager::Get(); |
| 979 const User* user = user_manager->FindUser(username); |
| 980 if (!user) |
| 981 return; |
| 982 PrefService* profile_prefs = |
| 983 user_manager->GetProfileByUser(user)->GetPrefs(); |
| 984 if (profile_prefs->GetBoolean(prefs::kEasyUnlockShowTutorial)) { |
| 985 CallJS("login.AccountPickerScreen.showEasyUnlockBubble"); |
| 986 profile_prefs->SetBoolean(prefs::kEasyUnlockShowTutorial, false); |
| 987 } |
| 988 } |
| 989 } |
| 990 |
| 991 void SigninScreenHandler::HideUserPodCustomIcon(const std::string& username) { |
| 992 CallJS("login.AccountPickerScreen.hideUserPodCustomIcon", username); |
| 993 } |
| 994 |
| 995 void SigninScreenHandler::EnableInput() { |
| 996 // Only for lock screen at the moment. |
| 997 ScreenLocker::default_screen_locker()->EnableInput(); |
| 998 } |
| 999 |
| 1000 void SigninScreenHandler::SetAuthType( |
| 1001 const std::string& username, |
| 1002 ScreenlockBridge::LockHandler::AuthType auth_type, |
| 1003 const std::string& initial_value) { |
| 1004 user_auth_type_map_[username] = auth_type; |
| 1005 CallJS("login.AccountPickerScreen.setAuthType", |
| 1006 username, |
| 1007 static_cast<int>(auth_type), |
| 1008 base::StringValue(initial_value)); |
| 1009 } |
| 1010 |
| 1011 ScreenlockBridge::LockHandler::AuthType SigninScreenHandler::GetAuthType( |
| 1012 const std::string& username) const { |
| 1013 if (user_auth_type_map_.find(username) == user_auth_type_map_.end()) |
| 1014 return OFFLINE_PASSWORD; |
| 1015 return user_auth_type_map_.find(username)->second; |
| 1016 } |
| 1017 |
| 1018 void SigninScreenHandler::Unlock(const std::string& user_email) { |
| 1019 DCHECK(ScreenLocker::default_screen_locker()); |
| 1020 ScreenLocker::Hide(); |
| 1021 } |
| 1022 |
| 1010 void SigninScreenHandler::OnDnsCleared() { | 1023 void SigninScreenHandler::OnDnsCleared() { |
| 1011 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1024 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1012 dns_clear_task_running_ = false; | 1025 dns_clear_task_running_ = false; |
| 1013 dns_cleared_ = true; | 1026 dns_cleared_ = true; |
| 1014 ShowSigninScreenIfReady(); | 1027 ShowSigninScreenIfReady(); |
| 1015 } | 1028 } |
| 1016 | 1029 |
| 1017 // Update keyboard layout to least recently used by the user. | 1030 // Update keyboard layout to least recently used by the user. |
| 1018 void SigninScreenHandler::SetUserInputMethod(const std::string& username) { | 1031 void SigninScreenHandler::SetUserInputMethod(const std::string& username) { |
| 1019 UserManager* user_manager = UserManager::Get(); | 1032 UserManager* user_manager = UserManager::Get(); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1176 | 1189 |
| 1177 void SigninScreenHandler::HandleAuthenticateUser(const std::string& username, | 1190 void SigninScreenHandler::HandleAuthenticateUser(const std::string& username, |
| 1178 const std::string& password) { | 1191 const std::string& password) { |
| 1179 if (!delegate_) | 1192 if (!delegate_) |
| 1180 return; | 1193 return; |
| 1181 delegate_->Login(UserContext(gaia::SanitizeEmail(username), | 1194 delegate_->Login(UserContext(gaia::SanitizeEmail(username), |
| 1182 password, | 1195 password, |
| 1183 std::string())); // auth_code | 1196 std::string())); // auth_code |
| 1184 } | 1197 } |
| 1185 | 1198 |
| 1199 void SigninScreenHandler::HandleAttemptUnlock(const std::string& username) { |
| 1200 DCHECK(ScreenLocker::default_screen_locker()); |
| 1201 |
| 1202 const User* unlock_user = NULL; |
| 1203 const UserList& users = delegate_->GetUsers(); |
| 1204 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { |
| 1205 if ((*it)->email() == username) { |
| 1206 unlock_user = *it; |
| 1207 break; |
| 1208 } |
| 1209 } |
| 1210 if (!unlock_user) |
| 1211 return; |
| 1212 |
| 1213 Profile* profile = UserManager::Get()->GetProfileByUser(unlock_user); |
| 1214 extensions::ScreenlockPrivateEventRouter* router = |
| 1215 extensions::ScreenlockPrivateEventRouter::GetFactoryInstance()->Get( |
| 1216 profile); |
| 1217 router->OnAuthAttempted(GetAuthType(username), ""); |
| 1218 } |
| 1219 |
| 1186 void SigninScreenHandler::HandleLaunchDemoUser() { | 1220 void SigninScreenHandler::HandleLaunchDemoUser() { |
| 1187 if (delegate_) | 1221 if (delegate_) |
| 1188 delegate_->LoginAsRetailModeUser(); | 1222 delegate_->LoginAsRetailModeUser(); |
| 1189 } | 1223 } |
| 1190 | 1224 |
| 1191 void SigninScreenHandler::HandleLaunchIncognito() { | 1225 void SigninScreenHandler::HandleLaunchIncognito() { |
| 1192 if (delegate_) | 1226 if (delegate_) |
| 1193 delegate_->LoginAsGuest(); | 1227 delegate_->LoginAsGuest(); |
| 1194 } | 1228 } |
| 1195 | 1229 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1277 } | 1311 } |
| 1278 } | 1312 } |
| 1279 | 1313 |
| 1280 void SigninScreenHandler::HandleToggleKioskAutolaunchScreen() { | 1314 void SigninScreenHandler::HandleToggleKioskAutolaunchScreen() { |
| 1281 policy::BrowserPolicyConnectorChromeOS* connector = | 1315 policy::BrowserPolicyConnectorChromeOS* connector = |
| 1282 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 1316 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 1283 if (delegate_ && !connector->IsEnterpriseManaged()) | 1317 if (delegate_ && !connector->IsEnterpriseManaged()) |
| 1284 delegate_->ShowKioskAutolaunchScreen(); | 1318 delegate_->ShowKioskAutolaunchScreen(); |
| 1285 } | 1319 } |
| 1286 | 1320 |
| 1287 void SigninScreenHandler::FillUserDictionary(User* user, | 1321 void SigninScreenHandler::FillUserDictionary( |
| 1288 bool is_owner, | 1322 User* user, |
| 1289 bool is_signin_to_add, | 1323 bool is_owner, |
| 1290 LoginDisplay::AuthType auth_type, | 1324 bool is_signin_to_add, |
| 1291 base::DictionaryValue* user_dict) { | 1325 ScreenlockBridge::LockHandler::AuthType auth_type, |
| 1326 base::DictionaryValue* user_dict) { |
| 1292 const std::string& email = user->email(); | 1327 const std::string& email = user->email(); |
| 1293 const bool is_public_account = | 1328 const bool is_public_account = |
| 1294 user->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT; | 1329 user->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT; |
| 1295 const bool is_locally_managed_user = | 1330 const bool is_locally_managed_user = |
| 1296 user->GetType() == User::USER_TYPE_LOCALLY_MANAGED; | 1331 user->GetType() == User::USER_TYPE_LOCALLY_MANAGED; |
| 1297 | 1332 |
| 1298 user_dict->SetString(kKeyUsername, email); | 1333 user_dict->SetString(kKeyUsername, email); |
| 1299 user_dict->SetString(kKeyEmailAddress, user->display_email()); | 1334 user_dict->SetString(kKeyEmailAddress, user->display_email()); |
| 1300 user_dict->SetString(kKeyDisplayName, user->GetDisplayName()); | 1335 user_dict->SetString(kKeyDisplayName, user->GetDisplayName()); |
| 1301 user_dict->SetBoolean(kKeyPublicAccount, is_public_account); | 1336 user_dict->SetBoolean(kKeyPublicAccount, is_public_account); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1339 BootTimesLoader::Get()->RecordCurrentStats("login-send-user-list"); | 1374 BootTimesLoader::Get()->RecordCurrentStats("login-send-user-list"); |
| 1340 | 1375 |
| 1341 base::ListValue users_list; | 1376 base::ListValue users_list; |
| 1342 const UserList& users = delegate_->GetUsers(); | 1377 const UserList& users = delegate_->GetUsers(); |
| 1343 | 1378 |
| 1344 // TODO(nkostylev): Move to a separate method in UserManager. | 1379 // TODO(nkostylev): Move to a separate method in UserManager. |
| 1345 // http://crbug.com/230852 | 1380 // http://crbug.com/230852 |
| 1346 bool is_signin_to_add = LoginDisplayHostImpl::default_host() && | 1381 bool is_signin_to_add = LoginDisplayHostImpl::default_host() && |
| 1347 UserManager::Get()->IsUserLoggedIn(); | 1382 UserManager::Get()->IsUserLoggedIn(); |
| 1348 | 1383 |
| 1349 user_pod_button_callback_map_.clear(); | |
| 1350 user_auth_type_map_.clear(); | 1384 user_auth_type_map_.clear(); |
| 1351 | 1385 |
| 1352 bool single_user = users.size() == 1; | 1386 bool single_user = users.size() == 1; |
| 1353 std::string owner; | 1387 std::string owner; |
| 1354 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); | 1388 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); |
| 1355 bool has_owner = owner.size() > 0; | 1389 bool has_owner = owner.size() > 0; |
| 1356 size_t max_non_owner_users = has_owner ? kMaxUsers - 1 : kMaxUsers; | 1390 size_t max_non_owner_users = has_owner ? kMaxUsers - 1 : kMaxUsers; |
| 1357 size_t non_owner_count = 0; | 1391 size_t non_owner_count = 0; |
| 1358 policy::BrowserPolicyConnectorChromeOS* connector = | 1392 policy::BrowserPolicyConnectorChromeOS* connector = |
| 1359 g_browser_process->platform_part()-> | 1393 g_browser_process->platform_part()-> |
| 1360 browser_policy_connector_chromeos(); | 1394 browser_policy_connector_chromeos(); |
| 1361 bool is_enterprise_managed = connector->IsEnterpriseManaged(); | 1395 bool is_enterprise_managed = connector->IsEnterpriseManaged(); |
| 1362 | 1396 |
| 1363 | 1397 |
| 1364 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { | 1398 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { |
| 1365 const std::string& email = (*it)->email(); | 1399 const std::string& email = (*it)->email(); |
| 1366 bool is_owner = (email == owner); | 1400 bool is_owner = (email == owner); |
| 1367 bool is_public_account = | 1401 bool is_public_account = |
| 1368 ((*it)->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT); | 1402 ((*it)->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT); |
| 1369 | 1403 |
| 1370 if ((is_public_account && !is_signin_to_add) || | 1404 if ((is_public_account && !is_signin_to_add) || |
| 1371 is_owner || | 1405 is_owner || |
| 1372 (!is_public_account && non_owner_count < max_non_owner_users)) { | 1406 (!is_public_account && non_owner_count < max_non_owner_users)) { |
| 1373 LoginDisplay::AuthType initial_auth_type = | 1407 AuthType initial_auth_type = |
| 1374 ShouldForceOnlineSignIn(*it) ? LoginDisplay::ONLINE_SIGN_IN | 1408 ShouldForceOnlineSignIn(*it) ? ONLINE_SIGN_IN : OFFLINE_PASSWORD; |
| 1375 : LoginDisplay::OFFLINE_PASSWORD; | |
| 1376 user_auth_type_map_[email] = initial_auth_type; | 1409 user_auth_type_map_[email] = initial_auth_type; |
| 1377 | 1410 |
| 1378 base::DictionaryValue* user_dict = new base::DictionaryValue(); | 1411 base::DictionaryValue* user_dict = new base::DictionaryValue(); |
| 1379 FillUserDictionary( | 1412 FillUserDictionary( |
| 1380 *it, is_owner, is_signin_to_add, initial_auth_type, user_dict); | 1413 *it, is_owner, is_signin_to_add, initial_auth_type, user_dict); |
| 1381 bool signed_in = (*it)->is_logged_in(); | 1414 bool signed_in = (*it)->is_logged_in(); |
| 1382 // Single user check here is necessary because owner info might not be | 1415 // Single user check here is necessary because owner info might not be |
| 1383 // available when running into login screen on first boot. | 1416 // available when running into login screen on first boot. |
| 1384 // See http://crosbug.com/12723 | 1417 // See http://crosbug.com/12723 |
| 1385 bool can_remove_user = ((!single_user || is_enterprise_managed) && | 1418 bool can_remove_user = ((!single_user || is_enterprise_managed) && |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1417 PrefService* prefs = g_browser_process->local_state(); | 1450 PrefService* prefs = g_browser_process->local_state(); |
| 1418 if (prefs->GetBoolean(prefs::kFactoryResetRequested)) { | 1451 if (prefs->GetBoolean(prefs::kFactoryResetRequested)) { |
| 1419 if (core_oobe_actor_) | 1452 if (core_oobe_actor_) |
| 1420 core_oobe_actor_->ShowDeviceResetScreen(); | 1453 core_oobe_actor_->ShowDeviceResetScreen(); |
| 1421 return; | 1454 return; |
| 1422 } | 1455 } |
| 1423 | 1456 |
| 1424 is_account_picker_showing_first_time_ = true; | 1457 is_account_picker_showing_first_time_ = true; |
| 1425 MaybePreloadAuthExtension(); | 1458 MaybePreloadAuthExtension(); |
| 1426 | 1459 |
| 1427 if (ScreenLocker::default_screen_locker()) | 1460 if (ScreenLocker::default_screen_locker()) { |
| 1428 ScreenLocker::default_screen_locker()->delegate()->OnLockWebUIReady(); | 1461 ScreenLocker::default_screen_locker()->delegate()->OnLockWebUIReady(); |
| 1462 ScreenlockBridge::Get()->SetLockHandler(this); |
| 1463 } |
| 1429 | 1464 |
| 1430 if (delegate_) | 1465 if (delegate_) |
| 1431 delegate_->OnSigninScreenReady(); | 1466 delegate_->OnSigninScreenReady(); |
| 1432 } | 1467 } |
| 1433 | 1468 |
| 1434 void SigninScreenHandler::HandleWallpaperReady() { | 1469 void SigninScreenHandler::HandleWallpaperReady() { |
| 1435 if (ScreenLocker::default_screen_locker()) { | 1470 if (ScreenLocker::default_screen_locker()) { |
| 1436 ScreenLocker::default_screen_locker()->delegate()-> | 1471 ScreenLocker::default_screen_locker()->delegate()-> |
| 1437 OnLockBackgroundDisplayed(); | 1472 OnLockBackgroundDisplayed(); |
| 1438 } | 1473 } |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1564 | 1599 |
| 1565 void SigninScreenHandler::HandleUpdateOfflineLogin(bool offline_login_active) { | 1600 void SigninScreenHandler::HandleUpdateOfflineLogin(bool offline_login_active) { |
| 1566 offline_login_active_ = offline_login_active; | 1601 offline_login_active_ = offline_login_active; |
| 1567 } | 1602 } |
| 1568 | 1603 |
| 1569 void SigninScreenHandler::HandleFocusPod(const std::string& user_id) { | 1604 void SigninScreenHandler::HandleFocusPod(const std::string& user_id) { |
| 1570 SetUserInputMethod(user_id); | 1605 SetUserInputMethod(user_id); |
| 1571 WallpaperManager::Get()->SetUserWallpaperDelayed(user_id); | 1606 WallpaperManager::Get()->SetUserWallpaperDelayed(user_id); |
| 1572 } | 1607 } |
| 1573 | 1608 |
| 1574 void SigninScreenHandler::HandleCustomButtonClicked( | |
| 1575 const std::string& username) { | |
| 1576 if (user_pod_button_callback_map_.find(username) | |
| 1577 == user_pod_button_callback_map_.end()) { | |
| 1578 LOG(WARNING) << "User pod custom button clicked but no callback found"; | |
| 1579 return; | |
| 1580 } | |
| 1581 user_pod_button_callback_map_[username].Run(); | |
| 1582 } | |
| 1583 | |
| 1584 void SigninScreenHandler::HandleRetrieveAuthenticatedUserEmail( | 1609 void SigninScreenHandler::HandleRetrieveAuthenticatedUserEmail( |
| 1585 double attempt_token) { | 1610 double attempt_token) { |
| 1586 email_retriever_.reset(new AuthenticatedUserEmailRetriever( | 1611 email_retriever_.reset(new AuthenticatedUserEmailRetriever( |
| 1587 base::Bind(&SigninScreenHandler::CallJS<double, std::string>, | 1612 base::Bind(&SigninScreenHandler::CallJS<double, std::string>, |
| 1588 base::Unretained(this), | 1613 base::Unretained(this), |
| 1589 "login.GaiaSigninScreen.setAuthenticatedUserEmail", | 1614 "login.GaiaSigninScreen.setAuthenticatedUserEmail", |
| 1590 attempt_token), | 1615 attempt_token), |
| 1591 Profile::FromWebUI(web_ui())->GetRequestContext())); | 1616 Profile::FromWebUI(web_ui())->GetRequestContext())); |
| 1592 } | 1617 } |
| 1593 | 1618 |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1785 DCHECK(gaia_screen_handler_); | 1810 DCHECK(gaia_screen_handler_); |
| 1786 return gaia_screen_handler_->frame_state(); | 1811 return gaia_screen_handler_->frame_state(); |
| 1787 } | 1812 } |
| 1788 | 1813 |
| 1789 net::Error SigninScreenHandler::FrameError() const { | 1814 net::Error SigninScreenHandler::FrameError() const { |
| 1790 DCHECK(gaia_screen_handler_); | 1815 DCHECK(gaia_screen_handler_); |
| 1791 return gaia_screen_handler_->frame_error(); | 1816 return gaia_screen_handler_->frame_error(); |
| 1792 } | 1817 } |
| 1793 | 1818 |
| 1794 } // namespace chromeos | 1819 } // namespace chromeos |
| OLD | NEW |