OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "chrome/browser/chromeos/login/auth/auth_attempt_state.h" |
| 6 |
| 7 #include <string> |
| 8 |
| 9 #include "content/public/browser/browser_thread.h" |
| 10 #include "google_apis/gaia/gaia_auth_consumer.h" |
| 11 #include "google_apis/gaia/gaia_auth_fetcher.h" |
| 12 |
| 13 using content::BrowserThread; |
| 14 |
| 15 namespace chromeos { |
| 16 |
| 17 AuthAttemptState::AuthAttemptState(const UserContext& user_context, |
| 18 user_manager::UserType user_type, |
| 19 bool unlock, |
| 20 bool online_complete, |
| 21 bool user_is_new) |
| 22 : user_context(user_context), |
| 23 user_type(user_type), |
| 24 unlock(unlock), |
| 25 online_complete_(online_complete), |
| 26 online_outcome_(online_complete ? AuthFailure::UNLOCK_FAILED |
| 27 : AuthFailure::NONE), |
| 28 hosted_policy_(GaiaAuthFetcher::HostedAccountsAllowed), |
| 29 is_first_time_user_(user_is_new), |
| 30 cryptohome_complete_(false), |
| 31 cryptohome_outcome_(false), |
| 32 cryptohome_code_(cryptohome::MOUNT_ERROR_NONE), |
| 33 username_hash_obtained_(true), |
| 34 username_hash_valid_(true) { |
| 35 } |
| 36 |
| 37 AuthAttemptState::~AuthAttemptState() {} |
| 38 |
| 39 void AuthAttemptState::RecordOnlineLoginStatus(const AuthFailure& outcome) { |
| 40 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 41 online_complete_ = true; |
| 42 online_outcome_ = outcome; |
| 43 // We're either going to not try again, or try again with HOSTED |
| 44 // accounts not allowed, so just set this here. |
| 45 DisableHosted(); |
| 46 } |
| 47 |
| 48 void AuthAttemptState::DisableHosted() { |
| 49 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 50 hosted_policy_ = GaiaAuthFetcher::HostedAccountsNotAllowed; |
| 51 } |
| 52 |
| 53 void AuthAttemptState::RecordCryptohomeStatus( |
| 54 bool cryptohome_outcome, |
| 55 cryptohome::MountError cryptohome_code) { |
| 56 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 57 cryptohome_complete_ = true; |
| 58 cryptohome_outcome_ = cryptohome_outcome; |
| 59 cryptohome_code_ = cryptohome_code; |
| 60 } |
| 61 |
| 62 void AuthAttemptState::RecordUsernameHash(const std::string& username_hash) { |
| 63 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 64 user_context.SetUserIDHash(username_hash); |
| 65 username_hash_obtained_ = true; |
| 66 username_hash_valid_ = true; |
| 67 } |
| 68 |
| 69 void AuthAttemptState::RecordUsernameHashFailed() { |
| 70 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 71 username_hash_obtained_ = true; |
| 72 username_hash_valid_ = false; |
| 73 } |
| 74 |
| 75 void AuthAttemptState::UsernameHashRequested() { |
| 76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 77 username_hash_obtained_ = false; |
| 78 } |
| 79 |
| 80 void AuthAttemptState::ResetCryptohomeStatus() { |
| 81 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 82 cryptohome_complete_ = false; |
| 83 cryptohome_outcome_ = false; |
| 84 cryptohome_code_ = cryptohome::MOUNT_ERROR_NONE; |
| 85 } |
| 86 |
| 87 bool AuthAttemptState::online_complete() { |
| 88 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 89 return online_complete_; |
| 90 } |
| 91 |
| 92 const AuthFailure& AuthAttemptState::online_outcome() { |
| 93 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 94 return online_outcome_; |
| 95 } |
| 96 |
| 97 bool AuthAttemptState::is_first_time_user() { |
| 98 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 99 return is_first_time_user_; |
| 100 } |
| 101 |
| 102 GaiaAuthFetcher::HostedAccountsSetting AuthAttemptState::hosted_policy() { |
| 103 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 104 return hosted_policy_; |
| 105 } |
| 106 |
| 107 bool AuthAttemptState::cryptohome_complete() { |
| 108 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 109 return cryptohome_complete_; |
| 110 } |
| 111 |
| 112 bool AuthAttemptState::cryptohome_outcome() { |
| 113 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 114 return cryptohome_outcome_; |
| 115 } |
| 116 |
| 117 cryptohome::MountError AuthAttemptState::cryptohome_code() { |
| 118 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 119 return cryptohome_code_; |
| 120 } |
| 121 |
| 122 bool AuthAttemptState::username_hash_obtained() { |
| 123 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 124 return username_hash_obtained_; |
| 125 } |
| 126 |
| 127 bool AuthAttemptState::username_hash_valid() { |
| 128 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 129 return username_hash_obtained_; |
| 130 } |
| 131 |
| 132 } // namespace chromeos |
OLD | NEW |