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