| 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_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 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 namespace user_manager { | 32 namespace user_manager { |
| 33 class User; | 33 class User; |
| 34 } | 34 } |
| 35 | 35 |
| 36 namespace user_prefs { | 36 namespace user_prefs { |
| 37 class PrefRegistrySyncable; | 37 class PrefRegistrySyncable; |
| 38 } | 38 } |
| 39 | 39 |
| 40 namespace proximity_auth { | 40 namespace proximity_auth { |
| 41 class ProximityAuthBleSystem; | 41 class ProximityAuthBleSystem; |
| 42 class ProximityAuthSystem; |
| 43 class RemoteDevice; |
| 42 } | 44 } |
| 43 | 45 |
| 44 class EasyUnlockAppManager; | 46 class EasyUnlockAppManager; |
| 45 class EasyUnlockServiceObserver; | 47 class EasyUnlockServiceObserver; |
| 46 class Profile; | 48 class Profile; |
| 47 class PrefRegistrySimple; | 49 class PrefRegistrySimple; |
| 48 | 50 |
| 49 class EasyUnlockService : public KeyedService { | 51 class EasyUnlockService : public KeyedService { |
| 50 public: | 52 public: |
| 51 enum TurnOffFlowStatus { | 53 enum TurnOffFlowStatus { |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 // Service type specific tests for whether the service is allowed. Returns | 235 // Service type specific tests for whether the service is allowed. Returns |
| 234 // false if service is not allowed. If true is returned, the service may still | 236 // false if service is not allowed. If true is returned, the service may still |
| 235 // not be allowed if common tests fail (e.g. if Bluetooth is not available). | 237 // not be allowed if common tests fail (e.g. if Bluetooth is not available). |
| 236 virtual bool IsAllowedInternal() const = 0; | 238 virtual bool IsAllowedInternal() const = 0; |
| 237 | 239 |
| 238 // Called while processing a user gesture to unlock the screen using Easy | 240 // Called while processing a user gesture to unlock the screen using Easy |
| 239 // Unlock, just before the screen is unlocked. | 241 // Unlock, just before the screen is unlocked. |
| 240 virtual void OnWillFinalizeUnlock(bool success) = 0; | 242 virtual void OnWillFinalizeUnlock(bool success) = 0; |
| 241 | 243 |
| 242 // Called when the local device resumes after a suspend. | 244 // Called when the local device resumes after a suspend. |
| 243 virtual void OnSuspendDone() = 0; | 245 virtual void OnSuspendDoneInternal() = 0; |
| 244 | 246 |
| 245 // KeyedService override: | 247 // KeyedService override: |
| 246 void Shutdown() override; | 248 void Shutdown() override; |
| 247 | 249 |
| 248 // Exposes the profile to which the service is attached to subclasses. | 250 // Exposes the profile to which the service is attached to subclasses. |
| 249 const Profile* profile() const { return profile_; } | 251 const Profile* profile() const { return profile_; } |
| 250 Profile* profile() { return profile_; } | 252 Profile* profile() { return profile_; } |
| 251 | 253 |
| 252 // Opens an Easy Unlock Setup app window. | 254 // Opens an Easy Unlock Setup app window. |
| 253 void OpenSetupApp(); | 255 void OpenSetupApp(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 // Saves hardlock state for the given user. Update UI if the currently | 288 // Saves hardlock state for the given user. Update UI if the currently |
| 287 // associated user is the same. | 289 // associated user is the same. |
| 288 void SetHardlockStateForUser( | 290 void SetHardlockStateForUser( |
| 289 const std::string& user_id, | 291 const std::string& user_id, |
| 290 EasyUnlockScreenlockStateHandler::HardlockState state); | 292 EasyUnlockScreenlockStateHandler::HardlockState state); |
| 291 | 293 |
| 292 // Returns the authentication event for a recent password sign-in or unlock, | 294 // Returns the authentication event for a recent password sign-in or unlock, |
| 293 // according to the current state of the service. | 295 // according to the current state of the service. |
| 294 EasyUnlockAuthEvent GetPasswordAuthEvent() const; | 296 EasyUnlockAuthEvent GetPasswordAuthEvent() const; |
| 295 | 297 |
| 298 // Called by subclasses when the remote device allowed to unlock the screen |
| 299 // changes. If |remote_device| is not null, then |proximity_auth_system_| will |
| 300 // be recreated with the new remote device. Otherwise, |
| 301 // |proximity_auth_system_| will be destroyed if no |remote_device| is set. |
| 302 void OnRemoteDeviceChanged(const proximity_auth::RemoteDevice* remote_device); |
| 303 |
| 296 private: | 304 private: |
| 297 // A class to detect whether a bluetooth adapter is present. | 305 // A class to detect whether a bluetooth adapter is present. |
| 298 class BluetoothDetector; | 306 class BluetoothDetector; |
| 299 | 307 |
| 300 // Initializes the service after EasyUnlockAppManager is ready. | 308 // Initializes the service after EasyUnlockAppManager is ready. |
| 301 void InitializeOnAppManagerReady(); | 309 void InitializeOnAppManagerReady(); |
| 302 | 310 |
| 303 // Gets |screenlock_state_handler_|. Returns NULL if Easy Unlock is not | 311 // Gets |screenlock_state_handler_|. Returns NULL if Easy Unlock is not |
| 304 // allowed. Otherwise, if |screenlock_state_handler_| is not set, an instance | 312 // allowed. Otherwise, if |screenlock_state_handler_| is not set, an instance |
| 305 // is created. Do not cache the returned value, as it may go away if Easy | 313 // is created. Do not cache the returned value, as it may go away if Easy |
| 306 // Unlock gets disabled. | 314 // Unlock gets disabled. |
| 307 EasyUnlockScreenlockStateHandler* GetScreenlockStateHandler(); | 315 EasyUnlockScreenlockStateHandler* GetScreenlockStateHandler(); |
| 308 | 316 |
| 309 // Callback when Bluetooth adapter present state changes. | 317 // Callback when Bluetooth adapter present state changes. |
| 310 void OnBluetoothAdapterPresentChanged(); | 318 void OnBluetoothAdapterPresentChanged(); |
| 311 | 319 |
| 312 #if defined(OS_CHROMEOS) | 320 #if defined(OS_CHROMEOS) |
| 313 // Callback for get key operation from CheckCryptohomeKeysAndMaybeHardlock. | 321 // Callback for get key operation from CheckCryptohomeKeysAndMaybeHardlock. |
| 314 void OnCryptohomeKeysFetchedForChecking( | 322 void OnCryptohomeKeysFetchedForChecking( |
| 315 const std::string& user_id, | 323 const std::string& user_id, |
| 316 const std::set<std::string> paired_devices, | 324 const std::set<std::string> paired_devices, |
| 317 bool success, | 325 bool success, |
| 318 const chromeos::EasyUnlockDeviceKeyDataList& key_data_list); | 326 const chromeos::EasyUnlockDeviceKeyDataList& key_data_list); |
| 319 #endif | 327 #endif |
| 320 | 328 |
| 321 // Updates the service to state for handling system suspend. | 329 // Updates the service to state for handling system suspend. |
| 322 void PrepareForSuspend(); | 330 void PrepareForSuspend(); |
| 323 | 331 |
| 332 // Called when the system resumes from a suspended state. |
| 333 void OnSuspendDone(); |
| 334 |
| 324 void EnsureTpmKeyPresentIfNeeded(); | 335 void EnsureTpmKeyPresentIfNeeded(); |
| 325 | 336 |
| 326 Profile* const profile_; | 337 Profile* const profile_; |
| 327 | 338 |
| 328 ChromeProximityAuthClient proximity_auth_client_; | 339 ChromeProximityAuthClient proximity_auth_client_; |
| 329 | 340 |
| 330 scoped_ptr<EasyUnlockAppManager> app_manager_; | 341 scoped_ptr<EasyUnlockAppManager> app_manager_; |
| 331 | 342 |
| 332 // Created lazily in |GetScreenlockStateHandler|. | 343 // Created lazily in |GetScreenlockStateHandler|. |
| 333 scoped_ptr<EasyUnlockScreenlockStateHandler> screenlock_state_handler_; | 344 scoped_ptr<EasyUnlockScreenlockStateHandler> screenlock_state_handler_; |
| 334 | 345 |
| 335 // The handler for the current auth attempt. Set iff an auth attempt is in | 346 // The handler for the current auth attempt. Set iff an auth attempt is in |
| 336 // progress. | 347 // progress. |
| 337 scoped_ptr<EasyUnlockAuthAttempt> auth_attempt_; | 348 scoped_ptr<EasyUnlockAuthAttempt> auth_attempt_; |
| 338 | 349 |
| 350 // Detects when the system Bluetooth adapter status changes. |
| 339 scoped_ptr<BluetoothDetector> bluetooth_detector_; | 351 scoped_ptr<BluetoothDetector> bluetooth_detector_; |
| 340 | 352 |
| 341 // The proximity auth over Bluetooth Low Energy system. This is main entry | 353 // Handles connecting, authenticating, and updating the UI on the lock/sign-in |
| 342 // point to bootstap Smart Lock to discover phones over Bluetooth Low | 354 // screen. After a |RemoteDevice| instance is provided, this object will |
| 343 // Energy. | 355 // handle the rest. |
| 344 scoped_ptr<proximity_auth::ProximityAuthBleSystem> proximity_auth_ble_system_; | 356 // TODO(tengs): This object is intended as a replacement of the background |
| 357 // page of the easy_unlock Chrome app. We are in the process of removing the |
| 358 // app in favor of |proximity_auth_system_|. |
| 359 scoped_ptr<proximity_auth::ProximityAuthSystem> proximity_auth_system_; |
| 345 | 360 |
| 346 #if defined(OS_CHROMEOS) | 361 #if defined(OS_CHROMEOS) |
| 347 // Monitors suspend and wake state of ChromeOS. | 362 // Monitors suspend and wake state of ChromeOS. |
| 348 class PowerMonitor; | 363 class PowerMonitor; |
| 349 scoped_ptr<PowerMonitor> power_monitor_; | 364 scoped_ptr<PowerMonitor> power_monitor_; |
| 350 #endif | 365 #endif |
| 351 | 366 |
| 352 // Whether the service has been shut down. | 367 // Whether the service has been shut down. |
| 353 bool shut_down_; | 368 bool shut_down_; |
| 354 | 369 |
| 355 bool tpm_key_checked_; | 370 bool tpm_key_checked_; |
| 356 | 371 |
| 357 base::ObserverList<EasyUnlockServiceObserver> observers_; | 372 base::ObserverList<EasyUnlockServiceObserver> observers_; |
| 358 | 373 |
| 359 base::WeakPtrFactory<EasyUnlockService> weak_ptr_factory_; | 374 base::WeakPtrFactory<EasyUnlockService> weak_ptr_factory_; |
| 360 | 375 |
| 361 DISALLOW_COPY_AND_ASSIGN(EasyUnlockService); | 376 DISALLOW_COPY_AND_ASSIGN(EasyUnlockService); |
| 362 }; | 377 }; |
| 363 | 378 |
| 364 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_H_ | 379 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_H_ |
| OLD | NEW |