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