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

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 // |client| is not owned and must outlive this object.
33 explicit ScreenlockBridge(ProximityAuthClient* client);
34 ~ScreenlockBridge();
35
28 // User pod icons supported by lock screen / signin screen UI. 36 // User pod icons supported by lock screen / signin screen UI.
29 enum UserPodCustomIcon { 37 enum UserPodCustomIcon {
30 USER_POD_CUSTOM_ICON_NONE, 38 USER_POD_CUSTOM_ICON_NONE,
31 USER_POD_CUSTOM_ICON_HARDLOCKED, 39 USER_POD_CUSTOM_ICON_HARDLOCKED,
32 USER_POD_CUSTOM_ICON_LOCKED, 40 USER_POD_CUSTOM_ICON_LOCKED,
33 USER_POD_CUSTOM_ICON_LOCKED_TO_BE_ACTIVATED, 41 USER_POD_CUSTOM_ICON_LOCKED_TO_BE_ACTIVATED,
34 // TODO(isherman): The "locked with proximity hint" icon is currently the 42 // 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 43 // 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 44 // 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 45 // 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. 100 // user_pod_row.js.
93 enum AuthType { 101 enum AuthType {
94 OFFLINE_PASSWORD = 0, 102 OFFLINE_PASSWORD = 0,
95 ONLINE_SIGN_IN = 1, 103 ONLINE_SIGN_IN = 1,
96 NUMERIC_PIN = 2, 104 NUMERIC_PIN = 2,
97 USER_CLICK = 3, 105 USER_CLICK = 3,
98 EXPAND_THEN_USER_CLICK = 4, 106 EXPAND_THEN_USER_CLICK = 4,
99 FORCE_OFFLINE_PASSWORD = 5 107 FORCE_OFFLINE_PASSWORD = 5
100 }; 108 };
101 109
102 enum ScreenType { 110 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 111
108 // Displays |message| in a banner on the lock screen. 112 // Displays |message| in a banner on the lock screen.
109 virtual void ShowBannerMessage(const base::string16& message) = 0; 113 virtual void ShowBannerMessage(const base::string16& message) = 0;
110 114
111 // Shows a custom icon in the user pod on the lock screen. 115 // Shows a custom icon in the user pod on the lock screen.
112 virtual void ShowUserPodCustomIcon( 116 virtual void ShowUserPodCustomIcon(
113 const std::string& user_email, 117 const std::string& user_email,
114 const UserPodCustomIconOptions& icon) = 0; 118 const UserPodCustomIconOptions& icon) = 0;
115 119
116 // Hides the custom icon in user pod for a user. 120 // Hides the custom icon in user pod for a user.
117 virtual void HideUserPodCustomIcon(const std::string& user_email) = 0; 121 virtual void HideUserPodCustomIcon(const std::string& user_email) = 0;
118 122
119 // (Re)enable lock screen UI. 123 // (Re)enable lock screen UI.
120 virtual void EnableInput() = 0; 124 virtual void EnableInput() = 0;
121 125
122 // Set the authentication type to be used on the lock screen. 126 // Set the authentication type to be used on the lock screen.
123 virtual void SetAuthType(const std::string& user_email, 127 virtual void SetAuthType(const std::string& user_email,
124 AuthType auth_type, 128 AuthType auth_type,
125 const base::string16& auth_value) = 0; 129 const base::string16& auth_value) = 0;
126 130
127 // Returns the authentication type used for a user. 131 // Returns the authentication type used for a user.
128 virtual AuthType GetAuthType(const std::string& user_email) const = 0; 132 virtual AuthType GetAuthType(const std::string& user_email) const = 0;
129 133
130 // Returns the type of the screen -- a signin or a lock screen. 134 // Returns the type of the screen -- a signin or a lock screen.
131 virtual ScreenType GetScreenType() const = 0; 135 virtual ScreenType GetScreenType() const = 0;
132 136
133 // Unlock from easy unlock app for a user. 137 // Unlocks from easy unlock app for a user.
134 virtual void Unlock(const std::string& user_email) = 0; 138 virtual void Unlock(const std::string& user_email) = 0;
135 139
136 // Attempts to login the user using an easy unlock key. 140 // Attempts to login the user using an easy unlock key.
137 virtual void AttemptEasySignin(const std::string& user_email, 141 virtual void AttemptEasySignin(const std::string& user_email,
138 const std::string& secret, 142 const std::string& secret,
139 const std::string& key_label) = 0; 143 const std::string& key_label) = 0;
140 144
141 protected: 145 protected:
142 virtual ~LockHandler() {} 146 virtual ~LockHandler() {}
143 }; 147 };
144 148
145 class Observer { 149 class Observer {
146 public: 150 public:
147 // Invoked after the screen is locked. 151 // Invoked after the screen is locked.
148 virtual void OnScreenDidLock(LockHandler::ScreenType screen_type) = 0; 152 virtual void OnScreenDidLock(LockHandler::ScreenType screen_type) = 0;
149 153
150 // Invoked after the screen lock is dismissed. 154 // Invoked after the screen lock is dismissed.
151 virtual void OnScreenDidUnlock(LockHandler::ScreenType screen_type) = 0; 155 virtual void OnScreenDidUnlock(LockHandler::ScreenType screen_type) = 0;
152 156
153 // Invoked when the user focused on the lock screen changes. 157 // Invoked when the user focused on the lock screen changes.
154 virtual void OnFocusedUserChanged(const std::string& user_id) = 0; 158 virtual void OnFocusedUserChanged(const std::string& user_id) = 0;
155 159
156 protected: 160 protected:
157 virtual ~Observer() {} 161 virtual ~Observer() {}
158 }; 162 };
159 163
160 static ScreenlockBridge* Get();
161 static std::string GetAuthenticatedUserEmail(const Profile* profile);
162
163 void SetLockHandler(LockHandler* lock_handler); 164 void SetLockHandler(LockHandler* lock_handler);
164 void SetFocusedUser(const std::string& user_id); 165 void SetFocusedUser(const std::string& user_id);
165 166
166 bool IsLocked() const; 167 bool IsLocked() const;
167 void Lock(Profile* profile); 168 void Lock(content::BrowserContext* browser_context);
168 void Unlock(Profile* profile); 169 void Unlock(content::BrowserContext* browser_context);
169 170
170 void AddObserver(Observer* observer); 171 void AddObserver(Observer* observer);
171 void RemoveObserver(Observer* observer); 172 void RemoveObserver(Observer* observer);
172 173
173 LockHandler* lock_handler() { return lock_handler_; } 174 LockHandler* lock_handler() { return lock_handler_; }
174 175
175 std::string focused_user_id() const { return focused_user_id_; } 176 std::string focused_user_id() const { return focused_user_id_; }
176 177
177 private: 178 private:
178 friend struct base::DefaultLazyInstanceTraits<ScreenlockBridge>; 179 ProximityAuthClient* client_; // Not owned. Must outlive this object.
179 friend struct base::DefaultDeleter<ScreenlockBridge>; 180 LockHandler* lock_handler_; // Not owned
180
181 ScreenlockBridge();
182 ~ScreenlockBridge();
183
184 LockHandler* lock_handler_; // Not owned
185 // The last focused user's id. 181 // The last focused user's id.
186 std::string focused_user_id_; 182 std::string focused_user_id_;
187 ObserverList<Observer, true> observers_; 183 ObserverList<Observer, true> observers_;
188 184
189 DISALLOW_COPY_AND_ASSIGN(ScreenlockBridge); 185 DISALLOW_COPY_AND_ASSIGN(ScreenlockBridge);
190 }; 186 };
191 187
192 #endif // CHROME_BROWSER_SIGNIN_SCREENLOCK_BRIDGE_H_ 188 } // namespace proximity_auth
189
190 #endif // COMPONENTS_PROXIMITY_AUTH_SCREENLOCK_BRIDGE_H_
OLDNEW
« no previous file with comments | « components/proximity_auth/proximity_auth_client.h ('k') | components/proximity_auth/screenlock_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698