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" |
11 #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" |
| 15 #include "components/proximity_auth/screenlock_bridge.h" |
12 | 16 |
13 namespace proximity_auth { | 17 namespace proximity_auth { |
14 | 18 |
| 19 class ProximityAuthClient; |
| 20 class RemoteDeviceLifeCycle; |
| 21 class UnlockManager; |
| 22 |
15 // This is the main entry point to start Proximity Auth, the underlying system | 23 // This is the main entry point to start Proximity Auth, the underlying system |
16 // for the Easy Unlock and Easy Sign-in features. Given a list of registered | 24 // for the Smart Lock feature. Given a registered remote device (i.e. a phone), |
17 // remote devices (i.e. phones), this object will handle the connection, | 25 // this object will handle the connection, authentication, and protocol for the |
18 // authentication, and protocol for all the devices. | 26 // device. |
19 class ProximityAuthSystem { | 27 class ProximityAuthSystem : public RemoteDeviceLifeCycle::Observer, |
| 28 public ScreenlockBridge::Observer { |
20 public: | 29 public: |
21 ProximityAuthSystem(const std::vector<RemoteDevice>& remote_devices); | 30 ProximityAuthSystem(RemoteDevice remote_device, |
22 virtual ~ProximityAuthSystem(); | 31 ProximityAuthClient* proximity_auth_client); |
| 32 ~ProximityAuthSystem() override; |
23 | 33 |
24 const std::vector<RemoteDevice>& GetRemoteDevices(); | 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(); |
25 | 45 |
26 private: | 46 private: |
27 std::vector<RemoteDevice> remote_devices_; | 47 // RemoteDeviceLifeCycle::Observer: |
| 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_; |
28 | 79 |
29 DISALLOW_COPY_AND_ASSIGN(ProximityAuthSystem); | 80 DISALLOW_COPY_AND_ASSIGN(ProximityAuthSystem); |
30 }; | 81 }; |
31 | 82 |
32 } // namespace proximity_auth | 83 } // namespace proximity_auth |
33 | 84 |
34 #endif // COMPONENTS_PROXIMITY_AUTH_PROXIMITY_AUTH_SYSTEM_H | 85 #endif // COMPONENTS_PROXIMITY_AUTH_PROXIMITY_AUTH_SYSTEM_H |
OLD | NEW |