Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: chromeos/login/auth/auth_attempt_state.cc

Issue 391373002: Refactoring : Move AuthAttempt and Authenticators to chromeos/login (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge w/ToT Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/chromeos/login/auth/auth_attempt_state.h" 5 #include "chromeos/login/auth/auth_attempt_state.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "content/public/browser/browser_thread.h"
10 #include "google_apis/gaia/gaia_auth_consumer.h" 9 #include "google_apis/gaia/gaia_auth_consumer.h"
11 #include "google_apis/gaia/gaia_auth_fetcher.h" 10 #include "google_apis/gaia/gaia_auth_fetcher.h"
12 11
13 using content::BrowserThread;
14
15 namespace chromeos { 12 namespace chromeos {
16 13
17 AuthAttemptState::AuthAttemptState(const UserContext& user_context, 14 AuthAttemptState::AuthAttemptState(const UserContext& user_context,
18 user_manager::UserType user_type, 15 user_manager::UserType user_type,
19 bool unlock, 16 bool unlock,
20 bool online_complete, 17 bool online_complete,
21 bool user_is_new) 18 bool user_is_new)
22 : user_context(user_context), 19 : user_context(user_context),
23 user_type(user_type), 20 user_type(user_type),
24 unlock(unlock), 21 unlock(unlock),
25 online_complete_(online_complete), 22 online_complete_(online_complete),
26 online_outcome_(online_complete ? AuthFailure::UNLOCK_FAILED 23 online_outcome_(online_complete ? AuthFailure::UNLOCK_FAILED
27 : AuthFailure::NONE), 24 : AuthFailure::NONE),
28 hosted_policy_(GaiaAuthFetcher::HostedAccountsAllowed), 25 hosted_policy_(GaiaAuthFetcher::HostedAccountsAllowed),
29 is_first_time_user_(user_is_new), 26 is_first_time_user_(user_is_new),
30 cryptohome_complete_(false), 27 cryptohome_complete_(false),
31 cryptohome_outcome_(false), 28 cryptohome_outcome_(false),
32 cryptohome_code_(cryptohome::MOUNT_ERROR_NONE), 29 cryptohome_code_(cryptohome::MOUNT_ERROR_NONE),
33 username_hash_obtained_(true), 30 username_hash_obtained_(true),
34 username_hash_valid_(true) { 31 username_hash_valid_(true) {
35 } 32 }
36 33
37 AuthAttemptState::~AuthAttemptState() {} 34 AuthAttemptState::~AuthAttemptState() {
35 }
38 36
39 void AuthAttemptState::RecordOnlineLoginStatus(const AuthFailure& outcome) { 37 void AuthAttemptState::RecordOnlineLoginStatus(const AuthFailure& outcome) {
40 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
41 online_complete_ = true; 38 online_complete_ = true;
42 online_outcome_ = outcome; 39 online_outcome_ = outcome;
43 // We're either going to not try again, or try again with HOSTED 40 // We're either going to not try again, or try again with HOSTED
44 // accounts not allowed, so just set this here. 41 // accounts not allowed, so just set this here.
45 DisableHosted(); 42 DisableHosted();
46 } 43 }
47 44
48 void AuthAttemptState::DisableHosted() { 45 void AuthAttemptState::DisableHosted() {
49 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
50 hosted_policy_ = GaiaAuthFetcher::HostedAccountsNotAllowed; 46 hosted_policy_ = GaiaAuthFetcher::HostedAccountsNotAllowed;
51 } 47 }
52 48
53 void AuthAttemptState::RecordCryptohomeStatus( 49 void AuthAttemptState::RecordCryptohomeStatus(
54 bool cryptohome_outcome, 50 bool cryptohome_outcome,
55 cryptohome::MountError cryptohome_code) { 51 cryptohome::MountError cryptohome_code) {
56 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
57 cryptohome_complete_ = true; 52 cryptohome_complete_ = true;
58 cryptohome_outcome_ = cryptohome_outcome; 53 cryptohome_outcome_ = cryptohome_outcome;
59 cryptohome_code_ = cryptohome_code; 54 cryptohome_code_ = cryptohome_code;
60 } 55 }
61 56
62 void AuthAttemptState::RecordUsernameHash(const std::string& username_hash) { 57 void AuthAttemptState::RecordUsernameHash(const std::string& username_hash) {
63 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
64 user_context.SetUserIDHash(username_hash); 58 user_context.SetUserIDHash(username_hash);
65 username_hash_obtained_ = true; 59 username_hash_obtained_ = true;
66 username_hash_valid_ = true; 60 username_hash_valid_ = true;
67 } 61 }
68 62
69 void AuthAttemptState::RecordUsernameHashFailed() { 63 void AuthAttemptState::RecordUsernameHashFailed() {
70 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
71 username_hash_obtained_ = true; 64 username_hash_obtained_ = true;
72 username_hash_valid_ = false; 65 username_hash_valid_ = false;
73 } 66 }
74 67
75 void AuthAttemptState::UsernameHashRequested() { 68 void AuthAttemptState::UsernameHashRequested() {
76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
77 username_hash_obtained_ = false; 69 username_hash_obtained_ = false;
78 } 70 }
79 71
80 void AuthAttemptState::ResetCryptohomeStatus() { 72 void AuthAttemptState::ResetCryptohomeStatus() {
81 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
82 cryptohome_complete_ = false; 73 cryptohome_complete_ = false;
83 cryptohome_outcome_ = false; 74 cryptohome_outcome_ = false;
84 cryptohome_code_ = cryptohome::MOUNT_ERROR_NONE; 75 cryptohome_code_ = cryptohome::MOUNT_ERROR_NONE;
85 } 76 }
86 77
87 bool AuthAttemptState::online_complete() { 78 bool AuthAttemptState::online_complete() {
88 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
89 return online_complete_; 79 return online_complete_;
90 } 80 }
91 81
92 const AuthFailure& AuthAttemptState::online_outcome() { 82 const AuthFailure& AuthAttemptState::online_outcome() {
93 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
94 return online_outcome_; 83 return online_outcome_;
95 } 84 }
96 85
97 bool AuthAttemptState::is_first_time_user() { 86 bool AuthAttemptState::is_first_time_user() {
98 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
99 return is_first_time_user_; 87 return is_first_time_user_;
100 } 88 }
101 89
102 GaiaAuthFetcher::HostedAccountsSetting AuthAttemptState::hosted_policy() { 90 GaiaAuthFetcher::HostedAccountsSetting AuthAttemptState::hosted_policy() {
103 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
104 return hosted_policy_; 91 return hosted_policy_;
105 } 92 }
106 93
107 bool AuthAttemptState::cryptohome_complete() { 94 bool AuthAttemptState::cryptohome_complete() {
108 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
109 return cryptohome_complete_; 95 return cryptohome_complete_;
110 } 96 }
111 97
112 bool AuthAttemptState::cryptohome_outcome() { 98 bool AuthAttemptState::cryptohome_outcome() {
113 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
114 return cryptohome_outcome_; 99 return cryptohome_outcome_;
115 } 100 }
116 101
117 cryptohome::MountError AuthAttemptState::cryptohome_code() { 102 cryptohome::MountError AuthAttemptState::cryptohome_code() {
118 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
119 return cryptohome_code_; 103 return cryptohome_code_;
120 } 104 }
121 105
122 bool AuthAttemptState::username_hash_obtained() { 106 bool AuthAttemptState::username_hash_obtained() {
123 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
124 return username_hash_obtained_; 107 return username_hash_obtained_;
125 } 108 }
126 109
127 bool AuthAttemptState::username_hash_valid() { 110 bool AuthAttemptState::username_hash_valid() {
128 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
129 return username_hash_obtained_; 111 return username_hash_obtained_;
130 } 112 }
131 113
132 } // namespace chromeos 114 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/login/auth/auth_attempt_state.h ('k') | chromeos/login/auth/auth_attempt_state_resolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698