OLD | NEW |
---|---|
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 #ifndef CHROMEOS_LOGIN_AUTH_AUTH_STATUS_CONSUMER_H_ | 5 #ifndef CHROMEOS_LOGIN_AUTH_AUTH_STATUS_CONSUMER_H_ |
6 #define CHROMEOS_LOGIN_AUTH_AUTH_STATUS_CONSUMER_H_ | 6 #define CHROMEOS_LOGIN_AUTH_AUTH_STATUS_CONSUMER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 22 matching lines...) Expand all Loading... | |
33 // value is synthesized by the ExistingUserController and passed to the | 33 // value is synthesized by the ExistingUserController and passed to the |
34 // login_status_consumer_ in tests only. It is never generated or seen by | 34 // login_status_consumer_ in tests only. It is never generated or seen by |
35 // any of the other authenticator classes. | 35 // any of the other authenticator classes. |
36 TPM_ERROR, // Critical TPM error encountered. | 36 TPM_ERROR, // Critical TPM error encountered. |
37 USERNAME_HASH_FAILED, // Could not get username hash. | 37 USERNAME_HASH_FAILED, // Could not get username hash. |
38 FAILED_TO_INITIALIZE_TOKEN, // Could not get OAuth2 Token, | 38 FAILED_TO_INITIALIZE_TOKEN, // Could not get OAuth2 Token, |
39 NUM_FAILURE_REASONS, // This has to be the last item. | 39 NUM_FAILURE_REASONS, // This has to be the last item. |
40 }; | 40 }; |
41 | 41 |
42 explicit AuthFailure(FailureReason reason) | 42 explicit AuthFailure(FailureReason reason) |
43 : reason_(reason), error_(GoogleServiceAuthError::NONE) { | 43 : is_pin_attempt_(false), |
jdufault
2016/08/04 19:42:04
Initialize in declaration (line 107) instead of in
sammiequon
2016/08/05 01:46:00
Done.
| |
44 reason_(reason), | |
45 error_(GoogleServiceAuthError::NONE) { | |
44 DCHECK(reason != NETWORK_AUTH_FAILED); | 46 DCHECK(reason != NETWORK_AUTH_FAILED); |
45 } | 47 } |
46 | 48 |
47 inline bool operator==(const AuthFailure& b) const { | 49 inline bool operator==(const AuthFailure& b) const { |
48 if (reason_ != b.reason_) { | 50 if (reason_ != b.reason_) { |
49 return false; | 51 return false; |
50 } | 52 } |
51 if (reason_ == NETWORK_AUTH_FAILED) { | 53 if (reason_ == NETWORK_AUTH_FAILED) { |
52 return error_ == b.error_; | 54 return error_ == b.error_; |
53 } | 55 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 return "OAuth2 token fetch failed."; | 90 return "OAuth2 token fetch failed."; |
89 default: | 91 default: |
90 NOTREACHED(); | 92 NOTREACHED(); |
91 return std::string(); | 93 return std::string(); |
92 } | 94 } |
93 } | 95 } |
94 | 96 |
95 const GoogleServiceAuthError& error() const { return error_; } | 97 const GoogleServiceAuthError& error() const { return error_; } |
96 const FailureReason& reason() const { return reason_; } | 98 const FailureReason& reason() const { return reason_; } |
97 | 99 |
100 void SetIsPinAttempt(bool tried_pin) { is_pin_attempt_ = tried_pin; } | |
101 bool IsPinAttempt() const { return is_pin_attempt_; } | |
102 | |
98 private: | 103 private: |
99 AuthFailure(FailureReason reason, GoogleServiceAuthError error) | 104 AuthFailure(FailureReason reason, GoogleServiceAuthError error) |
100 : reason_(reason), error_(error) {} | 105 : is_pin_attempt_(false), reason_(reason), error_(error) {} |
101 | 106 |
107 bool is_pin_attempt_; | |
102 FailureReason reason_; | 108 FailureReason reason_; |
103 GoogleServiceAuthError error_; | 109 GoogleServiceAuthError error_; |
104 }; | 110 }; |
105 | 111 |
106 // An interface that defines the callbacks for objects that the | 112 // An interface that defines the callbacks for objects that the |
107 // Authenticator class will call to report the success/failure of | 113 // Authenticator class will call to report the success/failure of |
108 // authentication for Chromium OS. | 114 // authentication for Chromium OS. |
109 class CHROMEOS_EXPORT AuthStatusConsumer { | 115 class CHROMEOS_EXPORT AuthStatusConsumer { |
110 public: | 116 public: |
111 virtual ~AuthStatusConsumer() {} | 117 virtual ~AuthStatusConsumer() {} |
112 // The current login attempt has ended in failure, with error |error|. | 118 // The current login attempt has ended in failure, with error |error|. |
113 virtual void OnAuthFailure(const AuthFailure& error) = 0; | 119 virtual void OnAuthFailure(const AuthFailure& error) = 0; |
114 | 120 |
115 // The current login attempt has succeeded for |user_context|. | 121 // The current login attempt has succeeded for |user_context|. |
116 virtual void OnAuthSuccess(const UserContext& user_context) = 0; | 122 virtual void OnAuthSuccess(const UserContext& user_context) = 0; |
117 // The current guest login attempt has succeeded. | 123 // The current guest login attempt has succeeded. |
118 virtual void OnOffTheRecordAuthSuccess() {} | 124 virtual void OnOffTheRecordAuthSuccess() {} |
119 // The same password didn't work both online and offline. | 125 // The same password didn't work both online and offline. |
120 virtual void OnPasswordChangeDetected(); | 126 virtual void OnPasswordChangeDetected(); |
121 }; | 127 }; |
122 | 128 |
123 } // namespace chromeos | 129 } // namespace chromeos |
124 | 130 |
125 #endif // CHROMEOS_LOGIN_AUTH_AUTH_STATUS_CONSUMER_H_ | 131 #endif // CHROMEOS_LOGIN_AUTH_AUTH_STATUS_CONSUMER_H_ |
OLD | NEW |