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

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

Issue 324463003: ChromeOS login webui refactoring : Simplify login methods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 963 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 CallJS("cr.ui.login.DisplayManager.updateAddUserButtonStatus", 974 CallJS("cr.ui.login.DisplayManager.updateAddUserButtonStatus",
975 AllWhitelistedUsersPresent()); 975 AllWhitelistedUsersPresent());
976 } 976 }
977 977
978 void SigninScreenHandler::HandleAuthenticateUser(const std::string& username, 978 void SigninScreenHandler::HandleAuthenticateUser(const std::string& username,
979 const std::string& password) { 979 const std::string& password) {
980 if (!delegate_) 980 if (!delegate_)
981 return; 981 return;
982 UserContext user_context(username); 982 UserContext user_context(username);
983 user_context.SetKey(Key(password)); 983 user_context.SetKey(Key(password));
984 delegate_->Login(user_context); 984 delegate_->Login(user_context, SigninSpecifics());
985 } 985 }
986 986
987 void SigninScreenHandler::HandleAttemptUnlock(const std::string& username) { 987 void SigninScreenHandler::HandleAttemptUnlock(const std::string& username) {
988 DCHECK(ScreenLocker::default_screen_locker()); 988 DCHECK(ScreenLocker::default_screen_locker());
989 989
990 const User* unlock_user = NULL; 990 const User* unlock_user = NULL;
991 const UserList& users = delegate_->GetUsers(); 991 const UserList& users = delegate_->GetUsers();
992 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { 992 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) {
993 if ((*it)->email() == username) { 993 if ((*it)->email() == username) {
994 unlock_user = *it; 994 unlock_user = *it;
995 break; 995 break;
996 } 996 }
997 } 997 }
998 if (!unlock_user) 998 if (!unlock_user)
999 return; 999 return;
1000 1000
1001 Profile* profile = UserManager::Get()->GetProfileByUser(unlock_user); 1001 Profile* profile = UserManager::Get()->GetProfileByUser(unlock_user);
1002 extensions::ScreenlockPrivateEventRouter* router = 1002 extensions::ScreenlockPrivateEventRouter* router =
1003 extensions::ScreenlockPrivateEventRouter::GetFactoryInstance()->Get( 1003 extensions::ScreenlockPrivateEventRouter::GetFactoryInstance()->Get(
1004 profile); 1004 profile);
1005 router->OnAuthAttempted(GetAuthType(username), ""); 1005 router->OnAuthAttempted(GetAuthType(username), "");
1006 } 1006 }
1007 1007
1008 void SigninScreenHandler::HandleLaunchDemoUser() { 1008 void SigninScreenHandler::HandleLaunchDemoUser() {
1009 UserContext context;
1010 context.SetUserType(User::USER_TYPE_RETAIL_MODE);
1009 if (delegate_) 1011 if (delegate_)
1010 delegate_->LoginAsRetailModeUser(); 1012 delegate_->Login(context, SigninSpecifics());
1011 } 1013 }
1012 1014
1013 void SigninScreenHandler::HandleLaunchIncognito() { 1015 void SigninScreenHandler::HandleLaunchIncognito() {
1016 UserContext context;
1017 context.SetUserType(User::USER_TYPE_GUEST);
1014 if (delegate_) 1018 if (delegate_)
1015 delegate_->LoginAsGuest(); 1019 delegate_->Login(context, SigninSpecifics());
1016 } 1020 }
1017 1021
1018 void SigninScreenHandler::HandleShowLocallyManagedUserCreationScreen() { 1022 void SigninScreenHandler::HandleShowLocallyManagedUserCreationScreen() {
1019 if (!UserManager::Get()->AreLocallyManagedUsersAllowed()) { 1023 if (!UserManager::Get()->AreLocallyManagedUsersAllowed()) {
1020 LOG(ERROR) << "Managed users not allowed."; 1024 LOG(ERROR) << "Managed users not allowed.";
1021 return; 1025 return;
1022 } 1026 }
1023 scoped_ptr<base::DictionaryValue> params(new base::DictionaryValue()); 1027 scoped_ptr<base::DictionaryValue> params(new base::DictionaryValue());
1024 LoginDisplayHostImpl::default_host()-> 1028 LoginDisplayHostImpl::default_host()->
1025 StartWizard(WizardController::kLocallyManagedUserCreationScreenName, 1029 StartWizard(WizardController::kLocallyManagedUserCreationScreenName,
1026 params.Pass()); 1030 params.Pass());
1027 } 1031 }
1028 1032
1029 void SigninScreenHandler::HandleLaunchPublicAccount( 1033 void SigninScreenHandler::HandleLaunchPublicAccount(
1030 const std::string& username) { 1034 const std::string& username) {
1035 UserContext context(username);
1036 context.SetUserType(User::USER_TYPE_PUBLIC_ACCOUNT);
1031 if (delegate_) 1037 if (delegate_)
1032 delegate_->LoginAsPublicAccount(username); 1038 delegate_->Login(context, SigninSpecifics());
1033 } 1039 }
1034 1040
1035 void SigninScreenHandler::HandleOfflineLogin(const base::ListValue* args) { 1041 void SigninScreenHandler::HandleOfflineLogin(const base::ListValue* args) {
1036 if (!delegate_ || delegate_->IsShowUsers()) { 1042 if (!delegate_ || delegate_->IsShowUsers()) {
1037 NOTREACHED(); 1043 NOTREACHED();
1038 return; 1044 return;
1039 } 1045 }
1040 std::string email; 1046 std::string email;
1041 args->GetString(0, &email); 1047 args->GetString(0, &email);
1042 1048
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 offline_login_active_ = offline_login_active; 1254 offline_login_active_ = offline_login_active;
1249 } 1255 }
1250 1256
1251 void SigninScreenHandler::HandleFocusPod(const std::string& user_id) { 1257 void SigninScreenHandler::HandleFocusPod(const std::string& user_id) {
1252 SetUserInputMethod(user_id); 1258 SetUserInputMethod(user_id);
1253 WallpaperManager::Get()->SetUserWallpaperDelayed(user_id); 1259 WallpaperManager::Get()->SetUserWallpaperDelayed(user_id);
1254 } 1260 }
1255 1261
1256 void SigninScreenHandler::HandleRetrieveAuthenticatedUserEmail( 1262 void SigninScreenHandler::HandleRetrieveAuthenticatedUserEmail(
1257 double attempt_token) { 1263 double attempt_token) {
1264 // TODO(antrim) : move GaiaSigninScreen dependency to GaiaSigninScreen.
1258 email_retriever_.reset(new AuthenticatedUserEmailRetriever( 1265 email_retriever_.reset(new AuthenticatedUserEmailRetriever(
1259 base::Bind(&SigninScreenHandler::CallJS<double, std::string>, 1266 base::Bind(&SigninScreenHandler::CallJS<double, std::string>,
1260 base::Unretained(this), 1267 base::Unretained(this),
1261 "login.GaiaSigninScreen.setAuthenticatedUserEmail", 1268 "login.GaiaSigninScreen.setAuthenticatedUserEmail",
1262 attempt_token), 1269 attempt_token),
1263 Profile::FromWebUI(web_ui())->GetRequestContext())); 1270 Profile::FromWebUI(web_ui())->GetRequestContext()));
1264 } 1271 }
1265 1272
1266 void SigninScreenHandler::HandleLaunchKioskApp(const std::string& app_id, 1273 void SigninScreenHandler::HandleLaunchKioskApp(const std::string& app_id,
1267 bool diagnostic_mode) { 1274 bool diagnostic_mode) {
1268 delegate_->LoginAsKioskApp(app_id, diagnostic_mode); 1275 UserContext context(app_id);
1276 context.SetUserType(User::USER_TYPE_KIOSK_APP);
1277 SigninSpecifics specifics;
1278 specifics.kiosk_diagnostic_mode = diagnostic_mode;
1279 if (delegate_)
1280 delegate_->Login(context, specifics);
1269 } 1281 }
1270 1282
1271 bool SigninScreenHandler::AllWhitelistedUsersPresent() { 1283 bool SigninScreenHandler::AllWhitelistedUsersPresent() {
1272 CrosSettings* cros_settings = CrosSettings::Get(); 1284 CrosSettings* cros_settings = CrosSettings::Get();
1273 bool allow_new_user = false; 1285 bool allow_new_user = false;
1274 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); 1286 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user);
1275 if (allow_new_user) 1287 if (allow_new_user)
1276 return false; 1288 return false;
1277 UserManager* user_manager = UserManager::Get(); 1289 UserManager* user_manager = UserManager::Get();
1278 const UserList& users = user_manager->GetUsers(); 1290 const UserList& users = user_manager->GetUsers();
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 return gaia_screen_handler_->frame_error(); 1398 return gaia_screen_handler_->frame_error();
1387 } 1399 }
1388 1400
1389 void SigninScreenHandler::OnCapsLockChanged(bool enabled) { 1401 void SigninScreenHandler::OnCapsLockChanged(bool enabled) {
1390 caps_lock_enabled_ = enabled; 1402 caps_lock_enabled_ = enabled;
1391 if (page_is_ready()) 1403 if (page_is_ready())
1392 CallJS("login.AccountPickerScreen.setCapsLockState", caps_lock_enabled_); 1404 CallJS("login.AccountPickerScreen.setCapsLockState", caps_lock_enabled_);
1393 } 1405 }
1394 1406
1395 } // namespace chromeos 1407 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698