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

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: Attemp to reland (updates in UserContext) 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(User::USER_TYPE_RETAIL_MODE, std::string());
1009 if (delegate_) 1010 if (delegate_)
1010 delegate_->LoginAsRetailModeUser(); 1011 delegate_->Login(context, SigninSpecifics());
1011 } 1012 }
1012 1013
1013 void SigninScreenHandler::HandleLaunchIncognito() { 1014 void SigninScreenHandler::HandleLaunchIncognito() {
1015 UserContext context(User::USER_TYPE_GUEST, std::string());
1014 if (delegate_) 1016 if (delegate_)
1015 delegate_->LoginAsGuest(); 1017 delegate_->Login(context, SigninSpecifics());
1016 } 1018 }
1017 1019
1018 void SigninScreenHandler::HandleShowLocallyManagedUserCreationScreen() { 1020 void SigninScreenHandler::HandleShowLocallyManagedUserCreationScreen() {
1019 if (!UserManager::Get()->AreLocallyManagedUsersAllowed()) { 1021 if (!UserManager::Get()->AreLocallyManagedUsersAllowed()) {
1020 LOG(ERROR) << "Managed users not allowed."; 1022 LOG(ERROR) << "Managed users not allowed.";
1021 return; 1023 return;
1022 } 1024 }
1023 scoped_ptr<base::DictionaryValue> params(new base::DictionaryValue()); 1025 scoped_ptr<base::DictionaryValue> params(new base::DictionaryValue());
1024 LoginDisplayHostImpl::default_host()-> 1026 LoginDisplayHostImpl::default_host()->
1025 StartWizard(WizardController::kLocallyManagedUserCreationScreenName, 1027 StartWizard(WizardController::kLocallyManagedUserCreationScreenName,
1026 params.Pass()); 1028 params.Pass());
1027 } 1029 }
1028 1030
1029 void SigninScreenHandler::HandleLaunchPublicAccount( 1031 void SigninScreenHandler::HandleLaunchPublicAccount(
1030 const std::string& username) { 1032 const std::string& username) {
1033 UserContext context(User::USER_TYPE_PUBLIC_ACCOUNT, username);
1031 if (delegate_) 1034 if (delegate_)
1032 delegate_->LoginAsPublicAccount(username); 1035 delegate_->Login(context, SigninSpecifics());
1033 } 1036 }
1034 1037
1035 void SigninScreenHandler::HandleOfflineLogin(const base::ListValue* args) { 1038 void SigninScreenHandler::HandleOfflineLogin(const base::ListValue* args) {
1036 if (!delegate_ || delegate_->IsShowUsers()) { 1039 if (!delegate_ || delegate_->IsShowUsers()) {
1037 NOTREACHED(); 1040 NOTREACHED();
1038 return; 1041 return;
1039 } 1042 }
1040 std::string email; 1043 std::string email;
1041 args->GetString(0, &email); 1044 args->GetString(0, &email);
1042 1045
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 offline_login_active_ = offline_login_active; 1251 offline_login_active_ = offline_login_active;
1249 } 1252 }
1250 1253
1251 void SigninScreenHandler::HandleFocusPod(const std::string& user_id) { 1254 void SigninScreenHandler::HandleFocusPod(const std::string& user_id) {
1252 SetUserInputMethod(user_id); 1255 SetUserInputMethod(user_id);
1253 WallpaperManager::Get()->SetUserWallpaperDelayed(user_id); 1256 WallpaperManager::Get()->SetUserWallpaperDelayed(user_id);
1254 } 1257 }
1255 1258
1256 void SigninScreenHandler::HandleRetrieveAuthenticatedUserEmail( 1259 void SigninScreenHandler::HandleRetrieveAuthenticatedUserEmail(
1257 double attempt_token) { 1260 double attempt_token) {
1261 // TODO(antrim) : move GaiaSigninScreen dependency to GaiaSigninScreen.
1258 email_retriever_.reset(new AuthenticatedUserEmailRetriever( 1262 email_retriever_.reset(new AuthenticatedUserEmailRetriever(
1259 base::Bind(&SigninScreenHandler::CallJS<double, std::string>, 1263 base::Bind(&SigninScreenHandler::CallJS<double, std::string>,
1260 base::Unretained(this), 1264 base::Unretained(this),
1261 "login.GaiaSigninScreen.setAuthenticatedUserEmail", 1265 "login.GaiaSigninScreen.setAuthenticatedUserEmail",
1262 attempt_token), 1266 attempt_token),
1263 Profile::FromWebUI(web_ui())->GetRequestContext())); 1267 Profile::FromWebUI(web_ui())->GetRequestContext()));
1264 } 1268 }
1265 1269
1266 void SigninScreenHandler::HandleLaunchKioskApp(const std::string& app_id, 1270 void SigninScreenHandler::HandleLaunchKioskApp(const std::string& app_id,
1267 bool diagnostic_mode) { 1271 bool diagnostic_mode) {
1268 delegate_->LoginAsKioskApp(app_id, diagnostic_mode); 1272 UserContext context(User::USER_TYPE_KIOSK_APP, app_id);
1273 SigninSpecifics specifics;
1274 specifics.kiosk_diagnostic_mode = diagnostic_mode;
1275 if (delegate_)
1276 delegate_->Login(context, specifics);
1269 } 1277 }
1270 1278
1271 bool SigninScreenHandler::AllWhitelistedUsersPresent() { 1279 bool SigninScreenHandler::AllWhitelistedUsersPresent() {
1272 CrosSettings* cros_settings = CrosSettings::Get(); 1280 CrosSettings* cros_settings = CrosSettings::Get();
1273 bool allow_new_user = false; 1281 bool allow_new_user = false;
1274 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); 1282 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user);
1275 if (allow_new_user) 1283 if (allow_new_user)
1276 return false; 1284 return false;
1277 UserManager* user_manager = UserManager::Get(); 1285 UserManager* user_manager = UserManager::Get();
1278 const UserList& users = user_manager->GetUsers(); 1286 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(); 1394 return gaia_screen_handler_->frame_error();
1387 } 1395 }
1388 1396
1389 void SigninScreenHandler::OnCapsLockChanged(bool enabled) { 1397 void SigninScreenHandler::OnCapsLockChanged(bool enabled) {
1390 caps_lock_enabled_ = enabled; 1398 caps_lock_enabled_ = enabled;
1391 if (page_is_ready()) 1399 if (page_is_ready())
1392 CallJS("login.AccountPickerScreen.setCapsLockState", caps_lock_enabled_); 1400 CallJS("login.AccountPickerScreen.setCapsLockState", caps_lock_enabled_);
1393 } 1401 }
1394 1402
1395 } // namespace chromeos 1403 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698