| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chromeos/login/parallel_authenticator.h" | 5 #include "chrome/browser/chromeos/login/parallel_authenticator.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 void MountGuest(AuthAttemptState* attempt, | 103 void MountGuest(AuthAttemptState* attempt, |
| 104 scoped_refptr<ParallelAuthenticator> resolver) { | 104 scoped_refptr<ParallelAuthenticator> resolver) { |
| 105 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 105 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 106 cryptohome::AsyncMethodCaller::GetInstance()->AsyncMountGuest( | 106 cryptohome::AsyncMethodCaller::GetInstance()->AsyncMountGuest( |
| 107 base::Bind(&TriggerResolveWithLoginTimeMarker, | 107 base::Bind(&TriggerResolveWithLoginTimeMarker, |
| 108 "CryptohomeMount-End", | 108 "CryptohomeMount-End", |
| 109 attempt, | 109 attempt, |
| 110 resolver)); | 110 resolver)); |
| 111 } | 111 } |
| 112 | 112 |
| 113 // Calls cryptohome's mount method for guest and also get the user hash from |
| 114 // cryptohome. |
| 115 void MountGuestAndGetHash(AuthAttemptState* attempt, |
| 116 scoped_refptr<ParallelAuthenticator> resolver) { |
| 117 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 118 attempt->UsernameHashRequested(); |
| 119 cryptohome::AsyncMethodCaller::GetInstance()->AsyncMountGuest( |
| 120 base::Bind(&TriggerResolveWithLoginTimeMarker, |
| 121 "CryptohomeMount-End", |
| 122 attempt, |
| 123 resolver)); |
| 124 cryptohome::AsyncMethodCaller::GetInstance()->AsyncGetSanitizedUsername( |
| 125 attempt->user_context.username, |
| 126 base::Bind(&TriggerResolveHash, |
| 127 attempt, |
| 128 resolver)); |
| 129 } |
| 130 |
| 113 // Calls cryptohome's MountPublic method | 131 // Calls cryptohome's MountPublic method |
| 114 void MountPublic(AuthAttemptState* attempt, | 132 void MountPublic(AuthAttemptState* attempt, |
| 115 scoped_refptr<ParallelAuthenticator> resolver, | 133 scoped_refptr<ParallelAuthenticator> resolver, |
| 116 int flags) { | 134 int flags) { |
| 117 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 135 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 118 cryptohome::AsyncMethodCaller::GetInstance()->AsyncMountPublic( | 136 cryptohome::AsyncMethodCaller::GetInstance()->AsyncMountPublic( |
| 119 attempt->user_context.username, | 137 attempt->user_context.username, |
| 120 flags, | 138 flags, |
| 121 base::Bind(&TriggerResolveWithLoginTimeMarker, | 139 base::Bind(&TriggerResolveWithLoginTimeMarker, |
| 122 "CryptohomeMountPublic-End", | 140 "CryptohomeMountPublic-End", |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 remove_user_data_on_failure_ = false; | 357 remove_user_data_on_failure_ = false; |
| 340 ephemeral_mount_attempted_ = true; | 358 ephemeral_mount_attempted_ = true; |
| 341 SystemSaltGetter::Get()->GetSystemSalt( | 359 SystemSaltGetter::Get()->GetSystemSalt( |
| 342 base::Bind(&Mount, | 360 base::Bind(&Mount, |
| 343 current_state_.get(), | 361 current_state_.get(), |
| 344 scoped_refptr<ParallelAuthenticator>(this), | 362 scoped_refptr<ParallelAuthenticator>(this), |
| 345 cryptohome::CREATE_IF_MISSING | cryptohome::ENSURE_EPHEMERAL)); | 363 cryptohome::CREATE_IF_MISSING | cryptohome::ENSURE_EPHEMERAL)); |
| 346 } | 364 } |
| 347 | 365 |
| 348 void ParallelAuthenticator::LoginAsKioskAccount( | 366 void ParallelAuthenticator::LoginAsKioskAccount( |
| 349 const std::string& app_user_id, bool force_ephemeral) { | 367 const std::string& app_user_id, |
| 368 bool use_guest_mount) { |
| 350 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 369 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 351 | 370 |
| 352 std::string user_id = | 371 const std::string user_id = |
| 353 force_ephemeral ? UserManager::kGuestUserName : app_user_id; | 372 use_guest_mount ? UserManager::kGuestUserName : app_user_id; |
| 354 current_state_.reset(new AuthAttemptState( | 373 current_state_.reset(new AuthAttemptState( |
| 355 UserContext(user_id, | 374 UserContext(user_id, |
| 356 std::string(), // password | 375 std::string(), // password |
| 357 std::string()), // auth_code | 376 std::string()), // auth_code |
| 358 std::string(), // login_token | 377 std::string(), // login_token |
| 359 std::string(), // login_captcha | 378 std::string(), // login_captcha |
| 360 User::USER_TYPE_KIOSK_APP, | 379 User::USER_TYPE_KIOSK_APP, |
| 361 false)); | 380 false)); |
| 362 | 381 |
| 363 remove_user_data_on_failure_ = true; | 382 remove_user_data_on_failure_ = true; |
| 364 if (!force_ephemeral) { | 383 if (!use_guest_mount) { |
| 365 MountPublic(current_state_.get(), | 384 MountPublic(current_state_.get(), |
| 366 scoped_refptr<ParallelAuthenticator>(this), | 385 scoped_refptr<ParallelAuthenticator>(this), |
| 367 cryptohome::CREATE_IF_MISSING); | 386 cryptohome::CREATE_IF_MISSING); |
| 368 } else { | 387 } else { |
| 369 ephemeral_mount_attempted_ = true; | 388 ephemeral_mount_attempted_ = true; |
| 370 MountGuest(current_state_.get(), | 389 MountGuestAndGetHash(current_state_.get(), |
| 371 scoped_refptr<ParallelAuthenticator>(this)); | 390 scoped_refptr<ParallelAuthenticator>(this)); |
| 372 } | 391 } |
| 373 } | 392 } |
| 374 | 393 |
| 375 void ParallelAuthenticator::OnRetailModeLoginSuccess() { | 394 void ParallelAuthenticator::OnRetailModeLoginSuccess() { |
| 376 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 395 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 377 VLOG(1) << "Retail mode login success"; | 396 VLOG(1) << "Retail mode login success"; |
| 378 // Send notification of success | 397 // Send notification of success |
| 379 AuthenticationNotificationDetails details(true); | 398 AuthenticationNotificationDetails details(true); |
| 380 content::NotificationService::current()->Notify( | 399 content::NotificationService::current()->Notify( |
| 381 chrome::NOTIFICATION_LOGIN_AUTHENTICATION, | 400 chrome::NOTIFICATION_LOGIN_AUTHENTICATION, |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 Resolve(); | 835 Resolve(); |
| 817 } | 836 } |
| 818 | 837 |
| 819 void ParallelAuthenticator::SetOwnerState(bool owner_check_finished, | 838 void ParallelAuthenticator::SetOwnerState(bool owner_check_finished, |
| 820 bool check_result) { | 839 bool check_result) { |
| 821 owner_is_verified_ = owner_check_finished; | 840 owner_is_verified_ = owner_check_finished; |
| 822 user_can_login_ = check_result; | 841 user_can_login_ = check_result; |
| 823 } | 842 } |
| 824 | 843 |
| 825 } // namespace chromeos | 844 } // namespace chromeos |
| OLD | NEW |