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