| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_ATTEMPT_STATE_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_ATTEMPT_STATE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "chrome/browser/chromeos/login/login_status_consumer.h" | |
| 11 #include "chrome/browser/chromeos/login/user.h" | |
| 12 #include "google_apis/gaia/gaia_auth_consumer.h" | |
| 13 #include "google_apis/gaia/gaia_auth_fetcher.h" | |
| 14 #include "third_party/cros_system_api/dbus/service_constants.h" | |
| 15 | |
| 16 namespace chromeos { | |
| 17 | |
| 18 // Tracks the state associated with a single attempt to log in to chromium os. | |
| 19 // Enforces that methods are only called on the UI thread. | |
| 20 | |
| 21 class AuthAttemptState { | |
| 22 public: | |
| 23 // Used to initialize for a login attempt. | |
| 24 AuthAttemptState(const UserContext& user_context, | |
| 25 const std::string& login_token, | |
| 26 const std::string& login_captcha, | |
| 27 const User::UserType user_type, | |
| 28 const bool user_is_new); | |
| 29 | |
| 30 // Used to initialize for a externally authenticated login. | |
| 31 AuthAttemptState(const UserContext& user_context, | |
| 32 const bool user_is_new); | |
| 33 | |
| 34 // Used to initialize for a screen unlock attempt. | |
| 35 AuthAttemptState(const std::string& username, const std::string& password); | |
| 36 | |
| 37 virtual ~AuthAttemptState(); | |
| 38 | |
| 39 // Copy |user_context| and copy |outcome| into this object, so we can have | |
| 40 // a copy we're sure to own, and can make available on the UI thread. | |
| 41 // Must be called from the UI thread. | |
| 42 void RecordOnlineLoginStatus( | |
| 43 const LoginFailure& outcome); | |
| 44 | |
| 45 // Copy |username_hash| into this object, so we can have | |
| 46 // a copy we're sure to own, and can make available on the UI thread. | |
| 47 // Must be called from the UI thread. | |
| 48 void RecordUsernameHash(const std::string& username_hash); | |
| 49 | |
| 50 // Marks that the username hash request attempt has failed. | |
| 51 void RecordUsernameHashFailed(); | |
| 52 | |
| 53 // Marks username hash as being requested so that flow will block till both | |
| 54 // requests (Mount/GetUsernameHash) are completed. | |
| 55 void UsernameHashRequested(); | |
| 56 | |
| 57 // The next attempt will not allow HOSTED accounts to log in. | |
| 58 void DisableHosted(); | |
| 59 | |
| 60 // Copy |cryptohome_code| and |cryptohome_outcome| into this object, | |
| 61 // so we can have a copy we're sure to own, and can make available | |
| 62 // on the UI thread. Must be called from the UI thread. | |
| 63 void RecordCryptohomeStatus(bool cryptohome_outcome, | |
| 64 cryptohome::MountError cryptohome_code); | |
| 65 | |
| 66 // Blow away locally stored cryptohome login status. | |
| 67 // Must be called from the UI thread. | |
| 68 void ResetCryptohomeStatus(); | |
| 69 | |
| 70 virtual bool online_complete(); | |
| 71 virtual const LoginFailure& online_outcome(); | |
| 72 virtual bool is_first_time_user(); | |
| 73 virtual GaiaAuthFetcher::HostedAccountsSetting hosted_policy(); | |
| 74 | |
| 75 virtual bool cryptohome_complete(); | |
| 76 virtual bool cryptohome_outcome(); | |
| 77 virtual cryptohome::MountError cryptohome_code(); | |
| 78 | |
| 79 virtual bool username_hash_obtained(); | |
| 80 virtual bool username_hash_valid(); | |
| 81 | |
| 82 // Saved so we can retry client login, and also so we know for whom login | |
| 83 // has succeeded, in the event of successful completion. | |
| 84 UserContext user_context; | |
| 85 | |
| 86 // These fields are saved so we can retry client login. | |
| 87 const std::string login_token; | |
| 88 const std::string login_captcha; | |
| 89 | |
| 90 // The type of the user attempting to log in. | |
| 91 const User::UserType user_type; | |
| 92 | |
| 93 const bool unlock; // True if authenticating to unlock the computer. | |
| 94 | |
| 95 protected: | |
| 96 // Status of our online login attempt. | |
| 97 bool online_complete_; | |
| 98 LoginFailure online_outcome_; | |
| 99 | |
| 100 // Whether or not we're accepting HOSTED accounts during the current | |
| 101 // online auth attempt. | |
| 102 GaiaAuthFetcher::HostedAccountsSetting hosted_policy_; | |
| 103 bool is_first_time_user_; | |
| 104 | |
| 105 // Status of our cryptohome op attempt. Can only have one in flight at a time. | |
| 106 bool cryptohome_complete_; | |
| 107 bool cryptohome_outcome_; | |
| 108 cryptohome::MountError cryptohome_code_; | |
| 109 | |
| 110 private: | |
| 111 // Status of the crypthome GetSanitizedUsername() async call. | |
| 112 // This gets initialized as being completed and those callers | |
| 113 // that would explicitly request username hash would have to reset this. | |
| 114 bool username_hash_obtained_; | |
| 115 | |
| 116 // After the username hash request is completed, this marks whether | |
| 117 // the request was successful. | |
| 118 bool username_hash_valid_; | |
| 119 | |
| 120 DISALLOW_COPY_AND_ASSIGN(AuthAttemptState); | |
| 121 }; | |
| 122 | |
| 123 } // namespace chromeos | |
| 124 | |
| 125 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_ATTEMPT_STATE_H_ | |
| OLD | NEW |