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 hosted_policy_(GaiaAuthFetcher::HostedAccountsAllowed
),
21 is_first_time_user_(user_is_new
),
22 cryptohome_complete_(false),
23 cryptohome_outcome_(false),
24 cryptohome_code_(cryptohome::MOUNT_ERROR_NONE
),
25 username_hash_obtained_(true),
26 username_hash_valid_(true) {
29 AuthAttemptState::~AuthAttemptState() {
32 void AuthAttemptState::RecordOnlineLoginStatus(const AuthFailure
& outcome
) {
33 online_complete_
= true;
34 online_outcome_
= outcome
;
35 // We're either going to not try again, or try again with HOSTED
36 // accounts not allowed, so just set this here.
40 void AuthAttemptState::DisableHosted() {
41 hosted_policy_
= GaiaAuthFetcher::HostedAccountsNotAllowed
;
44 void AuthAttemptState::RecordCryptohomeStatus(
45 bool cryptohome_outcome
,
46 cryptohome::MountError cryptohome_code
) {
47 cryptohome_complete_
= true;
48 cryptohome_outcome_
= cryptohome_outcome
;
49 cryptohome_code_
= cryptohome_code
;
52 void AuthAttemptState::RecordUsernameHash(const std::string
& username_hash
) {
53 user_context
.SetUserIDHash(username_hash
);
54 username_hash_obtained_
= true;
55 username_hash_valid_
= true;
58 void AuthAttemptState::RecordUsernameHashFailed() {
59 username_hash_obtained_
= true;
60 username_hash_valid_
= false;
63 void AuthAttemptState::UsernameHashRequested() {
64 username_hash_obtained_
= false;
67 void AuthAttemptState::ResetCryptohomeStatus() {
68 cryptohome_complete_
= false;
69 cryptohome_outcome_
= false;
70 cryptohome_code_
= cryptohome::MOUNT_ERROR_NONE
;
73 bool AuthAttemptState::online_complete() {
74 return online_complete_
;
77 const AuthFailure
& AuthAttemptState::online_outcome() {
78 return online_outcome_
;
81 bool AuthAttemptState::is_first_time_user() {
82 return is_first_time_user_
;
85 GaiaAuthFetcher::HostedAccountsSetting
AuthAttemptState::hosted_policy() {
86 return hosted_policy_
;
89 bool AuthAttemptState::cryptohome_complete() {
90 return cryptohome_complete_
;
93 bool AuthAttemptState::cryptohome_outcome() {
94 return cryptohome_outcome_
;
97 cryptohome::MountError
AuthAttemptState::cryptohome_code() {
98 return cryptohome_code_
;
101 bool AuthAttemptState::username_hash_obtained() {
102 return username_hash_obtained_
;
105 bool AuthAttemptState::username_hash_valid() {
106 return username_hash_obtained_
;
109 } // namespace chromeos