| 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 COMPONENTS_PROXIMITY_AUTH_PROXIMITY_AUTH_SYSTEM_H | 5 #ifndef COMPONENTS_PROXIMITY_AUTH_PROXIMITY_AUTH_SYSTEM_H |
| 6 #define COMPONENTS_PROXIMITY_AUTH_PROXIMITY_AUTH_SYSTEM_H | 6 #define COMPONENTS_PROXIMITY_AUTH_PROXIMITY_AUTH_SYSTEM_H |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "components/proximity_auth/remote_device.h" | 13 #include "components/proximity_auth/remote_device.h" |
| 14 #include "components/proximity_auth/remote_device_life_cycle.h" | 14 #include "components/proximity_auth/remote_device_life_cycle.h" |
| 15 #include "components/proximity_auth/screenlock_bridge.h" | 15 #include "components/proximity_auth/screenlock_bridge.h" |
| 16 | 16 |
| 17 class AccountId; |
| 18 |
| 17 namespace proximity_auth { | 19 namespace proximity_auth { |
| 18 | 20 |
| 19 class ProximityAuthClient; | 21 class ProximityAuthClient; |
| 20 class RemoteDeviceLifeCycle; | 22 class RemoteDeviceLifeCycle; |
| 21 class UnlockManager; | 23 class UnlockManager; |
| 22 | 24 |
| 23 // This is the main entry point to start Proximity Auth, the underlying system | 25 // This is the main entry point to start Proximity Auth, the underlying system |
| 24 // for the Smart Lock feature. Given a registered remote device (i.e. a phone), | 26 // for the Smart Lock feature. Given a registered remote device (i.e. a phone), |
| 25 // this object will handle the connection, authentication, and protocol for the | 27 // this object will handle the connection, authentication, and protocol for the |
| 26 // device. | 28 // device. |
| 27 class ProximityAuthSystem : public RemoteDeviceLifeCycle::Observer, | 29 class ProximityAuthSystem : public RemoteDeviceLifeCycle::Observer, |
| 28 public ScreenlockBridge::Observer { | 30 public ScreenlockBridge::Observer { |
| 29 public: | 31 public: |
| 30 enum ScreenlockType { SESSION_LOCK, SIGN_IN }; | 32 enum ScreenlockType { SESSION_LOCK, SIGN_IN }; |
| 31 | 33 |
| 32 ProximityAuthSystem(ScreenlockType screenlock_type, | 34 ProximityAuthSystem(ScreenlockType screenlock_type, |
| 33 RemoteDevice remote_device, | 35 RemoteDevice remote_device, |
| 34 ProximityAuthClient* proximity_auth_client); | 36 ProximityAuthClient* proximity_auth_client); |
| 35 ~ProximityAuthSystem() override; | 37 ~ProximityAuthSystem() override; |
| 36 | 38 |
| 37 // Starts the system to begin connecting and authenticating the remote device. | 39 // Starts the system to begin connecting and authenticating the remote device. |
| 38 void Start(); | 40 void Start(); |
| 39 | 41 |
| 40 // Called when the user clicks the user pod and attempts to unlock/sign-in. | 42 // Called when the user clicks the user pod and attempts to unlock/sign-in. |
| 41 void OnAuthAttempted(const std::string& user_id); | 43 void OnAuthAttempted(const AccountId& account_id); |
| 42 | 44 |
| 43 // Called when the system suspends. | 45 // Called when the system suspends. |
| 44 void OnSuspend(); | 46 void OnSuspend(); |
| 45 | 47 |
| 46 // Called when the system wakes up from a suspended state. | 48 // Called when the system wakes up from a suspended state. |
| 47 void OnSuspendDone(); | 49 void OnSuspendDone(); |
| 48 | 50 |
| 49 private: | 51 private: |
| 50 // RemoteDeviceLifeCycle::Observer: | 52 // RemoteDeviceLifeCycle::Observer: |
| 51 void OnLifeCycleStateChanged(RemoteDeviceLifeCycle::State old_state, | 53 void OnLifeCycleStateChanged(RemoteDeviceLifeCycle::State old_state, |
| 52 RemoteDeviceLifeCycle::State new_state) override; | 54 RemoteDeviceLifeCycle::State new_state) override; |
| 53 | 55 |
| 54 // ScreenlockBridge::Observer: | 56 // ScreenlockBridge::Observer: |
| 55 void OnScreenDidLock( | 57 void OnScreenDidLock( |
| 56 ScreenlockBridge::LockHandler::ScreenType screen_type) override; | 58 ScreenlockBridge::LockHandler::ScreenType screen_type) override; |
| 57 void OnScreenDidUnlock( | 59 void OnScreenDidUnlock( |
| 58 ScreenlockBridge::LockHandler::ScreenType screen_type) override; | 60 ScreenlockBridge::LockHandler::ScreenType screen_type) override; |
| 59 void OnFocusedUserChanged(const std::string& user_id) override; | 61 void OnFocusedUserChanged(const AccountId& account_id) override; |
| 60 | 62 |
| 61 // Resumes |remote_device_life_cycle_| after device wakes up and waits a | 63 // Resumes |remote_device_life_cycle_| after device wakes up and waits a |
| 62 // timeout. | 64 // timeout. |
| 63 void ResumeAfterWakeUpTimeout(); | 65 void ResumeAfterWakeUpTimeout(); |
| 64 | 66 |
| 65 // The remote device to connect to. | 67 // The remote device to connect to. |
| 66 RemoteDevice remote_device_; | 68 RemoteDevice remote_device_; |
| 67 | 69 |
| 68 // Delegate for Chrome dependent functionality. | 70 // Delegate for Chrome dependent functionality. |
| 69 ProximityAuthClient* proximity_auth_client_; | 71 ProximityAuthClient* proximity_auth_client_; |
| 70 | 72 |
| 71 // Responsible for the life cycle of connecting and authenticating to | 73 // Responsible for the life cycle of connecting and authenticating to |
| 72 // |remote_device_|. | 74 // |remote_device_|. |
| 73 scoped_ptr<RemoteDeviceLifeCycle> remote_device_life_cycle_; | 75 scoped_ptr<RemoteDeviceLifeCycle> remote_device_life_cycle_; |
| 74 | 76 |
| 75 // Handles the interaction with the lock screen UI. | 77 // Handles the interaction with the lock screen UI. |
| 76 scoped_ptr<UnlockManager> unlock_manager_; | 78 scoped_ptr<UnlockManager> unlock_manager_; |
| 77 | 79 |
| 78 // True if the system is suspended. | 80 // True if the system is suspended. |
| 79 bool suspended_; | 81 bool suspended_; |
| 80 | 82 |
| 81 base::WeakPtrFactory<ProximityAuthSystem> weak_ptr_factory_; | 83 base::WeakPtrFactory<ProximityAuthSystem> weak_ptr_factory_; |
| 82 | 84 |
| 83 DISALLOW_COPY_AND_ASSIGN(ProximityAuthSystem); | 85 DISALLOW_COPY_AND_ASSIGN(ProximityAuthSystem); |
| 84 }; | 86 }; |
| 85 | 87 |
| 86 } // namespace proximity_auth | 88 } // namespace proximity_auth |
| 87 | 89 |
| 88 #endif // COMPONENTS_PROXIMITY_AUTH_PROXIMITY_AUTH_SYSTEM_H | 90 #endif // COMPONENTS_PROXIMITY_AUTH_PROXIMITY_AUTH_SYSTEM_H |
| OLD | NEW |