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
3 // found in the LICENSE file.
5 #include "chromeos/login/auth/auth_attempt_state.h"
11 AuthAttemptState::AuthAttemptState(const UserContext
& user_context
,
15 : user_context(user_context
),
17 online_complete_(online_complete
),
18 online_outcome_(online_complete
? AuthFailure::UNLOCK_FAILED
20 is_first_time_user_(user_is_new
),
21 cryptohome_complete_(false),
22 cryptohome_outcome_(false),
23 cryptohome_code_(cryptohome::MOUNT_ERROR_NONE
),
24 username_hash_obtained_(true),
25 username_hash_valid_(true) {
28 AuthAttemptState::~AuthAttemptState() {
31 void AuthAttemptState::RecordOnlineLoginStatus(const AuthFailure
& outcome
) {
32 online_complete_
= true;
33 online_outcome_
= outcome
;
36 void AuthAttemptState::RecordCryptohomeStatus(
37 bool cryptohome_outcome
,
38 cryptohome::MountError cryptohome_code
) {
39 cryptohome_complete_
= true;
40 cryptohome_outcome_
= cryptohome_outcome
;
41 cryptohome_code_
= cryptohome_code
;
44 void AuthAttemptState::RecordUsernameHash(const std::string
& username_hash
) {
45 user_context
.SetUserIDHash(username_hash
);
46 username_hash_obtained_
= true;
47 username_hash_valid_
= true;
50 void AuthAttemptState::RecordUsernameHashFailed() {
51 username_hash_obtained_
= true;
52 username_hash_valid_
= false;
55 void AuthAttemptState::UsernameHashRequested() {
56 username_hash_obtained_
= false;
59 void AuthAttemptState::ResetCryptohomeStatus() {
60 cryptohome_complete_
= false;
61 cryptohome_outcome_
= false;
62 cryptohome_code_
= cryptohome::MOUNT_ERROR_NONE
;
65 bool AuthAttemptState::online_complete() {
66 return online_complete_
;
69 const AuthFailure
& AuthAttemptState::online_outcome() {
70 return online_outcome_
;
73 bool AuthAttemptState::is_first_time_user() {
74 return is_first_time_user_
;
77 bool AuthAttemptState::cryptohome_complete() {
78 return cryptohome_complete_
;
81 bool AuthAttemptState::cryptohome_outcome() {
82 return cryptohome_outcome_
;
85 cryptohome::MountError
AuthAttemptState::cryptohome_code() {
86 return cryptohome_code_
;
89 bool AuthAttemptState::username_hash_obtained() {
90 return username_hash_obtained_
;
93 bool AuthAttemptState::username_hash_valid() {
94 return username_hash_obtained_
;
97 } // namespace chromeos