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