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 11 matching lines...) Expand all Loading... |
22 enum FailureReason { | 22 enum FailureReason { |
23 NONE, | 23 NONE, |
24 COULD_NOT_MOUNT_CRYPTOHOME, | 24 COULD_NOT_MOUNT_CRYPTOHOME, |
25 COULD_NOT_MOUNT_TMPFS, | 25 COULD_NOT_MOUNT_TMPFS, |
26 COULD_NOT_UNMOUNT_CRYPTOHOME, | 26 COULD_NOT_UNMOUNT_CRYPTOHOME, |
27 DATA_REMOVAL_FAILED, // Could not destroy your old data | 27 DATA_REMOVAL_FAILED, // Could not destroy your old data |
28 LOGIN_TIMED_OUT, | 28 LOGIN_TIMED_OUT, |
29 UNLOCK_FAILED, | 29 UNLOCK_FAILED, |
30 NETWORK_AUTH_FAILED, // Could not authenticate against Google | 30 NETWORK_AUTH_FAILED, // Could not authenticate against Google |
31 OWNER_REQUIRED, // Only the device owner can log-in. | 31 OWNER_REQUIRED, // Only the device owner can log-in. |
32 WHITELIST_CHECK_FAILED, // Login attempt blocked by whitelist. This | 32 WHITELIST_CHECK_FAILED, // Login attempt blocked by whitelist. This value |
33 // value is synthesized by the ExistingUserController and passed to the | 33 // is |
34 // login_status_consumer_ in tests only. It is never generated or seen by | 34 // synthesized by the ExistingUserController and |
35 // any of the other authenticator classes. | 35 // passed to the login_status_consumer_ in tests |
36 TPM_ERROR, // Critical TPM error encountered. | 36 // only. It is never generated or seen by any of the |
37 USERNAME_HASH_FAILED, // Could not get username hash. | 37 // other authenticator classes. |
38 FAILED_TO_INITIALIZE_TOKEN, // Could not get OAuth2 Token, | 38 TPM_ERROR, // Critical TPM error encountered. |
39 NUM_FAILURE_REASONS, // This has to be the last item. | 39 USERNAME_HASH_FAILED, // Could not get username hash. |
| 40 NUM_FAILURE_REASONS, // This has to be the last item. |
40 }; | 41 }; |
41 | 42 |
42 explicit AuthFailure(FailureReason reason) | 43 explicit AuthFailure(FailureReason reason) |
43 : reason_(reason), error_(GoogleServiceAuthError::NONE) { | 44 : reason_(reason), error_(GoogleServiceAuthError::NONE) { |
44 DCHECK(reason != NETWORK_AUTH_FAILED); | 45 DCHECK(reason != NETWORK_AUTH_FAILED); |
45 } | 46 } |
46 | 47 |
47 inline bool operator==(const AuthFailure& b) const { | 48 inline bool operator==(const AuthFailure& b) const { |
48 if (reason_ != b.reason_) { | 49 if (reason_ != b.reason_) { |
49 return false; | 50 return false; |
(...skipping 27 matching lines...) Expand all Loading... |
77 return "Unlock failed."; | 78 return "Unlock failed."; |
78 case NETWORK_AUTH_FAILED: | 79 case NETWORK_AUTH_FAILED: |
79 if (error_.state() == GoogleServiceAuthError::CONNECTION_FAILED) { | 80 if (error_.state() == GoogleServiceAuthError::CONNECTION_FAILED) { |
80 return net::ErrorToString(error_.network_error()); | 81 return net::ErrorToString(error_.network_error()); |
81 } | 82 } |
82 return "Google authentication failed."; | 83 return "Google authentication failed."; |
83 case OWNER_REQUIRED: | 84 case OWNER_REQUIRED: |
84 return "Login is restricted to the owner's account only."; | 85 return "Login is restricted to the owner's account only."; |
85 case WHITELIST_CHECK_FAILED: | 86 case WHITELIST_CHECK_FAILED: |
86 return "Login attempt blocked by whitelist."; | 87 return "Login attempt blocked by whitelist."; |
87 case FAILED_TO_INITIALIZE_TOKEN: | |
88 return "OAuth2 token fetch failed."; | |
89 default: | 88 default: |
90 NOTREACHED(); | 89 NOTREACHED(); |
91 return std::string(); | 90 return std::string(); |
92 } | 91 } |
93 } | 92 } |
94 | 93 |
95 const GoogleServiceAuthError& error() const { return error_; } | 94 const GoogleServiceAuthError& error() const { return error_; } |
96 const FailureReason& reason() const { return reason_; } | 95 const FailureReason& reason() const { return reason_; } |
97 | 96 |
98 private: | 97 private: |
(...skipping 17 matching lines...) Expand all Loading... |
116 virtual void OnAuthSuccess(const UserContext& user_context) = 0; | 115 virtual void OnAuthSuccess(const UserContext& user_context) = 0; |
117 // The current guest login attempt has succeeded. | 116 // The current guest login attempt has succeeded. |
118 virtual void OnOffTheRecordAuthSuccess() {} | 117 virtual void OnOffTheRecordAuthSuccess() {} |
119 // The same password didn't work both online and offline. | 118 // The same password didn't work both online and offline. |
120 virtual void OnPasswordChangeDetected(); | 119 virtual void OnPasswordChangeDetected(); |
121 }; | 120 }; |
122 | 121 |
123 } // namespace chromeos | 122 } // namespace chromeos |
124 | 123 |
125 #endif // CHROMEOS_LOGIN_AUTH_AUTH_STATUS_CONSUMER_H_ | 124 #endif // CHROMEOS_LOGIN_AUTH_AUTH_STATUS_CONSUMER_H_ |
OLD | NEW |