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

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

Issue 1096293003: Move screenlock_bridge to components/proximity_auth (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 7 months 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
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 CHROME_BROWSER_SIGNIN_SCREENLOCK_BRIDGE_H_ 5 #ifndef COMPONENTS_PROXIMITY_AUTH_SCREENLOCK_BRIDGE_H_
6 #define CHROME_BROWSER_SIGNIN_SCREENLOCK_BRIDGE_H_ 6 #define COMPONENTS_PROXIMITY_AUTH_SCREENLOCK_BRIDGE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/lazy_instance.h"
12 #include "base/macros.h" 11 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
14 #include "base/observer_list.h" 13 #include "base/observer_list.h"
15 #include "base/strings/string16.h" 14 #include "base/strings/string16.h"
16 #include "base/values.h" 15 #include "base/values.h"
17 16
17 namespace content {
18 class BrowserContext;
19 } // namespace content
18 20
19 class Profile; 21 namespace proximity_auth {
22
23 class ProximityAuthClient;
20 24
21 // ScreenlockBridge brings together the screenLockPrivate API and underlying 25 // ScreenlockBridge brings together the screenLockPrivate API and underlying
22 // support. On ChromeOS, it delegates calls to the ScreenLocker. On other 26 // support. On ChromeOS, it delegates calls to the ScreenLocker. On other
23 // platforms, it delegates calls to UserManagerUI (and friends). 27 // platforms, it delegates calls to UserManagerUI (and friends).
24 // TODO(tbarzic): Rename ScreenlockBridge to SignInScreenBridge, as this is not 28 // TODO(tbarzic): Rename ScreenlockBridge to SignInScreenBridge, as this is not
25 // used solely for the lock screen anymore. 29 // used solely for the lock screen anymore.
26 class ScreenlockBridge { 30 class ScreenlockBridge {
27 public: 31 public:
32 explicit ScreenlockBridge(ProximityAuthClient* client);
Ilya Sherman 2015/04/24 21:22:02 Please document the lifetime expectations for the
msarda 2015/04/27 11:29:25 Done.
33 ~ScreenlockBridge();
34
28 // User pod icons supported by lock screen / signin screen UI. 35 // User pod icons supported by lock screen / signin screen UI.
29 enum UserPodCustomIcon { 36 enum UserPodCustomIcon {
30 USER_POD_CUSTOM_ICON_NONE, 37 USER_POD_CUSTOM_ICON_NONE,
31 USER_POD_CUSTOM_ICON_HARDLOCKED, 38 USER_POD_CUSTOM_ICON_HARDLOCKED,
32 USER_POD_CUSTOM_ICON_LOCKED, 39 USER_POD_CUSTOM_ICON_LOCKED,
33 USER_POD_CUSTOM_ICON_LOCKED_TO_BE_ACTIVATED, 40 USER_POD_CUSTOM_ICON_LOCKED_TO_BE_ACTIVATED,
34 // TODO(isherman): The "locked with proximity hint" icon is currently the 41 // TODO(isherman): The "locked with proximity hint" icon is currently the
35 // same as the "locked" icon. It's treated as a separate case to allow an 42 // same as the "locked" icon. It's treated as a separate case to allow an
36 // easy asset swap without changing the code, in case we decide to use a 43 // easy asset swap without changing the code, in case we decide to use a
37 // different icon for this case. If we definitely decide against that, then 44 // different icon for this case. If we definitely decide against that, then
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 // user_pod_row.js. 99 // user_pod_row.js.
93 enum AuthType { 100 enum AuthType {
94 OFFLINE_PASSWORD = 0, 101 OFFLINE_PASSWORD = 0,
95 ONLINE_SIGN_IN = 1, 102 ONLINE_SIGN_IN = 1,
96 NUMERIC_PIN = 2, 103 NUMERIC_PIN = 2,
97 USER_CLICK = 3, 104 USER_CLICK = 3,
98 EXPAND_THEN_USER_CLICK = 4, 105 EXPAND_THEN_USER_CLICK = 4,
99 FORCE_OFFLINE_PASSWORD = 5 106 FORCE_OFFLINE_PASSWORD = 5
100 }; 107 };
101 108
102 enum ScreenType { 109 enum ScreenType { SIGNIN_SCREEN = 0, LOCK_SCREEN = 1, OTHER_SCREEN = 2 };
103 SIGNIN_SCREEN = 0,
104 LOCK_SCREEN = 1,
105 OTHER_SCREEN = 2
106 };
107 110
108 // Displays |message| in a banner on the lock screen. 111 // Displays |message| in a banner on the lock screen.
109 virtual void ShowBannerMessage(const base::string16& message) = 0; 112 virtual void ShowBannerMessage(const base::string16& message) = 0;
110 113
111 // Shows a custom icon in the user pod on the lock screen. 114 // Shows a custom icon in the user pod on the lock screen.
112 virtual void ShowUserPodCustomIcon( 115 virtual void ShowUserPodCustomIcon(
113 const std::string& user_email, 116 const std::string& user_email,
114 const UserPodCustomIconOptions& icon) = 0; 117 const UserPodCustomIconOptions& icon) = 0;
115 118
116 // Hides the custom icon in user pod for a user. 119 // Hides the custom icon in user pod for a user.
117 virtual void HideUserPodCustomIcon(const std::string& user_email) = 0; 120 virtual void HideUserPodCustomIcon(const std::string& user_email) = 0;
118 121
119 // (Re)enable lock screen UI. 122 // (Re)enable lock screen UI.
120 virtual void EnableInput() = 0; 123 virtual void EnableInput() = 0;
121 124
122 // Set the authentication type to be used on the lock screen. 125 // Set the authentication type to be used on the lock screen.
123 virtual void SetAuthType(const std::string& user_email, 126 virtual void SetAuthType(const std::string& user_email,
124 AuthType auth_type, 127 AuthType auth_type,
125 const base::string16& auth_value) = 0; 128 const base::string16& auth_value) = 0;
126 129
127 // Returns the authentication type used for a user. 130 // Returns the authentication type used for a user.
128 virtual AuthType GetAuthType(const std::string& user_email) const = 0; 131 virtual AuthType GetAuthType(const std::string& user_email) const = 0;
129 132
130 // Returns the type of the screen -- a signin or a lock screen. 133 // Returns the type of the screen -- a signin or a lock screen.
131 virtual ScreenType GetScreenType() const = 0; 134 virtual ScreenType GetScreenType() const = 0;
132 135
133 // Unlock from easy unlock app for a user. 136 // Unlocks from easy unlock app for a user.
134 virtual void Unlock(const std::string& user_email) = 0; 137 virtual void Unlock(const std::string& user_email) = 0;
135 138
136 // Attempts to login the user using an easy unlock key. 139 // Attempts to login the user using an easy unlock key.
137 virtual void AttemptEasySignin(const std::string& user_email, 140 virtual void AttemptEasySignin(const std::string& user_email,
138 const std::string& secret, 141 const std::string& secret,
139 const std::string& key_label) = 0; 142 const std::string& key_label) = 0;
140 143
141 protected: 144 protected:
142 virtual ~LockHandler() {} 145 virtual ~LockHandler() {}
143 }; 146 };
144 147
145 class Observer { 148 class Observer {
146 public: 149 public:
147 // Invoked after the screen is locked. 150 // Invoked after the screen is locked.
148 virtual void OnScreenDidLock(LockHandler::ScreenType screen_type) = 0; 151 virtual void OnScreenDidLock(LockHandler::ScreenType screen_type) = 0;
149 152
150 // Invoked after the screen lock is dismissed. 153 // Invoked after the screen lock is dismissed.
151 virtual void OnScreenDidUnlock(LockHandler::ScreenType screen_type) = 0; 154 virtual void OnScreenDidUnlock(LockHandler::ScreenType screen_type) = 0;
152 155
153 // Invoked when the user focused on the lock screen changes. 156 // Invoked when the user focused on the lock screen changes.
154 virtual void OnFocusedUserChanged(const std::string& user_id) = 0; 157 virtual void OnFocusedUserChanged(const std::string& user_id) = 0;
155 158
156 protected: 159 protected:
157 virtual ~Observer() {} 160 virtual ~Observer() {}
158 }; 161 };
159 162
160 static ScreenlockBridge* Get();
161 static std::string GetAuthenticatedUserEmail(const Profile* profile);
162
163 void SetLockHandler(LockHandler* lock_handler); 163 void SetLockHandler(LockHandler* lock_handler);
164 void SetFocusedUser(const std::string& user_id); 164 void SetFocusedUser(const std::string& user_id);
165 165
166 bool IsLocked() const; 166 bool IsLocked() const;
167 void Lock(Profile* profile); 167 void Lock(content::BrowserContext* browser_context);
168 void Unlock(Profile* profile); 168 void Unlock(content::BrowserContext* browser_context);
169 169
170 void AddObserver(Observer* observer); 170 void AddObserver(Observer* observer);
171 void RemoveObserver(Observer* observer); 171 void RemoveObserver(Observer* observer);
172 172
173 LockHandler* lock_handler() { return lock_handler_; } 173 LockHandler* lock_handler() { return lock_handler_; }
174 174
175 std::string focused_user_id() const { return focused_user_id_; } 175 std::string focused_user_id() const { return focused_user_id_; }
176 176
177 private: 177 private:
178 friend struct base::DefaultLazyInstanceTraits<ScreenlockBridge>; 178 ProximityAuthClient* client_; // Not owned. Must outlive this object.
179 friend struct base::DefaultDeleter<ScreenlockBridge>; 179 LockHandler* lock_handler_; // Not owned
180
181 ScreenlockBridge();
182 ~ScreenlockBridge();
183
184 LockHandler* lock_handler_; // Not owned
185 // The last focused user's id. 180 // The last focused user's id.
186 std::string focused_user_id_; 181 std::string focused_user_id_;
187 ObserverList<Observer, true> observers_; 182 ObserverList<Observer, true> observers_;
188 183
189 DISALLOW_COPY_AND_ASSIGN(ScreenlockBridge); 184 DISALLOW_COPY_AND_ASSIGN(ScreenlockBridge);
190 }; 185 };
191 186
192 #endif // CHROME_BROWSER_SIGNIN_SCREENLOCK_BRIDGE_H_ 187 } // namespace proximity_auth
188
189 #endif // COMPONENTS_PROXIMITY_AUTH_SCREENLOCK_BRIDGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698