OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_UNLOCK_MANAGER_IMPL_H | 5 #ifndef COMPONENTS_PROXIMITY_AUTH_UNLOCK_MANAGER_IMPL_H |
6 #define COMPONENTS_PROXIMITY_AUTH_UNLOCK_MANAGER_IMPL_H | 6 #define COMPONENTS_PROXIMITY_AUTH_UNLOCK_MANAGER_IMPL_H |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
12 #include "components/proximity_auth/messenger_observer.h" | 12 #include "components/proximity_auth/messenger_observer.h" |
13 #include "components/proximity_auth/proximity_auth_system.h" | 13 #include "components/proximity_auth/proximity_auth_system.h" |
14 #include "components/proximity_auth/proximity_monitor_observer.h" | 14 #include "components/proximity_auth/proximity_monitor_observer.h" |
15 #include "components/proximity_auth/remote_device_life_cycle.h" | 15 #include "components/proximity_auth/remote_device_life_cycle.h" |
16 #include "components/proximity_auth/remote_status_update.h" | 16 #include "components/proximity_auth/remote_status_update.h" |
17 #include "components/proximity_auth/screenlock_bridge.h" | 17 #include "components/proximity_auth/screenlock_bridge.h" |
18 #include "components/proximity_auth/screenlock_state.h" | 18 #include "components/proximity_auth/screenlock_state.h" |
19 #include "components/proximity_auth/unlock_manager.h" | 19 #include "components/proximity_auth/unlock_manager.h" |
20 #include "device/bluetooth/bluetooth_adapter.h" | 20 #include "device/bluetooth/bluetooth_adapter.h" |
21 | 21 |
22 #if defined(OS_CHROMEOS) | 22 #if defined(OS_CHROMEOS) |
23 #include "chromeos/dbus/power_manager_client.h" | 23 #include "chromeos/dbus/power_manager_client.h" |
24 #endif | 24 #endif |
25 | 25 |
26 namespace proximity_auth { | 26 namespace proximity_auth { |
27 | 27 |
28 class Messenger; | 28 class Messenger; |
29 class ProximityAuthClient; | 29 class ProximityAuthClient; |
| 30 class ProximityAuthPrefManager; |
30 class ProximityMonitor; | 31 class ProximityMonitor; |
31 | 32 |
32 // The unlock manager is responsible for controlling the lock screen UI based on | 33 // The unlock manager is responsible for controlling the lock screen UI based on |
33 // the authentication status of the registered remote devices. | 34 // the authentication status of the registered remote devices. |
34 class UnlockManagerImpl : public UnlockManager, | 35 class UnlockManagerImpl : public UnlockManager, |
35 public MessengerObserver, | 36 public MessengerObserver, |
36 public ProximityMonitorObserver, | 37 public ProximityMonitorObserver, |
37 public ScreenlockBridge::Observer, | 38 public ScreenlockBridge::Observer, |
38 #if defined(OS_CHROMEOS) | 39 #if defined(OS_CHROMEOS) |
39 chromeos::PowerManagerClient::Observer, | 40 chromeos::PowerManagerClient::Observer, |
40 #endif // defined(OS_CHROMEOS) | 41 #endif // defined(OS_CHROMEOS) |
41 public device::BluetoothAdapter::Observer { | 42 public device::BluetoothAdapter::Observer { |
42 public: | 43 public: |
43 // The |proximity_auth_client| is not owned and should outlive the constructed | 44 // The |proximity_auth_client| is not owned and should outlive the constructed |
44 // unlock manager. | 45 // unlock manager. |
45 UnlockManagerImpl(ProximityAuthSystem::ScreenlockType screenlock_type, | 46 UnlockManagerImpl(ProximityAuthSystem::ScreenlockType screenlock_type, |
46 ProximityAuthClient* proximity_auth_client); | 47 ProximityAuthClient* proximity_auth_client, |
| 48 ProximityAuthPrefManager* pref_manager); |
47 ~UnlockManagerImpl() override; | 49 ~UnlockManagerImpl() override; |
48 | 50 |
49 // UnlockManager: | 51 // UnlockManager: |
50 bool IsUnlockAllowed() override; | 52 bool IsUnlockAllowed() override; |
51 void SetRemoteDeviceLifeCycle(RemoteDeviceLifeCycle* life_cycle) override; | 53 void SetRemoteDeviceLifeCycle(RemoteDeviceLifeCycle* life_cycle) override; |
52 void OnLifeCycleStateChanged() override; | 54 void OnLifeCycleStateChanged() override; |
53 void OnAuthAttempted(mojom::AuthType auth_type) override; | 55 void OnAuthAttempted(mojom::AuthType auth_type) override; |
54 | 56 |
55 protected: | 57 protected: |
56 // Creates a ProximityMonitor instance for the given |connection|. | 58 // Creates a ProximityMonitor instance for the given |connection|. |
57 // Exposed for testing. | 59 // Exposed for testing. |
58 virtual std::unique_ptr<ProximityMonitor> CreateProximityMonitor( | 60 virtual std::unique_ptr<ProximityMonitor> CreateProximityMonitor( |
59 cryptauth::Connection* connection); | 61 cryptauth::Connection* connection, |
| 62 ProximityAuthPrefManager* pref_manager); |
60 | 63 |
61 private: | 64 private: |
62 // The possible lock screen states for the remote device. | 65 // The possible lock screen states for the remote device. |
63 enum class RemoteScreenlockState { | 66 enum class RemoteScreenlockState { |
64 UNKNOWN, | 67 UNKNOWN, |
65 UNLOCKED, | 68 UNLOCKED, |
66 DISABLED, | 69 DISABLED, |
67 LOCKED, | 70 LOCKED, |
68 }; | 71 }; |
69 | 72 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 // expcted to outlive |this| instance. | 151 // expcted to outlive |this| instance. |
149 RemoteDeviceLifeCycle* life_cycle_; | 152 RemoteDeviceLifeCycle* life_cycle_; |
150 | 153 |
151 // Tracks whether the remote device is currently in close enough proximity to | 154 // Tracks whether the remote device is currently in close enough proximity to |
152 // the local device to allow unlocking. | 155 // the local device to allow unlocking. |
153 std::unique_ptr<ProximityMonitor> proximity_monitor_; | 156 std::unique_ptr<ProximityMonitor> proximity_monitor_; |
154 | 157 |
155 // Used to call into the embedder. Expected to outlive |this| instance. | 158 // Used to call into the embedder. Expected to outlive |this| instance. |
156 ProximityAuthClient* proximity_auth_client_; | 159 ProximityAuthClient* proximity_auth_client_; |
157 | 160 |
| 161 // Used to access the common prefs. Expected to outlive |this| instance. |
| 162 ProximityAuthPrefManager* pref_manager_; |
| 163 |
158 // Whether the screen is currently locked. | 164 // Whether the screen is currently locked. |
159 bool is_locked_; | 165 bool is_locked_; |
160 | 166 |
161 // True if the manager is currently processing a user-initiated authentication | 167 // True if the manager is currently processing a user-initiated authentication |
162 // attempt, which is initiated when the user pod is clicked. | 168 // attempt, which is initiated when the user pod is clicked. |
163 bool is_attempting_auth_; | 169 bool is_attempting_auth_; |
164 | 170 |
165 // Whether the system is waking up from sleep. | 171 // Whether the system is waking up from sleep. |
166 bool is_waking_up_; | 172 bool is_waking_up_; |
167 | 173 |
(...skipping 19 matching lines...) Expand all Loading... |
187 | 193 |
188 // Used to vend all other weak pointers. | 194 // Used to vend all other weak pointers. |
189 base::WeakPtrFactory<UnlockManagerImpl> weak_ptr_factory_; | 195 base::WeakPtrFactory<UnlockManagerImpl> weak_ptr_factory_; |
190 | 196 |
191 DISALLOW_COPY_AND_ASSIGN(UnlockManagerImpl); | 197 DISALLOW_COPY_AND_ASSIGN(UnlockManagerImpl); |
192 }; | 198 }; |
193 | 199 |
194 } // namespace proximity_auth | 200 } // namespace proximity_auth |
195 | 201 |
196 #endif // COMPONENTS_PROXIMITY_AUTH_UNLOCK_MANAGER_IMPL_H | 202 #endif // COMPONENTS_PROXIMITY_AUTH_UNLOCK_MANAGER_IMPL_H |
OLD | NEW |