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

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

Issue 413473003: Revert of Refactoring : Move AuthAttempt and Authenticators to chromeos/login (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
(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 "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
40 void AuthAttemptState::RecordOnlineLoginStatus(const AuthFailure& outcome) {
41 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
42 online_complete_ = true;
43 online_outcome_ = outcome;
44 // We're either going to not try again, or try again with HOSTED
45 // accounts not allowed, so just set this here.
46 DisableHosted();
47 }
48
49 void AuthAttemptState::DisableHosted() {
50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
51 hosted_policy_ = GaiaAuthFetcher::HostedAccountsNotAllowed;
52 }
53
54 void AuthAttemptState::RecordCryptohomeStatus(
55 bool cryptohome_outcome,
56 cryptohome::MountError cryptohome_code) {
57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
58 cryptohome_complete_ = true;
59 cryptohome_outcome_ = cryptohome_outcome;
60 cryptohome_code_ = cryptohome_code;
61 }
62
63 void AuthAttemptState::RecordUsernameHash(const std::string& username_hash) {
64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
65 user_context.SetUserIDHash(username_hash);
66 username_hash_obtained_ = true;
67 username_hash_valid_ = true;
68 }
69
70 void AuthAttemptState::RecordUsernameHashFailed() {
71 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
72 username_hash_obtained_ = true;
73 username_hash_valid_ = false;
74 }
75
76 void AuthAttemptState::UsernameHashRequested() {
77 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
78 username_hash_obtained_ = false;
79 }
80
81 void AuthAttemptState::ResetCryptohomeStatus() {
82 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
83 cryptohome_complete_ = false;
84 cryptohome_outcome_ = false;
85 cryptohome_code_ = cryptohome::MOUNT_ERROR_NONE;
86 }
87
88 bool AuthAttemptState::online_complete() {
89 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
90 return online_complete_;
91 }
92
93 const AuthFailure& AuthAttemptState::online_outcome() {
94 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
95 return online_outcome_;
96 }
97
98 bool AuthAttemptState::is_first_time_user() {
99 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
100 return is_first_time_user_;
101 }
102
103 GaiaAuthFetcher::HostedAccountsSetting AuthAttemptState::hosted_policy() {
104 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
105 return hosted_policy_;
106 }
107
108 bool AuthAttemptState::cryptohome_complete() {
109 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
110 return cryptohome_complete_;
111 }
112
113 bool AuthAttemptState::cryptohome_outcome() {
114 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
115 return cryptohome_outcome_;
116 }
117
118 cryptohome::MountError AuthAttemptState::cryptohome_code() {
119 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
120 return cryptohome_code_;
121 }
122
123 bool AuthAttemptState::username_hash_obtained() {
124 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
125 return username_hash_obtained_;
126 }
127
128 bool AuthAttemptState::username_hash_valid() {
129 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
130 return username_hash_obtained_;
131 }
132
133 } // 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