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