OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/signin/easy_unlock_service.h" | 5 #include "chrome/browser/signin/easy_unlock_service.h" |
6 | 6 |
7 #include "apps/app_lifetime_monitor.h" | 7 #include "apps/app_lifetime_monitor.h" |
8 #include "apps/app_lifetime_monitor_factory.h" | 8 #include "apps/app_lifetime_monitor_factory.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 | 486 |
487 return handler->state(); | 487 return handler->state(); |
488 } | 488 } |
489 | 489 |
490 void EasyUnlockService::AttemptAuth(const std::string& user_id) { | 490 void EasyUnlockService::AttemptAuth(const std::string& user_id) { |
491 AttemptAuth(user_id, AttemptAuthCallback()); | 491 AttemptAuth(user_id, AttemptAuthCallback()); |
492 } | 492 } |
493 | 493 |
494 void EasyUnlockService::AttemptAuth(const std::string& user_id, | 494 void EasyUnlockService::AttemptAuth(const std::string& user_id, |
495 const AttemptAuthCallback& callback) { | 495 const AttemptAuthCallback& callback) { |
| 496 const EasyUnlockAuthAttempt::Type auth_attempt_type = |
| 497 GetType() == TYPE_REGULAR ? EasyUnlockAuthAttempt::TYPE_UNLOCK |
| 498 : EasyUnlockAuthAttempt::TYPE_SIGNIN; |
| 499 const std::string user_email = GetUserEmail(); |
| 500 if (user_email.empty()) { |
| 501 LOG(ERROR) << "Empty user email. Refresh token might go bad."; |
| 502 if (!callback.is_null()) { |
| 503 const bool kFailure = false; |
| 504 callback.Run(auth_attempt_type, kFailure, user_id, std::string(), |
| 505 std::string()); |
| 506 } |
| 507 return; |
| 508 } |
| 509 |
496 CHECK_EQ(GetUserEmail(), user_id); | 510 CHECK_EQ(GetUserEmail(), user_id); |
497 | 511 |
498 auth_attempt_.reset(new EasyUnlockAuthAttempt( | 512 auth_attempt_.reset(new EasyUnlockAuthAttempt(app_manager_.get(), user_id, |
499 app_manager_.get(), user_id, | 513 auth_attempt_type, callback)); |
500 GetType() == TYPE_REGULAR ? EasyUnlockAuthAttempt::TYPE_UNLOCK | |
501 : EasyUnlockAuthAttempt::TYPE_SIGNIN, | |
502 callback)); | |
503 if (!auth_attempt_->Start()) | 514 if (!auth_attempt_->Start()) |
504 auth_attempt_.reset(); | 515 auth_attempt_.reset(); |
505 } | 516 } |
506 | 517 |
507 void EasyUnlockService::FinalizeUnlock(bool success) { | 518 void EasyUnlockService::FinalizeUnlock(bool success) { |
508 if (!auth_attempt_.get()) | 519 if (!auth_attempt_.get()) |
509 return; | 520 return; |
510 | 521 |
511 this->OnWillFinalizeUnlock(success); | 522 this->OnWillFinalizeUnlock(success); |
512 auth_attempt_->FinalizeUnlock(GetUserEmail(), success); | 523 auth_attempt_->FinalizeUnlock(GetUserEmail(), success); |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 | 868 |
858 // TODO(tbarzic): Set check_private_key only if previous sign-in attempt | 869 // TODO(tbarzic): Set check_private_key only if previous sign-in attempt |
859 // failed. | 870 // failed. |
860 EasyUnlockTpmKeyManagerFactory::GetInstance()->Get(profile_) | 871 EasyUnlockTpmKeyManagerFactory::GetInstance()->Get(profile_) |
861 ->PrepareTpmKey(true /* check_private_key */, | 872 ->PrepareTpmKey(true /* check_private_key */, |
862 base::Closure()); | 873 base::Closure()); |
863 #endif // defined(OS_CHROMEOS) | 874 #endif // defined(OS_CHROMEOS) |
864 | 875 |
865 tpm_key_checked_ = true; | 876 tpm_key_checked_ = true; |
866 } | 877 } |
OLD | NEW |