OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_CHROMEOS_LOGIN_SCREEN_LOCKER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SCREEN_LOCKER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREEN_LOCKER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREEN_LOCKER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/sequenced_task_runner_helpers.h" | 13 #include "base/sequenced_task_runner_helpers.h" |
14 #include "base/time.h" | 14 #include "base/time.h" |
15 #include "chrome/browser/chromeos/login/help_app_launcher.h" | 15 #include "chrome/browser/chromeos/login/help_app_launcher.h" |
16 #include "chrome/browser/chromeos/login/login_status_consumer.h" | 16 #include "chrome/browser/chromeos/login/login_status_consumer.h" |
17 #include "chrome/browser/chromeos/login/screen_locker_delegate.h" | 17 #include "chrome/browser/chromeos/login/screen_locker_delegate.h" |
| 18 #include "chrome/browser/chromeos/login/user.h" |
18 #include "ui/base/accelerators/accelerator.h" | 19 #include "ui/base/accelerators/accelerator.h" |
19 | 20 |
20 namespace content { | 21 namespace content { |
21 class WebUI; | 22 class WebUI; |
22 } | 23 } |
23 | 24 |
24 namespace chromeos { | 25 namespace chromeos { |
25 | 26 |
26 class Authenticator; | 27 class Authenticator; |
27 class LoginFailure; | 28 class LoginFailure; |
28 class User; | |
29 struct UserContext; | |
30 | 29 |
31 namespace test { | 30 namespace test { |
32 class ScreenLockerTester; | 31 class ScreenLockerTester; |
33 class ScreenLockerViewsTester; | 32 class ScreenLockerViewsTester; |
34 class WebUIScreenLockerTester; | 33 class WebUIScreenLockerTester; |
35 } // namespace test | 34 } // namespace test |
36 | 35 |
37 // ScreenLocker creates a ScreenLockerDelegate which will display the lock UI. | 36 // ScreenLocker creates a ScreenLockerDelegate which will display the lock UI. |
38 // As well, it takes care of authenticating the user and managing a global | 37 // As well, it takes care of authenticating the user and managing a global |
39 // instance of itself which will be deleted when the system is unlocked. | 38 // instance of itself which will be deleted when the system is unlocked. |
40 class ScreenLocker : public LoginStatusConsumer { | 39 class ScreenLocker : public LoginStatusConsumer { |
41 public: | 40 public: |
42 explicit ScreenLocker(const User& user); | 41 explicit ScreenLocker(const UserList& users); |
43 | 42 |
44 // Returns the default instance if it has been created. | 43 // Returns the default instance if it has been created. |
45 static ScreenLocker* default_screen_locker() { | 44 static ScreenLocker* default_screen_locker() { |
46 return screen_locker_; | 45 return screen_locker_; |
47 } | 46 } |
48 | 47 |
49 bool locked() const { return locked_; } | 48 bool locked() const { return locked_; } |
50 | 49 |
51 // Initialize and show the screen locker. | 50 // Initialize and show the screen locker. |
52 void Init(); | 51 void Init(); |
53 | 52 |
54 // LoginStatusConsumer implements: | 53 // LoginStatusConsumer implements: |
55 virtual void OnLoginFailure(const chromeos::LoginFailure& error) OVERRIDE; | 54 virtual void OnLoginFailure(const chromeos::LoginFailure& error) OVERRIDE; |
56 virtual void OnLoginSuccess(const UserContext& user_context, | 55 virtual void OnLoginSuccess(const UserContext& user_context, |
57 bool pending_requests, | 56 bool pending_requests, |
58 bool using_oauth) OVERRIDE; | 57 bool using_oauth) OVERRIDE; |
59 | 58 |
60 // Does actual unlocking once authentication is successful and all blocking | 59 // Does actual unlocking once authentication is successful and all blocking |
61 // animations are done. | 60 // animations are done. |
62 void UnlockOnLoginSuccess(); | 61 void UnlockOnLoginSuccess(); |
63 | 62 |
64 // Authenticates the user with given |password| and authenticator. | 63 // Authenticates the user with given |user_context|. |
65 void Authenticate(const string16& password); | 64 void Authenticate(const UserContext& user_context); |
| 65 |
| 66 // Authenticates the only user with given |password|. |
| 67 // Works only if there is only one logged in user in system. |
| 68 // DEPRECATED: used only by tests. |
| 69 void AuthenticateByPassword(const std::string& password); |
66 | 70 |
67 // Close message bubble to clear error messages. | 71 // Close message bubble to clear error messages. |
68 void ClearErrors(); | 72 void ClearErrors(); |
69 | 73 |
70 // (Re)enable input field. | 74 // (Re)enable input field. |
71 void EnableInput(); | 75 void EnableInput(); |
72 | 76 |
73 // Exit the chrome, which will sign out the current session. | 77 // Exit the chrome, which will sign out the current session. |
74 void Signout(); | 78 void Signout(); |
75 | 79 |
76 // Disables all UI needed and shows error bubble with |message|. | 80 // Disables all UI needed and shows error bubble with |message|. |
77 // If |sign_out_only| is true then all other input except "Sign Out" | 81 // If |sign_out_only| is true then all other input except "Sign Out" |
78 // button is blocked. | 82 // button is blocked. |
79 void ShowErrorMessage(int error_msg_id, | 83 void ShowErrorMessage(int error_msg_id, |
80 HelpAppLauncher::HelpTopic help_topic_id, | 84 HelpAppLauncher::HelpTopic help_topic_id, |
81 bool sign_out_only); | 85 bool sign_out_only); |
82 | 86 |
83 // Returns the screen locker's delegate. | 87 // Returns the screen locker's delegate. |
84 ScreenLockerDelegate* delegate() const { return delegate_.get(); } | 88 ScreenLockerDelegate* delegate() const { return delegate_.get(); } |
85 | 89 |
86 // Returns the user to authenticate. | 90 // Returns the users to authenticate. |
87 const User& user() const { return user_; } | 91 const UserList& users() const { return users_; } |
88 | 92 |
89 // Allow a LoginStatusConsumer to listen for | 93 // Allow a LoginStatusConsumer to listen for |
90 // the same login events that ScreenLocker does. | 94 // the same login events that ScreenLocker does. |
91 void SetLoginStatusConsumer(chromeos::LoginStatusConsumer* consumer); | 95 void SetLoginStatusConsumer(chromeos::LoginStatusConsumer* consumer); |
92 | 96 |
93 // Returns WebUI associated with screen locker implementation or NULL if | 97 // Returns WebUI associated with screen locker implementation or NULL if |
94 // there isn't one. | 98 // there isn't one. |
95 content::WebUI* GetAssociatedWebUI(); | 99 content::WebUI* GetAssociatedWebUI(); |
96 | 100 |
97 // Initialize ScreenLocker class. It will listen to | 101 // Initialize ScreenLocker class. It will listen to |
(...skipping 27 matching lines...) Expand all Loading... |
125 | 129 |
126 // Sets the authenticator. | 130 // Sets the authenticator. |
127 void SetAuthenticator(Authenticator* authenticator); | 131 void SetAuthenticator(Authenticator* authenticator); |
128 | 132 |
129 // Called when the screen lock is ready. | 133 // Called when the screen lock is ready. |
130 void ScreenLockReady(); | 134 void ScreenLockReady(); |
131 | 135 |
132 // Called when screen locker is safe to delete. | 136 // Called when screen locker is safe to delete. |
133 static void ScheduleDeletion(); | 137 static void ScheduleDeletion(); |
134 | 138 |
| 139 // Returns true if |username| is found among logged in users. |
| 140 bool IsUserLoggedIn(const std::string& username); |
| 141 |
135 // ScreenLockerDelegate instance in use. | 142 // ScreenLockerDelegate instance in use. |
136 scoped_ptr<ScreenLockerDelegate> delegate_; | 143 scoped_ptr<ScreenLockerDelegate> delegate_; |
137 | 144 |
138 // Logged in user. | 145 // Logged in users. First user in list is active user. |
139 const User& user_; | 146 const UserList& users_; |
140 | 147 |
141 // Used to authenticate the user to unlock. | 148 // Used to authenticate the user to unlock. |
142 scoped_refptr<Authenticator> authenticator_; | 149 scoped_refptr<Authenticator> authenticator_; |
143 | 150 |
144 // Unlock the screen when it detects key/mouse event without asking | |
145 // password. True when chrome is in BWSI or auto login mode. | |
146 bool unlock_on_input_; | |
147 | |
148 // True if the screen is locked, or false otherwise. This changes | 151 // True if the screen is locked, or false otherwise. This changes |
149 // from false to true, but will never change from true to | 152 // from false to true, but will never change from true to |
150 // false. Instead, ScreenLocker object gets deleted when unlocked. | 153 // false. Instead, ScreenLocker object gets deleted when unlocked. |
151 bool locked_; | 154 bool locked_; |
152 | 155 |
153 // Reference to the single instance of the screen locker object. | 156 // Reference to the single instance of the screen locker object. |
154 // This is used to make sure there is only one screen locker instance. | 157 // This is used to make sure there is only one screen locker instance. |
155 static ScreenLocker* screen_locker_; | 158 static ScreenLocker* screen_locker_; |
156 | 159 |
157 // The time when the screen locker object is created. | 160 // The time when the screen locker object is created. |
(...skipping 13 matching lines...) Expand all Loading... |
171 scoped_ptr<AuthenticationParametersCapture> authentication_capture_; | 174 scoped_ptr<AuthenticationParametersCapture> authentication_capture_; |
172 | 175 |
173 base::WeakPtrFactory<ScreenLocker> weak_factory_; | 176 base::WeakPtrFactory<ScreenLocker> weak_factory_; |
174 | 177 |
175 DISALLOW_COPY_AND_ASSIGN(ScreenLocker); | 178 DISALLOW_COPY_AND_ASSIGN(ScreenLocker); |
176 }; | 179 }; |
177 | 180 |
178 } // namespace chromeos | 181 } // namespace chromeos |
179 | 182 |
180 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREEN_LOCKER_H_ | 183 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREEN_LOCKER_H_ |
OLD | NEW |