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 CHROME_BROWSER_SIGNIN_SIGNIN_SCREEN_BRIDGE_H_ |
6 #define CHROME_BROWSER_SIGNIN_SCREENLOCK_BRIDGE_H_ | 6 #define CHROME_BROWSER_SIGNIN_SIGNIN_SCREEN_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 |
19 class Profile; | 19 class Profile; |
20 | 20 |
21 // ScreenlockBridge brings together the screenLockPrivate API and underlying | 21 // SigninScreenBridge brings together the screenLockPrivate API and underlying |
22 // support. On ChromeOS, it delegates calls to the ScreenLocker. On other | 22 // support. On ChromeOS, it delegates calls to the ScreenLocker. On other |
23 // platforms, it delegates calls to UserManagerUI (and friends). | 23 // platforms, it delegates calls to UserManagerUI (and friends). |
24 // TODO(tbarzic): Rename ScreelockBridge to SignInScreenBridge, as this is not | 24 // TODO(tbarzic): Rename ScreelockBridge to SignInScreenBridge, as this is not |
25 // used solely for the lock screen anymore. | 25 // used solely for the lock screen anymore. |
26 class ScreenlockBridge { | 26 class SigninScreenBridge { |
27 public: | 27 public: |
28 class Observer { | 28 class Observer { |
29 public: | 29 public: |
30 // Invoked after the screen is locked. | 30 // Invoked after the screen is locked. |
31 virtual void OnScreenDidLock() = 0; | 31 virtual void OnScreenDidLock() = 0; |
32 // Invoked after the screen lock is dismissed. | 32 // Invoked after the screen lock is dismissed. |
33 virtual void OnScreenDidUnlock() = 0; | 33 virtual void OnScreenDidUnlock() = 0; |
34 // Invoked when the user focused on the lock screen changes. | 34 // Invoked when the user focused on the lock screen changes. |
35 virtual void OnFocusedUserChanged(const std::string& user_id) = 0; | 35 virtual void OnFocusedUserChanged(const std::string& user_id) = 0; |
36 protected: | 36 protected: |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 137 |
138 // Attempts to login the user using an easy unlock key. | 138 // Attempts to login the user using an easy unlock key. |
139 virtual void AttemptUserClickLogin(const std::string& user_email, | 139 virtual void AttemptUserClickLogin(const std::string& user_email, |
140 const std::string& secret, | 140 const std::string& secret, |
141 const std::string& key_label) = 0; | 141 const std::string& key_label) = 0; |
142 | 142 |
143 protected: | 143 protected: |
144 virtual ~LockHandler() {} | 144 virtual ~LockHandler() {} |
145 }; | 145 }; |
146 | 146 |
147 static ScreenlockBridge* Get(); | 147 static SigninScreenBridge* Get(); |
148 static std::string GetAuthenticatedUserEmail(Profile* profile); | 148 static std::string GetAuthenticatedUserEmail(Profile* profile); |
149 | 149 |
150 void SetLockHandler(LockHandler* lock_handler); | 150 void SetLockHandler(LockHandler* lock_handler); |
151 void SetFocusedUser(const std::string& user_id); | 151 void SetFocusedUser(const std::string& user_id); |
152 | 152 |
153 bool IsLocked() const; | 153 bool IsLocked() const; |
154 void Lock(Profile* profile); | 154 void Lock(Profile* profile); |
155 void Unlock(Profile* profile); | 155 void Unlock(Profile* profile); |
156 | 156 |
157 void AddObserver(Observer* observer); | 157 void AddObserver(Observer* observer); |
158 void RemoveObserver(Observer* observer); | 158 void RemoveObserver(Observer* observer); |
159 | 159 |
160 LockHandler* lock_handler() { return lock_handler_; } | 160 LockHandler* lock_handler() { return lock_handler_; } |
161 | 161 |
162 std::string focused_user_id() const { return focused_user_id_; } | 162 std::string focused_user_id() const { return focused_user_id_; } |
163 | 163 |
164 private: | 164 private: |
165 friend struct base::DefaultLazyInstanceTraits<ScreenlockBridge>; | 165 friend struct base::DefaultLazyInstanceTraits<SigninScreenBridge>; |
166 friend struct base::DefaultDeleter<ScreenlockBridge>; | 166 friend struct base::DefaultDeleter<SigninScreenBridge>; |
167 | 167 |
168 ScreenlockBridge(); | 168 SigninScreenBridge(); |
169 ~ScreenlockBridge(); | 169 ~SigninScreenBridge(); |
170 | 170 |
171 LockHandler* lock_handler_; // Not owned | 171 LockHandler* lock_handler_; // Not owned |
172 // The last focused user's id. | 172 // The last focused user's id. |
173 std::string focused_user_id_; | 173 std::string focused_user_id_; |
174 ObserverList<Observer, true> observers_; | 174 ObserverList<Observer, true> observers_; |
175 | 175 |
176 DISALLOW_COPY_AND_ASSIGN(ScreenlockBridge); | 176 DISALLOW_COPY_AND_ASSIGN(SigninScreenBridge); |
177 }; | 177 }; |
178 | 178 |
179 #endif // CHROME_BROWSER_SIGNIN_SCREENLOCK_BRIDGE_H_ | 179 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_SCREEN_BRIDGE_H_ |
OLD | NEW |