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

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

Powered by Google App Engine
This is Rietveld 408576698