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