Chromium Code Reviews| 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 cryptohome::AsyncMethodCaller::GetInstance()->AsyncMountGuest( | |
|
bartfab (slow)
2014/03/27 14:13:29
The AuthAttemptState constructor sets username_has
rkc
2014/03/27 21:43:10
Done.
| |
| 119 base::Bind(&TriggerResolveWithLoginTimeMarker, | |
| 120 "CryptohomeMount-End", | |
| 121 attempt, | |
| 122 resolver)); | |
| 123 cryptohome::AsyncMethodCaller::GetInstance()->AsyncGetSanitizedUsername( | |
| 124 attempt->user_context.username, | |
| 125 base::Bind(&TriggerResolveHash, | |
| 126 attempt, | |
| 127 resolver)); | |
| 128 } | |
| 129 | |
| 113 // Calls cryptohome's MountPublic method | 130 // Calls cryptohome's MountPublic method |
| 114 void MountPublic(AuthAttemptState* attempt, | 131 void MountPublic(AuthAttemptState* attempt, |
| 115 scoped_refptr<ParallelAuthenticator> resolver, | 132 scoped_refptr<ParallelAuthenticator> resolver, |
| 116 int flags) { | 133 int flags) { |
| 117 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 134 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 118 cryptohome::AsyncMethodCaller::GetInstance()->AsyncMountPublic( | 135 cryptohome::AsyncMethodCaller::GetInstance()->AsyncMountPublic( |
| 119 attempt->user_context.username, | 136 attempt->user_context.username, |
| 120 flags, | 137 flags, |
| 121 base::Bind(&TriggerResolveWithLoginTimeMarker, | 138 base::Bind(&TriggerResolveWithLoginTimeMarker, |
| 122 "CryptohomeMountPublic-End", | 139 "CryptohomeMountPublic-End", |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 339 remove_user_data_on_failure_ = false; | 356 remove_user_data_on_failure_ = false; |
| 340 ephemeral_mount_attempted_ = true; | 357 ephemeral_mount_attempted_ = true; |
| 341 SystemSaltGetter::Get()->GetSystemSalt( | 358 SystemSaltGetter::Get()->GetSystemSalt( |
| 342 base::Bind(&Mount, | 359 base::Bind(&Mount, |
| 343 current_state_.get(), | 360 current_state_.get(), |
| 344 scoped_refptr<ParallelAuthenticator>(this), | 361 scoped_refptr<ParallelAuthenticator>(this), |
| 345 cryptohome::CREATE_IF_MISSING | cryptohome::ENSURE_EPHEMERAL)); | 362 cryptohome::CREATE_IF_MISSING | cryptohome::ENSURE_EPHEMERAL)); |
| 346 } | 363 } |
| 347 | 364 |
| 348 void ParallelAuthenticator::LoginAsKioskAccount( | 365 void ParallelAuthenticator::LoginAsKioskAccount( |
| 349 const std::string& app_user_id, bool force_ephemeral) { | 366 const std::string& app_user_id, |
| 367 bool use_guest_mount) { | |
| 350 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 368 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 351 | 369 |
| 352 std::string user_id = | 370 const std::string user_id = |
| 353 force_ephemeral ? UserManager::kGuestUserName : app_user_id; | 371 use_guest_mount ? UserManager::kGuestUserName : app_user_id; |
| 354 current_state_.reset(new AuthAttemptState( | 372 current_state_.reset(new AuthAttemptState( |
| 355 UserContext(user_id, | 373 UserContext(user_id, |
| 356 std::string(), // password | 374 std::string(), // password |
| 357 std::string()), // auth_code | 375 std::string()), // auth_code |
| 358 std::string(), // login_token | 376 std::string(), // login_token |
| 359 std::string(), // login_captcha | 377 std::string(), // login_captcha |
| 360 User::USER_TYPE_KIOSK_APP, | 378 User::USER_TYPE_KIOSK_APP, |
| 361 false)); | 379 false)); |
| 362 | 380 |
| 363 remove_user_data_on_failure_ = true; | 381 remove_user_data_on_failure_ = true; |
| 364 if (!force_ephemeral) { | 382 if (!use_guest_mount) { |
| 365 MountPublic(current_state_.get(), | 383 MountPublic(current_state_.get(), |
| 366 scoped_refptr<ParallelAuthenticator>(this), | 384 scoped_refptr<ParallelAuthenticator>(this), |
| 367 cryptohome::CREATE_IF_MISSING); | 385 cryptohome::CREATE_IF_MISSING); |
| 368 } else { | 386 } else { |
| 369 ephemeral_mount_attempted_ = true; | 387 ephemeral_mount_attempted_ = true; |
| 370 MountGuest(current_state_.get(), | 388 MountGuestAndGetHash(current_state_.get(), |
| 371 scoped_refptr<ParallelAuthenticator>(this)); | 389 scoped_refptr<ParallelAuthenticator>(this)); |
| 372 } | 390 } |
| 373 } | 391 } |
| 374 | 392 |
| 375 void ParallelAuthenticator::OnRetailModeLoginSuccess() { | 393 void ParallelAuthenticator::OnRetailModeLoginSuccess() { |
| 376 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 394 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 377 VLOG(1) << "Retail mode login success"; | 395 VLOG(1) << "Retail mode login success"; |
| 378 // Send notification of success | 396 // Send notification of success |
| 379 AuthenticationNotificationDetails details(true); | 397 AuthenticationNotificationDetails details(true); |
| 380 content::NotificationService::current()->Notify( | 398 content::NotificationService::current()->Notify( |
| 381 chrome::NOTIFICATION_LOGIN_AUTHENTICATION, | 399 chrome::NOTIFICATION_LOGIN_AUTHENTICATION, |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 816 Resolve(); | 834 Resolve(); |
| 817 } | 835 } |
| 818 | 836 |
| 819 void ParallelAuthenticator::SetOwnerState(bool owner_check_finished, | 837 void ParallelAuthenticator::SetOwnerState(bool owner_check_finished, |
| 820 bool check_result) { | 838 bool check_result) { |
| 821 owner_is_verified_ = owner_check_finished; | 839 owner_is_verified_ = owner_check_finished; |
| 822 user_can_login_ = check_result; | 840 user_can_login_ = check_result; |
| 823 } | 841 } |
| 824 | 842 |
| 825 } // namespace chromeos | 843 } // namespace chromeos |
| OLD | NEW |