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_SIGNIN_CONTENT_SCREENLOCK_BRIDGE_H_ |
6 #define CHROME_BROWSER_SIGNIN_SCREENLOCK_BRIDGE_H_ | 6 #define COMPONENTS_SIGNIN_CONTENT_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" | 11 #include "base/lazy_instance.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 | 17 |
18 | 18 namespace content { |
19 class Profile; | 19 class BrowserContext; |
| 20 } // namespace content |
20 | 21 |
21 // ScreenlockBridge brings together the screenLockPrivate API and underlying | 22 // ScreenlockBridge brings together the screenLockPrivate API and underlying |
22 // support. On ChromeOS, it delegates calls to the ScreenLocker. On other | 23 // support. On ChromeOS, it delegates calls to the ScreenLocker. On other |
23 // platforms, it delegates calls to UserManagerUI (and friends). | 24 // platforms, it delegates calls to UserManagerUI (and friends). |
24 // TODO(tbarzic): Rename ScreenlockBridge to SignInScreenBridge, as this is not | 25 // TODO(tbarzic): Rename ScreenlockBridge to SignInScreenBridge, as this is not |
25 // used solely for the lock screen anymore. | 26 // used solely for the lock screen anymore. |
26 class ScreenlockBridge { | 27 class ScreenlockBridge { |
27 public: | 28 public: |
28 // User pod icons supported by lock screen / signin screen UI. | 29 // User pod icons supported by lock screen / signin screen UI. |
29 enum UserPodCustomIcon { | 30 enum UserPodCustomIcon { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // user_pod_row.js. | 93 // user_pod_row.js. |
93 enum AuthType { | 94 enum AuthType { |
94 OFFLINE_PASSWORD = 0, | 95 OFFLINE_PASSWORD = 0, |
95 ONLINE_SIGN_IN = 1, | 96 ONLINE_SIGN_IN = 1, |
96 NUMERIC_PIN = 2, | 97 NUMERIC_PIN = 2, |
97 USER_CLICK = 3, | 98 USER_CLICK = 3, |
98 EXPAND_THEN_USER_CLICK = 4, | 99 EXPAND_THEN_USER_CLICK = 4, |
99 FORCE_OFFLINE_PASSWORD = 5 | 100 FORCE_OFFLINE_PASSWORD = 5 |
100 }; | 101 }; |
101 | 102 |
102 enum ScreenType { | 103 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 | 104 |
108 // Displays |message| in a banner on the lock screen. | 105 // Displays |message| in a banner on the lock screen. |
109 virtual void ShowBannerMessage(const base::string16& message) = 0; | 106 virtual void ShowBannerMessage(const base::string16& message) = 0; |
110 | 107 |
111 // Shows a custom icon in the user pod on the lock screen. | 108 // Shows a custom icon in the user pod on the lock screen. |
112 virtual void ShowUserPodCustomIcon( | 109 virtual void ShowUserPodCustomIcon( |
113 const std::string& user_email, | 110 const std::string& user_email, |
114 const UserPodCustomIconOptions& icon) = 0; | 111 const UserPodCustomIconOptions& icon) = 0; |
115 | 112 |
116 // Hides the custom icon in user pod for a user. | 113 // Hides the custom icon in user pod for a user. |
117 virtual void HideUserPodCustomIcon(const std::string& user_email) = 0; | 114 virtual void HideUserPodCustomIcon(const std::string& user_email) = 0; |
118 | 115 |
119 // (Re)enable lock screen UI. | 116 // (Re)enable lock screen UI. |
120 virtual void EnableInput() = 0; | 117 virtual void EnableInput() = 0; |
121 | 118 |
122 // Set the authentication type to be used on the lock screen. | 119 // Set the authentication type to be used on the lock screen. |
123 virtual void SetAuthType(const std::string& user_email, | 120 virtual void SetAuthType(const std::string& user_email, |
124 AuthType auth_type, | 121 AuthType auth_type, |
125 const base::string16& auth_value) = 0; | 122 const base::string16& auth_value) = 0; |
126 | 123 |
127 // Returns the authentication type used for a user. | 124 // Returns the authentication type used for a user. |
128 virtual AuthType GetAuthType(const std::string& user_email) const = 0; | 125 virtual AuthType GetAuthType(const std::string& user_email) const = 0; |
129 | 126 |
130 // Returns the type of the screen -- a signin or a lock screen. | 127 // Returns the type of the screen -- a signin or a lock screen. |
131 virtual ScreenType GetScreenType() const = 0; | 128 virtual ScreenType GetScreenType() const = 0; |
132 | 129 |
| 130 // Lock the screen for |browser_context|. |
| 131 virtual void Lock(content::BrowserContext* browser_context) = 0; |
| 132 |
| 133 // Unlock from easy unlock for |browser_context|. |
| 134 virtual void Unlock(content::BrowserContext* browser_context) = 0; |
| 135 |
133 // Unlock from easy unlock app for a user. | 136 // Unlock 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(); | 163 static ScreenlockBridge* Get(); |
161 static std::string GetAuthenticatedUserEmail(const Profile* profile); | |
162 | 164 |
163 void SetLockHandler(LockHandler* lock_handler); | 165 void SetLockHandler(LockHandler* lock_handler); |
164 void SetFocusedUser(const std::string& user_id); | 166 void SetFocusedUser(const std::string& user_id); |
165 | 167 |
166 bool IsLocked() const; | 168 bool IsLocked() const; |
167 void Lock(Profile* profile); | 169 void Lock(content::BrowserContext* browser_context); |
168 void Unlock(Profile* profile); | 170 void Unlock(content::BrowserContext* browser_context); |
169 | 171 |
170 void AddObserver(Observer* observer); | 172 void AddObserver(Observer* observer); |
171 void RemoveObserver(Observer* observer); | 173 void RemoveObserver(Observer* observer); |
172 | 174 |
173 LockHandler* lock_handler() { return lock_handler_; } | 175 LockHandler* lock_handler() { return lock_handler_; } |
174 | 176 |
175 std::string focused_user_id() const { return focused_user_id_; } | 177 std::string focused_user_id() const { return focused_user_id_; } |
176 | 178 |
177 private: | 179 private: |
178 friend struct base::DefaultLazyInstanceTraits<ScreenlockBridge>; | 180 friend struct base::DefaultLazyInstanceTraits<ScreenlockBridge>; |
179 friend struct base::DefaultDeleter<ScreenlockBridge>; | 181 friend struct base::DefaultDeleter<ScreenlockBridge>; |
180 | 182 |
181 ScreenlockBridge(); | 183 ScreenlockBridge(); |
182 ~ScreenlockBridge(); | 184 ~ScreenlockBridge(); |
183 | 185 |
184 LockHandler* lock_handler_; // Not owned | 186 LockHandler* lock_handler_; // Not owned |
185 // The last focused user's id. | 187 // The last focused user's id. |
186 std::string focused_user_id_; | 188 std::string focused_user_id_; |
187 ObserverList<Observer, true> observers_; | 189 ObserverList<Observer, true> observers_; |
188 | 190 |
189 DISALLOW_COPY_AND_ASSIGN(ScreenlockBridge); | 191 DISALLOW_COPY_AND_ASSIGN(ScreenlockBridge); |
190 }; | 192 }; |
191 | 193 |
192 #endif // CHROME_BROWSER_SIGNIN_SCREENLOCK_BRIDGE_H_ | 194 #endif // COMPONENTS_SIGNIN_CONTENT_SCREENLOCK_BRIDGE_H_ |
OLD | NEW |