Move action_runner.py out of actions folder prior to moving actions to internal.
[chromium-blink-merge.git] / chromeos / login / auth / auth_attempt_state.cc
blob9e328be3376b0ff8ba778f3c1063a3bbad53c112
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"
9 namespace chromeos {
11 AuthAttemptState::AuthAttemptState(const UserContext& user_context,
12 user_manager::UserType user_type,
13 bool unlock,
14 bool online_complete,
15 bool user_is_new)
16 : user_context(user_context),
17 user_type(user_type),
18 unlock(unlock),
19 online_complete_(online_complete),
20 online_outcome_(online_complete ? AuthFailure::UNLOCK_FAILED
21 : AuthFailure::NONE),
22 hosted_policy_(GaiaAuthFetcher::HostedAccountsAllowed),
23 is_first_time_user_(user_is_new),
24 cryptohome_complete_(false),
25 cryptohome_outcome_(false),
26 cryptohome_code_(cryptohome::MOUNT_ERROR_NONE),
27 username_hash_obtained_(true),
28 username_hash_valid_(true) {
31 AuthAttemptState::~AuthAttemptState() {
34 void AuthAttemptState::RecordOnlineLoginStatus(const AuthFailure& outcome) {
35 online_complete_ = true;
36 online_outcome_ = outcome;
37 // We're either going to not try again, or try again with HOSTED
38 // accounts not allowed, so just set this here.
39 DisableHosted();
42 void AuthAttemptState::DisableHosted() {
43 hosted_policy_ = GaiaAuthFetcher::HostedAccountsNotAllowed;
46 void AuthAttemptState::RecordCryptohomeStatus(
47 bool cryptohome_outcome,
48 cryptohome::MountError cryptohome_code) {
49 cryptohome_complete_ = true;
50 cryptohome_outcome_ = cryptohome_outcome;
51 cryptohome_code_ = cryptohome_code;
54 void AuthAttemptState::RecordUsernameHash(const std::string& username_hash) {
55 user_context.SetUserIDHash(username_hash);
56 username_hash_obtained_ = true;
57 username_hash_valid_ = true;
60 void AuthAttemptState::RecordUsernameHashFailed() {
61 username_hash_obtained_ = true;
62 username_hash_valid_ = false;
65 void AuthAttemptState::UsernameHashRequested() {
66 username_hash_obtained_ = false;
69 void AuthAttemptState::ResetCryptohomeStatus() {
70 cryptohome_complete_ = false;
71 cryptohome_outcome_ = false;
72 cryptohome_code_ = cryptohome::MOUNT_ERROR_NONE;
75 bool AuthAttemptState::online_complete() {
76 return online_complete_;
79 const AuthFailure& AuthAttemptState::online_outcome() {
80 return online_outcome_;
83 bool AuthAttemptState::is_first_time_user() {
84 return is_first_time_user_;
87 GaiaAuthFetcher::HostedAccountsSetting AuthAttemptState::hosted_policy() {
88 return hosted_policy_;
91 bool AuthAttemptState::cryptohome_complete() {
92 return cryptohome_complete_;
95 bool AuthAttemptState::cryptohome_outcome() {
96 return cryptohome_outcome_;
99 cryptohome::MountError AuthAttemptState::cryptohome_code() {
100 return cryptohome_code_;
103 bool AuthAttemptState::username_hash_obtained() {
104 return username_hash_obtained_;
107 bool AuthAttemptState::username_hash_valid() {
108 return username_hash_obtained_;
111 } // namespace chromeos