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 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_types.h" | 16 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_types.h" |
17 #include "chrome/browser/signin/easy_unlock_service.h" | 17 #include "chrome/browser/signin/easy_unlock_service.h" |
18 #include "chromeos/login/login_state.h" | 18 #include "chromeos/login/login_state.h" |
19 #include "components/proximity_auth/screenlock_bridge.h" | 19 #include "components/proximity_auth/screenlock_bridge.h" |
| 20 #include "components/user_manager/user_id.h" |
20 | 21 |
21 // EasyUnlockService instance that should be used for signin profile. | 22 // EasyUnlockService instance that should be used for signin profile. |
22 class EasyUnlockServiceSignin | 23 class EasyUnlockServiceSignin |
23 : public EasyUnlockService, | 24 : public EasyUnlockService, |
24 public proximity_auth::ScreenlockBridge::Observer, | 25 public proximity_auth::ScreenlockBridge::Observer, |
25 public chromeos::LoginState::Observer { | 26 public chromeos::LoginState::Observer { |
26 public: | 27 public: |
27 explicit EasyUnlockServiceSignin(Profile* profile); | 28 explicit EasyUnlockServiceSignin(Profile* profile); |
28 ~EasyUnlockServiceSignin() override; | 29 ~EasyUnlockServiceSignin() override; |
29 | 30 |
30 // Sets |user_id| as the current user of the service. Note this does | 31 // Sets |user_id| as the current user of the service. Note this does |
31 // not change the focused user on the login screen. | 32 // not change the focused user on the login screen. |
32 void SetCurrentUser(const std::string& user_id); | 33 void SetCurrentUser(const user_manager::UserID& user_id); |
33 | 34 |
34 private: | 35 private: |
35 // The load state of a user's cryptohome key data. | 36 // The load state of a user's cryptohome key data. |
36 enum UserDataState { | 37 enum UserDataState { |
37 // Initial state, the key data is empty and not being loaded. | 38 // Initial state, the key data is empty and not being loaded. |
38 USER_DATA_STATE_INITIAL, | 39 USER_DATA_STATE_INITIAL, |
39 // The key data is empty, but being loaded. | 40 // The key data is empty, but being loaded. |
40 USER_DATA_STATE_LOADING, | 41 USER_DATA_STATE_LOADING, |
41 // The key data has been loaded. | 42 // The key data has been loaded. |
42 USER_DATA_STATE_LOADED | 43 USER_DATA_STATE_LOADED |
(...skipping 13 matching lines...) Expand all Loading... |
56 // The list of remote device dictionaries understood by Easy unlock app. | 57 // The list of remote device dictionaries understood by Easy unlock app. |
57 // This will be returned by |GetRemoteDevices| method. | 58 // This will be returned by |GetRemoteDevices| method. |
58 base::ListValue remote_devices_value; | 59 base::ListValue remote_devices_value; |
59 | 60 |
60 private: | 61 private: |
61 DISALLOW_COPY_AND_ASSIGN(UserData); | 62 DISALLOW_COPY_AND_ASSIGN(UserData); |
62 }; | 63 }; |
63 | 64 |
64 // EasyUnlockService implementation: | 65 // EasyUnlockService implementation: |
65 EasyUnlockService::Type GetType() const override; | 66 EasyUnlockService::Type GetType() const override; |
66 std::string GetUserEmail() const override; | 67 user_manager::UserID GetUserID() const override; |
67 void LaunchSetup() override; | 68 void LaunchSetup() override; |
68 const base::DictionaryValue* GetPermitAccess() const override; | 69 const base::DictionaryValue* GetPermitAccess() const override; |
69 void SetPermitAccess(const base::DictionaryValue& permit) override; | 70 void SetPermitAccess(const base::DictionaryValue& permit) override; |
70 void ClearPermitAccess() override; | 71 void ClearPermitAccess() override; |
71 const base::ListValue* GetRemoteDevices() const override; | 72 const base::ListValue* GetRemoteDevices() const override; |
72 void SetRemoteDevices(const base::ListValue& devices) override; | 73 void SetRemoteDevices(const base::ListValue& devices) override; |
73 void RunTurnOffFlow() override; | 74 void RunTurnOffFlow() override; |
74 void ResetTurnOffFlow() override; | 75 void ResetTurnOffFlow() override; |
75 TurnOffFlowStatus GetTurnOffFlowStatus() const override; | 76 TurnOffFlowStatus GetTurnOffFlowStatus() const override; |
76 std::string GetChallenge() const override; | 77 std::string GetChallenge() const override; |
77 std::string GetWrappedSecret() const override; | 78 std::string GetWrappedSecret() const override; |
78 void RecordEasySignInOutcome(const std::string& user_id, | 79 void RecordEasySignInOutcome(const user_manager::UserID& user_id, |
79 bool success) const override; | 80 bool success) const override; |
80 void RecordPasswordLoginEvent(const std::string& user_id) const override; | 81 void RecordPasswordLoginEvent(const user_manager::UserID& user_id) const overr
ide; |
81 void StartAutoPairing(const AutoPairingResultCallback& callback) override; | 82 void StartAutoPairing(const AutoPairingResultCallback& callback) override; |
82 void SetAutoPairingResult(bool success, const std::string& error) override; | 83 void SetAutoPairingResult(bool success, const std::string& error) override; |
83 void InitializeInternal() override; | 84 void InitializeInternal() override; |
84 void ShutdownInternal() override; | 85 void ShutdownInternal() override; |
85 bool IsAllowedInternal() const override; | 86 bool IsAllowedInternal() const override; |
86 void OnWillFinalizeUnlock(bool success) override; | 87 void OnWillFinalizeUnlock(bool success) override; |
87 void OnSuspendDone() override; | 88 void OnSuspendDone() override; |
88 | 89 |
89 // proximity_auth::ScreenlockBridge::Observer implementation: | 90 // proximity_auth::ScreenlockBridge::Observer implementation: |
90 void OnScreenDidLock(proximity_auth::ScreenlockBridge::LockHandler::ScreenType | 91 void OnScreenDidLock(proximity_auth::ScreenlockBridge::LockHandler::ScreenType |
91 screen_type) override; | 92 screen_type) override; |
92 void OnScreenDidUnlock( | 93 void OnScreenDidUnlock( |
93 proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) | 94 proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) |
94 override; | 95 override; |
95 void OnFocusedUserChanged(const std::string& user_id) override; | 96 void OnFocusedUserChanged(const user_manager::UserID& user_id) override; |
96 | 97 |
97 // chromeos::LoginState::Observer implementation: | 98 // chromeos::LoginState::Observer implementation: |
98 void LoggedInStateChanged() override; | 99 void LoggedInStateChanged() override; |
99 | 100 |
100 // Loads the device data associated with the user's Easy unlock keys from | 101 // Loads the device data associated with the user's Easy unlock keys from |
101 // crypthome. | 102 // crypthome. |
102 void LoadCurrentUserDataIfNeeded(); | 103 void LoadCurrentUserDataIfNeeded(); |
103 | 104 |
104 // Callback invoked when the user's device data is loaded from cryptohome. | 105 // Callback invoked when the user's device data is loaded from cryptohome. |
105 void OnUserDataLoaded( | 106 void OnUserDataLoaded( |
106 const std::string& user_id, | 107 const user_manager::UserID& user_id, |
107 bool success, | 108 bool success, |
108 const chromeos::EasyUnlockDeviceKeyDataList& data); | 109 const chromeos::EasyUnlockDeviceKeyDataList& data); |
109 | 110 |
110 // If the device data has been loaded for the current user, returns it. | 111 // If the device data has been loaded for the current user, returns it. |
111 // Otherwise, returns NULL. | 112 // Otherwise, returns NULL. |
112 const UserData* FindLoadedDataForCurrentUser() const; | 113 const UserData* FindLoadedDataForCurrentUser() const; |
113 | 114 |
114 // User id of the user currently associated with the service. | 115 // User id of the user currently associated with the service. |
115 std::string user_id_; | 116 user_manager::UserID user_id_; |
116 | 117 |
117 // Maps user ids to their fetched cryptohome key data. | 118 // Maps user ids to their fetched cryptohome key data. |
118 std::map<std::string, UserData*> user_data_; | 119 std::map<user_manager::UserID, UserData*> user_data_; |
119 | 120 |
120 // Whether failed attempts to load user data should be retried. | 121 // Whether failed attempts to load user data should be retried. |
121 // This is to handle case where cryptohome daemon is not started in time the | 122 // This is to handle case where cryptohome daemon is not started in time the |
122 // service attempts to load some data. Retries will be allowed only until the | 123 // service attempts to load some data. Retries will be allowed only until the |
123 // first data load finishes (even if it fails). | 124 // first data load finishes (even if it fails). |
124 bool allow_cryptohome_backoff_; | 125 bool allow_cryptohome_backoff_; |
125 | 126 |
126 // Whether the service has been successfully initialized, and has not been | 127 // Whether the service has been successfully initialized, and has not been |
127 // shut down. | 128 // shut down. |
128 bool service_active_; | 129 bool service_active_; |
129 | 130 |
130 // The timestamp for the most recent time when a user pod was focused. | 131 // The timestamp for the most recent time when a user pod was focused. |
131 base::TimeTicks user_pod_last_focused_timestamp_; | 132 base::TimeTicks user_pod_last_focused_timestamp_; |
132 | 133 |
133 base::WeakPtrFactory<EasyUnlockServiceSignin> weak_ptr_factory_; | 134 base::WeakPtrFactory<EasyUnlockServiceSignin> weak_ptr_factory_; |
134 | 135 |
135 DISALLOW_COPY_AND_ASSIGN(EasyUnlockServiceSignin); | 136 DISALLOW_COPY_AND_ASSIGN(EasyUnlockServiceSignin); |
136 }; | 137 }; |
137 | 138 |
138 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_SIGNIN_CHROMEOS_H_ | 139 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_SIGNIN_CHROMEOS_H_ |
OLD | NEW |