Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc

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

Powered by Google App Engine
This is Rietveld 408576698