| 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 CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_SIGNIN_CHROMEOS_H_ | 5 #ifndef CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_SIGNIN_CHROMEOS_H_ |
| 6 #define CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_SIGNIN_CHROMEOS_H_ | 6 #define CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_SIGNIN_CHROMEOS_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 // EasyUnlockService instance that should be used for signin profile. | 25 // EasyUnlockService instance that should be used for signin profile. |
| 26 class EasyUnlockServiceSignin | 26 class EasyUnlockServiceSignin |
| 27 : public EasyUnlockService, | 27 : public EasyUnlockService, |
| 28 public proximity_auth::ScreenlockBridge::Observer, | 28 public proximity_auth::ScreenlockBridge::Observer, |
| 29 public chromeos::LoginState::Observer { | 29 public chromeos::LoginState::Observer { |
| 30 public: | 30 public: |
| 31 explicit EasyUnlockServiceSignin(Profile* profile); | 31 explicit EasyUnlockServiceSignin(Profile* profile); |
| 32 ~EasyUnlockServiceSignin() override; | 32 ~EasyUnlockServiceSignin() override; |
| 33 | 33 |
| 34 // Sets |user_id| as the current user of the service. Note this does | 34 // Sets |account_id| as the current user of the service. Note this does |
| 35 // not change the focused user on the login screen. | 35 // not change the focused user on the login screen. |
| 36 void SetCurrentUser(const std::string& user_id); | 36 void SetCurrentUser(const AccountId& account_id); |
| 37 | 37 |
| 38 // Wraps the challenge for the remote device identified by |user_id| and the | 38 // Wraps the challenge for the remote device identified by |account_id| and |
| 39 // the |
| 39 // |device_public_key|. The |channel_binding_data| is signed by the TPM | 40 // |device_public_key|. The |channel_binding_data| is signed by the TPM |
| 40 // included in the wrapped challenge. | 41 // included in the wrapped challenge. |
| 41 // |callback| will be invoked when wrapping is complete. If the user data is | 42 // |callback| will be invoked when wrapping is complete. If the user data is |
| 42 // not loaded yet, then |callback| will be invoked with an empty string. | 43 // not loaded yet, then |callback| will be invoked with an empty string. |
| 43 void WrapChallengeForUserAndDevice( | 44 void WrapChallengeForUserAndDevice( |
| 44 const std::string& user_id, | 45 const AccountId& account_id, |
| 45 const std::string& device_public_key, | 46 const std::string& device_public_key, |
| 46 const std::string& channel_binding_data, | 47 const std::string& channel_binding_data, |
| 47 base::Callback<void(const std::string& wraped_challenge)> callback); | 48 base::Callback<void(const std::string& wraped_challenge)> callback); |
| 48 | 49 |
| 49 private: | 50 private: |
| 50 // The load state of a user's cryptohome key data. | 51 // The load state of a user's cryptohome key data. |
| 51 enum UserDataState { | 52 enum UserDataState { |
| 52 // Initial state, the key data is empty and not being loaded. | 53 // Initial state, the key data is empty and not being loaded. |
| 53 USER_DATA_STATE_INITIAL, | 54 USER_DATA_STATE_INITIAL, |
| 54 // The key data is empty, but being loaded. | 55 // The key data is empty, but being loaded. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 71 // The list of remote device dictionaries understood by Easy unlock app. | 72 // The list of remote device dictionaries understood by Easy unlock app. |
| 72 // This will be returned by |GetRemoteDevices| method. | 73 // This will be returned by |GetRemoteDevices| method. |
| 73 base::ListValue remote_devices_value; | 74 base::ListValue remote_devices_value; |
| 74 | 75 |
| 75 private: | 76 private: |
| 76 DISALLOW_COPY_AND_ASSIGN(UserData); | 77 DISALLOW_COPY_AND_ASSIGN(UserData); |
| 77 }; | 78 }; |
| 78 | 79 |
| 79 // EasyUnlockService implementation: | 80 // EasyUnlockService implementation: |
| 80 EasyUnlockService::Type GetType() const override; | 81 EasyUnlockService::Type GetType() const override; |
| 81 std::string GetUserEmail() const override; | 82 AccountId GetAccountId() const override; |
| 82 void LaunchSetup() override; | 83 void LaunchSetup() override; |
| 83 const base::DictionaryValue* GetPermitAccess() const override; | 84 const base::DictionaryValue* GetPermitAccess() const override; |
| 84 void SetPermitAccess(const base::DictionaryValue& permit) override; | 85 void SetPermitAccess(const base::DictionaryValue& permit) override; |
| 85 void ClearPermitAccess() override; | 86 void ClearPermitAccess() override; |
| 86 const base::ListValue* GetRemoteDevices() const override; | 87 const base::ListValue* GetRemoteDevices() const override; |
| 87 void SetRemoteDevices(const base::ListValue& devices) override; | 88 void SetRemoteDevices(const base::ListValue& devices) override; |
| 88 void SetRemoteBleDevices(const base::ListValue& devices) override; | 89 void SetRemoteBleDevices(const base::ListValue& devices) override; |
| 89 void RunTurnOffFlow() override; | 90 void RunTurnOffFlow() override; |
| 90 void ResetTurnOffFlow() override; | 91 void ResetTurnOffFlow() override; |
| 91 TurnOffFlowStatus GetTurnOffFlowStatus() const override; | 92 TurnOffFlowStatus GetTurnOffFlowStatus() const override; |
| 92 std::string GetChallenge() const override; | 93 std::string GetChallenge() const override; |
| 93 std::string GetWrappedSecret() const override; | 94 std::string GetWrappedSecret() const override; |
| 94 void RecordEasySignInOutcome(const std::string& user_id, | 95 void RecordEasySignInOutcome(const AccountId& account_id, |
| 95 bool success) const override; | 96 bool success) const override; |
| 96 void RecordPasswordLoginEvent(const std::string& user_id) const override; | 97 void RecordPasswordLoginEvent(const AccountId& account_id) const override; |
| 97 void StartAutoPairing(const AutoPairingResultCallback& callback) override; | 98 void StartAutoPairing(const AutoPairingResultCallback& callback) override; |
| 98 void SetAutoPairingResult(bool success, const std::string& error) override; | 99 void SetAutoPairingResult(bool success, const std::string& error) override; |
| 99 void InitializeInternal() override; | 100 void InitializeInternal() override; |
| 100 void ShutdownInternal() override; | 101 void ShutdownInternal() override; |
| 101 bool IsAllowedInternal() const override; | 102 bool IsAllowedInternal() const override; |
| 102 void OnWillFinalizeUnlock(bool success) override; | 103 void OnWillFinalizeUnlock(bool success) override; |
| 103 void OnSuspendDoneInternal() override; | 104 void OnSuspendDoneInternal() override; |
| 104 | 105 |
| 105 // proximity_auth::ScreenlockBridge::Observer implementation: | 106 // proximity_auth::ScreenlockBridge::Observer implementation: |
| 106 void OnScreenDidLock(proximity_auth::ScreenlockBridge::LockHandler::ScreenType | 107 void OnScreenDidLock(proximity_auth::ScreenlockBridge::LockHandler::ScreenType |
| 107 screen_type) override; | 108 screen_type) override; |
| 108 void OnScreenDidUnlock( | 109 void OnScreenDidUnlock( |
| 109 proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) | 110 proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) |
| 110 override; | 111 override; |
| 111 void OnFocusedUserChanged(const std::string& user_id) override; | 112 void OnFocusedUserChanged(const AccountId& account_id) override; |
| 112 | 113 |
| 113 // chromeos::LoginState::Observer implementation: | 114 // chromeos::LoginState::Observer implementation: |
| 114 void LoggedInStateChanged() override; | 115 void LoggedInStateChanged() override; |
| 115 | 116 |
| 116 // Loads the device data associated with the user's Easy unlock keys from | 117 // Loads the device data associated with the user's Easy unlock keys from |
| 117 // crypthome. | 118 // crypthome. |
| 118 void LoadCurrentUserDataIfNeeded(); | 119 void LoadCurrentUserDataIfNeeded(); |
| 119 | 120 |
| 120 // Callback invoked when the user's device data is loaded from cryptohome. | 121 // Callback invoked when the user's device data is loaded from cryptohome. |
| 121 void OnUserDataLoaded( | 122 void OnUserDataLoaded(const AccountId& account_id, |
| 122 const std::string& user_id, | 123 bool success, |
| 123 bool success, | 124 const chromeos::EasyUnlockDeviceKeyDataList& data); |
| 124 const chromeos::EasyUnlockDeviceKeyDataList& data); | |
| 125 | 125 |
| 126 // If the device data has been loaded for the current user, returns it. | 126 // If the device data has been loaded for the current user, returns it. |
| 127 // Otherwise, returns NULL. | 127 // Otherwise, returns NULL. |
| 128 const UserData* FindLoadedDataForCurrentUser() const; | 128 const UserData* FindLoadedDataForCurrentUser() const; |
| 129 | 129 |
| 130 // User id of the user currently associated with the service. | 130 // User id of the user currently associated with the service. |
| 131 std::string user_id_; | 131 AccountId account_id_; |
| 132 | 132 |
| 133 // Maps user ids to their fetched cryptohome key data. | 133 // Maps account ids to their fetched cryptohome key data. |
| 134 std::map<std::string, UserData*> user_data_; | 134 std::map<AccountId, UserData*> user_data_; |
| 135 | 135 |
| 136 // Whether failed attempts to load user data should be retried. | 136 // Whether failed attempts to load user data should be retried. |
| 137 // This is to handle case where cryptohome daemon is not started in time the | 137 // This is to handle case where cryptohome daemon is not started in time the |
| 138 // service attempts to load some data. Retries will be allowed only until the | 138 // service attempts to load some data. Retries will be allowed only until the |
| 139 // first data load finishes (even if it fails). | 139 // first data load finishes (even if it fails). |
| 140 bool allow_cryptohome_backoff_; | 140 bool allow_cryptohome_backoff_ = true; |
| 141 | 141 |
| 142 // Whether the service has been successfully initialized, and has not been | 142 // Whether the service has been successfully initialized, and has not been |
| 143 // shut down. | 143 // shut down. |
| 144 bool service_active_; | 144 bool service_active_ = false; |
| 145 | 145 |
| 146 // The timestamp for the most recent time when a user pod was focused. | 146 // The timestamp for the most recent time when a user pod was focused. |
| 147 base::TimeTicks user_pod_last_focused_timestamp_; | 147 base::TimeTicks user_pod_last_focused_timestamp_; |
| 148 | 148 |
| 149 // Handles wrapping the user's challenge with the TPM. | 149 // Handles wrapping the user's challenge with the TPM. |
| 150 scoped_ptr<chromeos::EasyUnlockChallengeWrapper> challenge_wrapper_; | 150 scoped_ptr<chromeos::EasyUnlockChallengeWrapper> challenge_wrapper_; |
| 151 | 151 |
| 152 base::WeakPtrFactory<EasyUnlockServiceSignin> weak_ptr_factory_; | 152 base::WeakPtrFactory<EasyUnlockServiceSignin> weak_ptr_factory_; |
| 153 | 153 |
| 154 DISALLOW_COPY_AND_ASSIGN(EasyUnlockServiceSignin); | 154 DISALLOW_COPY_AND_ASSIGN(EasyUnlockServiceSignin); |
| 155 }; | 155 }; |
| 156 | 156 |
| 157 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_SIGNIN_CHROMEOS_H_ | 157 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_SIGNIN_CHROMEOS_H_ |
| OLD | NEW |