Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: chrome/browser/signin/easy_unlock_service.h

Issue 1165323004: We should use UserID object to identify users instead of username. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_H_ 5 #ifndef CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_H_
6 #define CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_H_ 6 #define CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
11 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/observer_list.h" 15 #include "base/observer_list.h"
16 #include "chrome/browser/signin/easy_unlock_auth_attempt.h" 16 #include "chrome/browser/signin/easy_unlock_auth_attempt.h"
17 #include "chrome/browser/signin/easy_unlock_metrics.h" 17 #include "chrome/browser/signin/easy_unlock_metrics.h"
18 #include "chrome/browser/signin/easy_unlock_screenlock_state_handler.h" 18 #include "chrome/browser/signin/easy_unlock_screenlock_state_handler.h"
19 #include "components/keyed_service/core/keyed_service.h" 19 #include "components/keyed_service/core/keyed_service.h"
20 #include "components/proximity_auth/screenlock_state.h" 20 #include "components/proximity_auth/screenlock_state.h"
21 #include "components/user_manager/user_id.h"
21 22
22 #if defined(OS_CHROMEOS) 23 #if defined(OS_CHROMEOS)
23 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_types.h" 24 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_types.h"
24 #endif 25 #endif
25 26
26 namespace base { 27 namespace base {
27 class DictionaryValue; 28 class DictionaryValue;
28 class ListValue; 29 class ListValue;
29 } 30 }
30 31
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 // logged in and his profile is initialized. 76 // logged in and his profile is initialized.
76 static EasyUnlockService* GetForUser(const user_manager::User& user); 77 static EasyUnlockService* GetForUser(const user_manager::User& user);
77 78
78 // Registers Easy Unlock profile preferences. 79 // Registers Easy Unlock profile preferences.
79 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 80 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
80 81
81 // Registers Easy Unlock local state entries. 82 // Registers Easy Unlock local state entries.
82 static void RegisterPrefs(PrefRegistrySimple* registry); 83 static void RegisterPrefs(PrefRegistrySimple* registry);
83 84
84 // Removes the hardlock state for the given user. 85 // Removes the hardlock state for the given user.
85 static void ResetLocalStateForUser(const std::string& user_id); 86 static void ResetLocalStateForUser(const user_manager::UserID& user_id);
86 87
87 // Returns the user's preferences. 88 // Returns the user's preferences.
88 static UserSettings GetUserSettings(const std::string& user_id); 89 static UserSettings GetUserSettings(const user_manager::UserID& user_id);
89 90
90 // Returns the identifier for the device. 91 // Returns the identifier for the device.
91 static std::string GetDeviceId(); 92 static std::string GetDeviceId();
92 93
93 // Returns true if Easy sign-in is enabled. 94 // Returns true if Easy sign-in is enabled.
94 static bool IsSignInEnabled(); 95 static bool IsSignInEnabled();
95 96
96 // Returns the EasyUnlockService type. 97 // Returns the EasyUnlockService type.
97 virtual Type GetType() const = 0; 98 virtual Type GetType() const = 0;
98 99
99 // Returns the user currently associated with the service. 100 // Returns the user currently associated with the service.
100 virtual std::string GetUserEmail() const = 0; 101 virtual user_manager::UserID GetUserID() const = 0;
101 102
102 // Launches Easy Unlock setup app. 103 // Launches Easy Unlock setup app.
103 virtual void LaunchSetup() = 0; 104 virtual void LaunchSetup() = 0;
104 105
105 // Gets/Sets/Clears the permit access for the local device. 106 // Gets/Sets/Clears the permit access for the local device.
106 virtual const base::DictionaryValue* GetPermitAccess() const = 0; 107 virtual const base::DictionaryValue* GetPermitAccess() const = 0;
107 virtual void SetPermitAccess(const base::DictionaryValue& permit) = 0; 108 virtual void SetPermitAccess(const base::DictionaryValue& permit) = 0;
108 virtual void ClearPermitAccess() = 0; 109 virtual void ClearPermitAccess() = 0;
109 110
110 // Gets/Sets the remote devices list. 111 // Gets/Sets the remote devices list.
(...skipping 13 matching lines...) Expand all
124 // service. 125 // service.
125 virtual std::string GetChallenge() const = 0; 126 virtual std::string GetChallenge() const = 0;
126 127
127 // Retrieved wrapped secret that should be used to unlock cryptohome for the 128 // Retrieved wrapped secret that should be used to unlock cryptohome for the
128 // user currently associated with the service. If the service does not support 129 // user currently associated with the service. If the service does not support
129 // signin (i.e. service for a regular profile) or there is no secret available 130 // signin (i.e. service for a regular profile) or there is no secret available
130 // for the user, returns an empty string. 131 // for the user, returns an empty string.
131 virtual std::string GetWrappedSecret() const = 0; 132 virtual std::string GetWrappedSecret() const = 0;
132 133
133 // Records metrics for Easy sign-in outcome for the given user. 134 // Records metrics for Easy sign-in outcome for the given user.
134 virtual void RecordEasySignInOutcome(const std::string& user_id, 135 virtual void RecordEasySignInOutcome(const user_manager::UserID& user_id,
135 bool success) const = 0; 136 bool success) const = 0;
136 137
137 // Records metrics for password based flow for the given user. 138 // Records metrics for password based flow for the given user.
138 virtual void RecordPasswordLoginEvent(const std::string& user_id) const = 0; 139 virtual void RecordPasswordLoginEvent(const user_manager::UserID& user_id) con st = 0;
139 140
140 // Starts auto pairing. 141 // Starts auto pairing.
141 typedef base::Callback<void(bool success, const std::string& error)> 142 typedef base::Callback<void(bool success, const std::string& error)>
142 AutoPairingResultCallback; 143 AutoPairingResultCallback;
143 virtual void StartAutoPairing(const AutoPairingResultCallback& callback) = 0; 144 virtual void StartAutoPairing(const AutoPairingResultCallback& callback) = 0;
144 145
145 // Sets auto pairing result. 146 // Sets auto pairing result.
146 virtual void SetAutoPairingResult(bool success, const std::string& error) = 0; 147 virtual void SetAutoPairingResult(bool success, const std::string& error) = 0;
147 148
148 // Sets the service up and schedules service initialization. 149 // Sets the service up and schedules service initialization.
(...skipping 26 matching lines...) Expand all
175 // Updates the user pod on the signin/lock screen for the user associated with 176 // Updates the user pod on the signin/lock screen for the user associated with
176 // the service to reflect the provided screenlock state. 177 // the service to reflect the provided screenlock state.
177 bool UpdateScreenlockState(proximity_auth::ScreenlockState state); 178 bool UpdateScreenlockState(proximity_auth::ScreenlockState state);
178 179
179 // Returns the screenlock state if it is available. Otherwise STATE_INACTIVE 180 // Returns the screenlock state if it is available. Otherwise STATE_INACTIVE
180 // is returned. 181 // is returned.
181 proximity_auth::ScreenlockState GetScreenlockState(); 182 proximity_auth::ScreenlockState GetScreenlockState();
182 183
183 // Starts an auth attempt for the user associated with the service. The 184 // Starts an auth attempt for the user associated with the service. The
184 // attempt type (unlock vs. signin) will depend on the service type. 185 // attempt type (unlock vs. signin) will depend on the service type.
185 void AttemptAuth(const std::string& user_id); 186 void AttemptAuth(const user_manager::UserID& user_id);
186 187
187 // Similar to above but a callback is invoked after the auth attempt is 188 // Similar to above but a callback is invoked after the auth attempt is
188 // finalized instead of default unlock/sign-in. 189 // finalized instead of default unlock/sign-in.
189 typedef EasyUnlockAuthAttempt::FinalizedCallback AttemptAuthCallback; 190 typedef EasyUnlockAuthAttempt::FinalizedCallback AttemptAuthCallback;
190 void AttemptAuth(const std::string& user_id, 191 void AttemptAuth(const user_manager::UserID& user_id,
191 const AttemptAuthCallback& callback); 192 const AttemptAuthCallback& callback);
192 193
193 // Finalizes the previously started auth attempt for easy unlock. If called on 194 // Finalizes the previously started auth attempt for easy unlock. If called on
194 // signin profile service, it will cancel the current auth attempt if one 195 // signin profile service, it will cancel the current auth attempt if one
195 // exists. 196 // exists.
196 void FinalizeUnlock(bool success); 197 void FinalizeUnlock(bool success);
197 198
198 // Finalizes previously started auth attempt for easy signin. If called on 199 // Finalizes previously started auth attempt for easy signin. If called on
199 // regular profile service, it will cancel the current auth attempt if one 200 // regular profile service, it will cancel the current auth attempt if one
200 // exists. 201 // exists.
201 void FinalizeSignin(const std::string& secret); 202 void FinalizeSignin(const std::string& secret);
202 203
203 // Handles Easy Unlock auth failure for the user. 204 // Handles Easy Unlock auth failure for the user.
204 void HandleAuthFailure(const std::string& user_id); 205 void HandleAuthFailure(const user_manager::UserID& user_id);
205 206
206 // Checks the consistency between pairing data and cryptohome keys. Set 207 // Checks the consistency between pairing data and cryptohome keys. Set
207 // hardlock state if the two do not match. 208 // hardlock state if the two do not match.
208 void CheckCryptohomeKeysAndMaybeHardlock(); 209 void CheckCryptohomeKeysAndMaybeHardlock();
209 210
210 // Marks the Easy Unlock screen lock state as the one associated with the 211 // Marks the Easy Unlock screen lock state as the one associated with the
211 // trial run initiated by Easy Unlock app. 212 // trial run initiated by Easy Unlock app.
212 void SetTrialRun(); 213 void SetTrialRun();
213 214
214 // Records that the user clicked on the lock icon during the trial run 215 // Records that the user clicked on the lock icon during the trial run
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 void SetScreenlockHardlockedState( 278 void SetScreenlockHardlockedState(
278 EasyUnlockScreenlockStateHandler::HardlockState state); 279 EasyUnlockScreenlockStateHandler::HardlockState state);
279 280
280 const EasyUnlockScreenlockStateHandler* screenlock_state_handler() const { 281 const EasyUnlockScreenlockStateHandler* screenlock_state_handler() const {
281 return screenlock_state_handler_.get(); 282 return screenlock_state_handler_.get();
282 } 283 }
283 284
284 // Saves hardlock state for the given user. Update UI if the currently 285 // Saves hardlock state for the given user. Update UI if the currently
285 // associated user is the same. 286 // associated user is the same.
286 void SetHardlockStateForUser( 287 void SetHardlockStateForUser(
287 const std::string& user_id, 288 const user_manager::UserID& user_id,
288 EasyUnlockScreenlockStateHandler::HardlockState state); 289 EasyUnlockScreenlockStateHandler::HardlockState state);
289 290
290 // Returns the authentication event for a recent password sign-in or unlock, 291 // Returns the authentication event for a recent password sign-in or unlock,
291 // according to the current state of the service. 292 // according to the current state of the service.
292 EasyUnlockAuthEvent GetPasswordAuthEvent() const; 293 EasyUnlockAuthEvent GetPasswordAuthEvent() const;
293 294
294 private: 295 private:
295 // A class to detect whether a bluetooth adapter is present. 296 // A class to detect whether a bluetooth adapter is present.
296 class BluetoothDetector; 297 class BluetoothDetector;
297 298
298 // Initializes the service after EasyUnlockAppManager is ready. 299 // Initializes the service after EasyUnlockAppManager is ready.
299 void InitializeOnAppManagerReady(); 300 void InitializeOnAppManagerReady();
300 301
301 // Gets |screenlock_state_handler_|. Returns NULL if Easy Unlock is not 302 // Gets |screenlock_state_handler_|. Returns NULL if Easy Unlock is not
302 // allowed. Otherwise, if |screenlock_state_handler_| is not set, an instance 303 // allowed. Otherwise, if |screenlock_state_handler_| is not set, an instance
303 // is created. Do not cache the returned value, as it may go away if Easy 304 // is created. Do not cache the returned value, as it may go away if Easy
304 // Unlock gets disabled. 305 // Unlock gets disabled.
305 EasyUnlockScreenlockStateHandler* GetScreenlockStateHandler(); 306 EasyUnlockScreenlockStateHandler* GetScreenlockStateHandler();
306 307
307 // Callback when Bluetooth adapter present state changes. 308 // Callback when Bluetooth adapter present state changes.
308 void OnBluetoothAdapterPresentChanged(); 309 void OnBluetoothAdapterPresentChanged();
309 310
310 #if defined(OS_CHROMEOS) 311 #if defined(OS_CHROMEOS)
311 // Callback for get key operation from CheckCryptohomeKeysAndMaybeHardlock. 312 // Callback for get key operation from CheckCryptohomeKeysAndMaybeHardlock.
312 void OnCryptohomeKeysFetchedForChecking( 313 void OnCryptohomeKeysFetchedForChecking(
313 const std::string& user_id, 314 const user_manager::UserID& user_id,
314 const std::set<std::string> paired_devices, 315 const std::set<std::string> paired_devices,
315 bool success, 316 bool success,
316 const chromeos::EasyUnlockDeviceKeyDataList& key_data_list); 317 const chromeos::EasyUnlockDeviceKeyDataList& key_data_list);
317 #endif 318 #endif
318 319
319 // Updates the service to state for handling system suspend. 320 // Updates the service to state for handling system suspend.
320 void PrepareForSuspend(); 321 void PrepareForSuspend();
321 322
322 void EnsureTpmKeyPresentIfNeeded(); 323 void EnsureTpmKeyPresentIfNeeded();
323 324
(...skipping 27 matching lines...) Expand all
351 bool tpm_key_checked_; 352 bool tpm_key_checked_;
352 353
353 ObserverList<EasyUnlockServiceObserver> observers_; 354 ObserverList<EasyUnlockServiceObserver> observers_;
354 355
355 base::WeakPtrFactory<EasyUnlockService> weak_ptr_factory_; 356 base::WeakPtrFactory<EasyUnlockService> weak_ptr_factory_;
356 357
357 DISALLOW_COPY_AND_ASSIGN(EasyUnlockService); 358 DISALLOW_COPY_AND_ASSIGN(EasyUnlockService);
358 }; 359 };
359 360
360 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_H_ 361 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698