Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: components/proximity_auth/proximity_auth_system.h

Issue 1494153002: This CL replaces e-mail with AccountId in easy signin code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Bugfix in original easy unlock code' Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/proximity_auth/DEPS ('k') | components/proximity_auth/proximity_auth_system.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "components/signin/core/account_id/account_id.h"
16 17
17 namespace proximity_auth { 18 namespace proximity_auth {
18 19
19 class ProximityAuthClient; 20 class ProximityAuthClient;
20 class RemoteDeviceLifeCycle; 21 class RemoteDeviceLifeCycle;
21 class UnlockManager; 22 class UnlockManager;
22 23
23 // This is the main entry point to start Proximity Auth, the underlying system 24 // This is the main entry point to start Proximity Auth, the underlying system
24 // for the Smart Lock feature. Given a list of remote devices (i.e. a 25 // for the Smart Lock feature. Given a list of remote devices (i.e. a
25 // phone) for each registered user, the system will handle the connection, 26 // phone) for each registered user, the system will handle the connection,
26 // authentication, and messenging protocol when the screen is locked and the 27 // authentication, and messenging protocol when the screen is locked and the
27 // registered user is focused. 28 // registered user is focused.
28 class ProximityAuthSystem : public RemoteDeviceLifeCycle::Observer, 29 class ProximityAuthSystem : public RemoteDeviceLifeCycle::Observer,
29 public ScreenlockBridge::Observer { 30 public ScreenlockBridge::Observer {
30 public: 31 public:
31 enum ScreenlockType { SESSION_LOCK, SIGN_IN }; 32 enum ScreenlockType { SESSION_LOCK, SIGN_IN };
32 33
33 ProximityAuthSystem(ScreenlockType screenlock_type, 34 ProximityAuthSystem(ScreenlockType screenlock_type,
34 ProximityAuthClient* proximity_auth_client); 35 ProximityAuthClient* proximity_auth_client);
35 ~ProximityAuthSystem() override; 36 ~ProximityAuthSystem() override;
36 37
37 // Starts the system to connect and authenticate when a registered user is 38 // Starts the system to connect and authenticate when a registered user is
38 // focused on the lock/sign-in screen. 39 // focused on the lock/sign-in screen.
39 void Start(); 40 void Start();
40 41
41 // Stops the system. 42 // Stops the system.
42 void Stop(); 43 void Stop();
43 44
44 // Registers a list of |remote_devices| for |user_id| that can be used for 45 // Registers a list of |remote_devices| for |account_id| that can be used for
45 // sign-in/unlock. If devices were previously registered for the user, then 46 // sign-in/unlock. If devices were previously registered for the user, then
46 // they will be replaced. 47 // they will be replaced.
47 void SetRemoteDevicesForUser(const std::string& user_id, 48 void SetRemoteDevicesForUser(const AccountId& account_id,
48 const RemoteDeviceList& remote_devices); 49 const RemoteDeviceList& remote_devices);
49 50
50 // Returns the RemoteDevices registered for |user_id|. Returns an empty list 51 // Returns the RemoteDevices registered for |account_id|. Returns an empty
51 // if no devices are registered for |user_id|. 52 // list
52 RemoteDeviceList GetRemoteDevicesForUser(const std::string& user_id) const; 53 // if no devices are registered for |account_id|.
54 RemoteDeviceList GetRemoteDevicesForUser(const AccountId& account_id) const;
53 55
54 // Called when the user clicks the user pod and attempts to unlock/sign-in. 56 // Called when the user clicks the user pod and attempts to unlock/sign-in.
55 void OnAuthAttempted(const std::string& user_id); 57 void OnAuthAttempted(const AccountId& account_id);
56 58
57 // Called when the system suspends. 59 // Called when the system suspends.
58 void OnSuspend(); 60 void OnSuspend();
59 61
60 // Called when the system wakes up from a suspended state. 62 // Called when the system wakes up from a suspended state.
61 void OnSuspendDone(); 63 void OnSuspendDone();
62 64
63 private: 65 private:
64 // RemoteDeviceLifeCycle::Observer: 66 // RemoteDeviceLifeCycle::Observer:
65 void OnLifeCycleStateChanged(RemoteDeviceLifeCycle::State old_state, 67 void OnLifeCycleStateChanged(RemoteDeviceLifeCycle::State old_state,
66 RemoteDeviceLifeCycle::State new_state) override; 68 RemoteDeviceLifeCycle::State new_state) override;
67 69
68 // ScreenlockBridge::Observer: 70 // ScreenlockBridge::Observer:
69 void OnScreenDidLock( 71 void OnScreenDidLock(
70 ScreenlockBridge::LockHandler::ScreenType screen_type) override; 72 ScreenlockBridge::LockHandler::ScreenType screen_type) override;
71 void OnScreenDidUnlock( 73 void OnScreenDidUnlock(
72 ScreenlockBridge::LockHandler::ScreenType screen_type) override; 74 ScreenlockBridge::LockHandler::ScreenType screen_type) override;
73 void OnFocusedUserChanged(const std::string& user_id) override; 75 void OnFocusedUserChanged(const AccountId& account_id) override;
74 76
75 // Resumes |remote_device_life_cycle_| after device wakes up and waits a 77 // Resumes |remote_device_life_cycle_| after device wakes up and waits a
76 // timeout. 78 // timeout.
77 void ResumeAfterWakeUpTimeout(); 79 void ResumeAfterWakeUpTimeout();
78 80
79 // Lists of remote devices, keyed by user id. 81 // Lists of remote devices, keyed by user account id.
80 std::map<std::string, RemoteDeviceList> remote_devices_map_; 82 std::map<AccountId, RemoteDeviceList> remote_devices_map_;
81 83
82 // Delegate for Chrome dependent functionality. 84 // Delegate for Chrome dependent functionality.
83 ProximityAuthClient* proximity_auth_client_; 85 ProximityAuthClient* proximity_auth_client_;
84 86
85 // Responsible for the life cycle of connecting and authenticating to 87 // Responsible for the life cycle of connecting and authenticating to
86 // the RemoteDevice of the currently focused user. 88 // the RemoteDevice of the currently focused user.
87 scoped_ptr<RemoteDeviceLifeCycle> remote_device_life_cycle_; 89 scoped_ptr<RemoteDeviceLifeCycle> remote_device_life_cycle_;
88 90
89 // Handles the interaction with the lock screen UI. 91 // Handles the interaction with the lock screen UI.
90 scoped_ptr<UnlockManager> unlock_manager_; 92 scoped_ptr<UnlockManager> unlock_manager_;
91 93
92 // True if the system is suspended. 94 // True if the system is suspended.
93 bool suspended_; 95 bool suspended_;
94 96
95 // True if the system is started_. 97 // True if the system is started_.
96 bool started_; 98 bool started_;
97 99
98 base::WeakPtrFactory<ProximityAuthSystem> weak_ptr_factory_; 100 base::WeakPtrFactory<ProximityAuthSystem> weak_ptr_factory_;
99 101
100 DISALLOW_COPY_AND_ASSIGN(ProximityAuthSystem); 102 DISALLOW_COPY_AND_ASSIGN(ProximityAuthSystem);
101 }; 103 };
102 104
103 } // namespace proximity_auth 105 } // namespace proximity_auth
104 106
105 #endif // COMPONENTS_PROXIMITY_AUTH_PROXIMITY_AUTH_SYSTEM_H 107 #endif // COMPONENTS_PROXIMITY_AUTH_PROXIMITY_AUTH_SYSTEM_H
OLDNEW
« no previous file with comments | « components/proximity_auth/DEPS ('k') | components/proximity_auth/proximity_auth_system.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698