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_H | 5 #ifndef COMPONENTS_PROXIMITY_AUTH_UNLOCK_MANAGER_H |
6 #define COMPONENTS_PROXIMITY_AUTH_UNLOCK_MANAGER_H | 6 #define COMPONENTS_PROXIMITY_AUTH_UNLOCK_MANAGER_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" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 bool IsUnlockAllowed(); | 55 bool IsUnlockAllowed(); |
56 | 56 |
57 // Sets the |life_cycle| of the rmeote device to which local events are | 57 // Sets the |life_cycle| of the rmeote device to which local events are |
58 // dispatched. A null |life_cycle| indicates that proximity-based | 58 // dispatched. A null |life_cycle| indicates that proximity-based |
59 // authentication is inactive. | 59 // authentication is inactive. |
60 void SetRemoteDeviceLifeCycle(RemoteDeviceLifeCycle* life_cycle); | 60 void SetRemoteDeviceLifeCycle(RemoteDeviceLifeCycle* life_cycle); |
61 | 61 |
62 // Called when the life cycle's state changes. | 62 // Called when the life cycle's state changes. |
63 void OnLifeCycleStateChanged(); | 63 void OnLifeCycleStateChanged(); |
64 | 64 |
| 65 protected: |
65 // Called when the user pod is clicked for an authentication attempt of type | 66 // Called when the user pod is clicked for an authentication attempt of type |
66 // |auth_type|. | 67 // |auth_type|. |
67 // Exposed for testing. | 68 // Exposed for testing. |
68 void OnAuthAttempted(ScreenlockBridge::LockHandler::AuthType auth_type); | 69 void OnAuthAttempted(ScreenlockBridge::LockHandler::AuthType auth_type); |
69 | 70 |
70 private: | 71 private: |
71 // The possible lock screen states for the remote device. | 72 // The possible lock screen states for the remote device. |
72 enum class RemoteScreenlockState { | 73 enum class RemoteScreenlockState { |
73 UNKNOWN, | 74 UNKNOWN, |
74 UNLOCKED, | 75 UNLOCKED, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 128 |
128 // Accepts or rejects the current auth attempt according to |should_accept|. | 129 // Accepts or rejects the current auth attempt according to |should_accept|. |
129 // If the auth attempt is accepted, unlocks the screen. | 130 // If the auth attempt is accepted, unlocks the screen. |
130 void AcceptAuthAttempt(bool should_accept); | 131 void AcceptAuthAttempt(bool should_accept); |
131 | 132 |
132 // Returns the screen lock state corresponding to the given remote |status| | 133 // Returns the screen lock state corresponding to the given remote |status| |
133 // update. | 134 // update. |
134 RemoteScreenlockState GetScreenlockStateFromRemoteUpdate( | 135 RemoteScreenlockState GetScreenlockStateFromRemoteUpdate( |
135 RemoteStatusUpdate update); | 136 RemoteStatusUpdate update); |
136 | 137 |
137 // Returns the Messenger instance associated with |life_cycle_|. This function | |
138 // will return nullptr if |life_cycle_| is not set or the remote device is not | |
139 // yet authenticated. | |
140 Messenger* GetMessenger(); | |
141 | |
142 // Whether |this| manager is being used for sign-in or session unlock. | 138 // Whether |this| manager is being used for sign-in or session unlock. |
143 const ScreenlockType screenlock_type_; | 139 const ScreenlockType screenlock_type_; |
144 | 140 |
145 // Whether the user is present at the remote device. Unset if no remote status | 141 // Whether the user is present at the remote device. Unset if no remote status |
146 // update has yet been received. | 142 // update has yet been received. |
147 scoped_ptr<RemoteScreenlockState> remote_screenlock_state_; | 143 scoped_ptr<RemoteScreenlockState> remote_screenlock_state_; |
148 | 144 |
149 // Controls the proximity auth flow logic for a remote device. Not owned, and | 145 // Controls the proximity auth flow logic for a remote device. Not owned, and |
150 // expcted to outlive |this| instance. | 146 // expcted to outlive |this| instance. |
151 RemoteDeviceLifeCycle* life_cycle_; | 147 RemoteDeviceLifeCycle* life_cycle_; |
152 | 148 |
| 149 // The messenger used to communicate with the remote device once a secure |
| 150 // channel |
| 151 // is established. Null if no secure channel has been established yet. Not |
| 152 // owned, and expected to outlive |this| instance. |
| 153 Messenger* messenger_; |
| 154 |
153 // Tracks whether the remote device is currently in close enough proximity to | 155 // Tracks whether the remote device is currently in close enough proximity to |
154 // the local device to allow unlocking. | 156 // the local device to allow unlocking. |
155 scoped_ptr<ProximityMonitor> proximity_monitor_; | 157 scoped_ptr<ProximityMonitor> proximity_monitor_; |
156 | 158 |
157 // Used to call into the embedder. Expected to outlive |this| instance. | 159 // Used to call into the embedder. Expected to outlive |this| instance. |
158 ProximityAuthClient* proximity_auth_client_; | 160 ProximityAuthClient* proximity_auth_client_; |
159 | 161 |
160 // Whether the screen is currently locked. | 162 // Whether the screen is currently locked. |
161 bool is_locked_; | 163 bool is_locked_; |
162 | 164 |
(...skipping 25 matching lines...) Expand all Loading... |
188 | 190 |
189 // Used to vend all other weak pointers. | 191 // Used to vend all other weak pointers. |
190 base::WeakPtrFactory<UnlockManager> weak_ptr_factory_; | 192 base::WeakPtrFactory<UnlockManager> weak_ptr_factory_; |
191 | 193 |
192 DISALLOW_COPY_AND_ASSIGN(UnlockManager); | 194 DISALLOW_COPY_AND_ASSIGN(UnlockManager); |
193 }; | 195 }; |
194 | 196 |
195 } // namespace proximity_auth | 197 } // namespace proximity_auth |
196 | 198 |
197 #endif // COMPONENTS_PROXIMITY_AUTH_UNLOCK_MANAGER_H | 199 #endif // COMPONENTS_PROXIMITY_AUTH_UNLOCK_MANAGER_H |
OLD | NEW |