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_EXISTING_USER_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_EXISTING_USER_CONTROLLER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_EXISTING_USER_CONTROLLER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_EXISTING_USER_CONTROLLER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "ash/wm/user_activity_observer.h" | |
bartfab (slow)
2013/02/28 10:21:33
This is no longer used.
dconnelly
2013/02/28 12:52:56
Done.
| |
10 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
12 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
15 #include "base/string16.h" | 16 #include "base/string16.h" |
16 #include "base/time.h" | 17 #include "base/time.h" |
17 #include "base/timer.h" | 18 #include "base/timer.h" |
18 #include "chrome/browser/chromeos/login/login_display.h" | 19 #include "chrome/browser/chromeos/login/login_display.h" |
19 #include "chrome/browser/chromeos/login/login_performer.h" | 20 #include "chrome/browser/chromeos/login/login_performer.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 | 61 |
61 // Tells the controller to resume a pending login. | 62 // Tells the controller to resume a pending login. |
62 void ResumeLogin(); | 63 void ResumeLogin(); |
63 | 64 |
64 // Invoked when a kiosk app launch is started. | 65 // Invoked when a kiosk app launch is started. |
65 void OnKioskAppLaunchStarted(); | 66 void OnKioskAppLaunchStarted(); |
66 | 67 |
67 // Invoked when a kiosk app launch is failed. | 68 // Invoked when a kiosk app launch is failed. |
68 void OnKioskAppLaunchFailed(); | 69 void OnKioskAppLaunchFailed(); |
69 | 70 |
71 // Start the public session auto-login timer. | |
72 void StartPublicSessionAutoLoginTimer(); | |
73 | |
74 // Stop the public session auto-login timer when a login attempt begins. | |
75 void StopPublicSessionAutoLoginTimer(); | |
76 | |
70 // LoginDisplay::Delegate: implementation | 77 // LoginDisplay::Delegate: implementation |
71 virtual void CancelPasswordChangedFlow() OVERRIDE; | 78 virtual void CancelPasswordChangedFlow() OVERRIDE; |
72 virtual void CreateAccount() OVERRIDE; | 79 virtual void CreateAccount() OVERRIDE; |
73 virtual void CreateLocallyManagedUser(const string16& display_name, | 80 virtual void CreateLocallyManagedUser(const string16& display_name, |
74 const std::string& password) OVERRIDE; | 81 const std::string& password) OVERRIDE; |
75 virtual void CompleteLogin(const std::string& username, | 82 virtual void CompleteLogin(const std::string& username, |
76 const std::string& password) OVERRIDE; | 83 const std::string& password) OVERRIDE; |
77 virtual string16 GetConnectedNetworkName() OVERRIDE; | 84 virtual string16 GetConnectedNetworkName() OVERRIDE; |
78 virtual void Login(const std::string& username, | 85 virtual void Login(const std::string& username, |
79 const std::string& password) OVERRIDE; | 86 const std::string& password) OVERRIDE; |
80 virtual void MigrateUserData(const std::string& old_password) OVERRIDE; | 87 virtual void MigrateUserData(const std::string& old_password) OVERRIDE; |
81 virtual void LoginAsRetailModeUser() OVERRIDE; | 88 virtual void LoginAsRetailModeUser() OVERRIDE; |
82 virtual void LoginAsGuest() OVERRIDE; | 89 virtual void LoginAsGuest() OVERRIDE; |
83 virtual void LoginAsPublicAccount(const std::string& username) OVERRIDE; | 90 virtual void LoginAsPublicAccount(const std::string& username) OVERRIDE; |
91 virtual void OnSigninScreenReady() OVERRIDE; | |
84 virtual void OnUserSelected(const std::string& username) OVERRIDE; | 92 virtual void OnUserSelected(const std::string& username) OVERRIDE; |
85 virtual void OnStartEnterpriseEnrollment() OVERRIDE; | 93 virtual void OnStartEnterpriseEnrollment() OVERRIDE; |
86 virtual void OnStartDeviceReset() OVERRIDE; | 94 virtual void OnStartDeviceReset() OVERRIDE; |
95 virtual void ResetPublicSessionAutoLoginTimer() OVERRIDE; | |
87 virtual void ResyncUserData() OVERRIDE; | 96 virtual void ResyncUserData() OVERRIDE; |
88 virtual void SetDisplayEmail(const std::string& email) OVERRIDE; | 97 virtual void SetDisplayEmail(const std::string& email) OVERRIDE; |
89 virtual void ShowWrongHWIDScreen() OVERRIDE; | 98 virtual void ShowWrongHWIDScreen() OVERRIDE; |
90 virtual void Signout() OVERRIDE; | 99 virtual void Signout() OVERRIDE; |
91 | 100 |
92 // content::NotificationObserver implementation. | 101 // content::NotificationObserver implementation. |
93 virtual void Observe(int type, | 102 virtual void Observe(int type, |
94 const content::NotificationSource& source, | 103 const content::NotificationSource& source, |
95 const content::NotificationDetails& details) OVERRIDE; | 104 const content::NotificationDetails& details) OVERRIDE; |
96 | 105 |
97 // Set a delegate that we will pass LoginStatusConsumer events to. | 106 // Set a delegate that we will pass LoginStatusConsumer events to. |
98 // Used for testing. | 107 // Used for testing. |
99 void set_login_status_consumer(LoginStatusConsumer* consumer) { | 108 void set_login_status_consumer(LoginStatusConsumer* consumer) { |
100 login_status_consumer_ = consumer; | 109 login_status_consumer_ = consumer; |
101 } | 110 } |
102 | 111 |
103 // Returns the LoginDisplay created and owned by this controller. | 112 // Returns the LoginDisplay created and owned by this controller. |
104 // Used for testing. | 113 // Used for testing. |
105 LoginDisplay* login_display() { | 114 LoginDisplay* login_display() { |
106 return login_display_.get(); | 115 return login_display_.get(); |
107 } | 116 } |
108 | 117 |
109 // Returns the LoginDisplayHost for this controller. | 118 // Returns the LoginDisplayHost for this controller. |
110 LoginDisplayHost* login_display_host() { | 119 LoginDisplayHost* login_display_host() { |
111 return host_; | 120 return host_; |
112 } | 121 } |
113 | 122 |
114 private: | 123 private: |
115 friend class ExistingUserControllerTest; | 124 friend class ExistingUserControllerTest; |
125 friend class ExistingUserControllerPublicSessionTest; | |
116 friend class MockLoginPerformerDelegate; | 126 friend class MockLoginPerformerDelegate; |
117 | 127 |
128 // Retrieve public session auto-login policy and update the timer. | |
129 void ConfigurePublicSessionAutoLogin(); | |
130 | |
131 // Trigger public session auto-login. | |
132 void OnPublicSessionAutoLoginTimerFire(); | |
133 | |
118 // LoginPerformer::Delegate implementation: | 134 // LoginPerformer::Delegate implementation: |
119 virtual void OnLoginFailure(const LoginFailure& error) OVERRIDE; | 135 virtual void OnLoginFailure(const LoginFailure& error) OVERRIDE; |
120 virtual void OnLoginSuccess( | 136 virtual void OnLoginSuccess( |
121 const std::string& username, | 137 const std::string& username, |
122 const std::string& password, | 138 const std::string& password, |
123 bool pending_requests, | 139 bool pending_requests, |
124 bool using_oauth) OVERRIDE; | 140 bool using_oauth) OVERRIDE; |
125 virtual void OnOffTheRecordLoginSuccess() OVERRIDE; | 141 virtual void OnOffTheRecordLoginSuccess() OVERRIDE; |
126 virtual void OnPasswordChangeDetected() OVERRIDE; | 142 virtual void OnPasswordChangeDetected() OVERRIDE; |
127 virtual void WhiteListCheckFailed(const std::string& email) OVERRIDE; | 143 virtual void WhiteListCheckFailed(const std::string& email) OVERRIDE; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
188 std::string password, | 204 std::string password, |
189 LoginPerformer::AuthorizationMode auth_mode); | 205 LoginPerformer::AuthorizationMode auth_mode); |
190 | 206 |
191 void set_login_performer_delegate(LoginPerformer::Delegate* d) { | 207 void set_login_performer_delegate(LoginPerformer::Delegate* d) { |
192 login_performer_delegate_.reset(d); | 208 login_performer_delegate_.reset(d); |
193 } | 209 } |
194 | 210 |
195 // Updates the |login_display_| attached to this controller. | 211 // Updates the |login_display_| attached to this controller. |
196 void UpdateLoginDisplay(const UserList& users); | 212 void UpdateLoginDisplay(const UserList& users); |
197 | 213 |
214 // Accesses (and lazily constructs if necessary) the auto-login timer. | |
215 base::OneShotTimer<ExistingUserController>& auto_login_timer(); | |
bartfab (slow)
2013/02/28 10:21:33
All-lowercase should be used for the simplest of g
dconnelly
2013/02/28 12:52:56
Done.
| |
216 | |
217 // Public session auto-login timer. | |
218 scoped_ptr<base::OneShotTimer<ExistingUserController> > auto_login_timer_; | |
219 | |
220 // Public session auto-login timeout, in milliseconds. | |
221 int public_session_auto_login_delay_; | |
222 | |
223 // Username for public session auto-login. | |
224 std::string public_session_auto_login_username_; | |
225 | |
198 // Used to execute login operations. | 226 // Used to execute login operations. |
199 scoped_ptr<LoginPerformer> login_performer_; | 227 scoped_ptr<LoginPerformer> login_performer_; |
200 | 228 |
201 // Delegate for login performer to be overridden by tests. | 229 // Delegate for login performer to be overridden by tests. |
202 // |this| is used if |login_performer_delegate_| is NULL. | 230 // |this| is used if |login_performer_delegate_| is NULL. |
203 scoped_ptr<LoginPerformer::Delegate> login_performer_delegate_; | 231 scoped_ptr<LoginPerformer::Delegate> login_performer_delegate_; |
204 | 232 |
205 // Delegate to forward all login status events to. | 233 // Delegate to forward all login status events to. |
206 // Tests can use this to receive login status events. | 234 // Tests can use this to receive login status events. |
207 LoginStatusConsumer* login_status_consumer_; | 235 LoginStatusConsumer* login_status_consumer_; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
248 std::string online_succeeded_for_; | 276 std::string online_succeeded_for_; |
249 | 277 |
250 // True if password has been changed for user who is completing sign in. | 278 // True if password has been changed for user who is completing sign in. |
251 // Set in OnLoginSuccess. Before that use LoginPerformer::password_changed(). | 279 // Set in OnLoginSuccess. Before that use LoginPerformer::password_changed(). |
252 bool password_changed_; | 280 bool password_changed_; |
253 | 281 |
254 // True if auto-enrollment should be performed before starting the user's | 282 // True if auto-enrollment should be performed before starting the user's |
255 // session. | 283 // session. |
256 bool do_auto_enrollment_; | 284 bool do_auto_enrollment_; |
257 | 285 |
286 // Whether the sign-in UI is finished loading. | |
287 bool signin_screen_ready_; | |
288 | |
258 // The username used for auto-enrollment, if it was triggered. | 289 // The username used for auto-enrollment, if it was triggered. |
259 std::string auto_enrollment_username_; | 290 std::string auto_enrollment_username_; |
260 | 291 |
261 // Callback to invoke to resume login, after auto-enrollment has completed. | 292 // Callback to invoke to resume login, after auto-enrollment has completed. |
262 base::Closure resume_login_callback_; | 293 base::Closure resume_login_callback_; |
263 | 294 |
264 // Time when the signin screen was first displayed. Used to measure the time | 295 // Time when the signin screen was first displayed. Used to measure the time |
265 // from showing the screen until a successful login is performed. | 296 // from showing the screen until a successful login is performed. |
266 base::Time time_init_; | 297 base::Time time_init_; |
267 | 298 |
268 // Timer for the interval to wait for the reboot after TPM error UI was shown. | 299 // Timer for the interval to wait for the reboot after TPM error UI was shown. |
269 base::OneShotTimer<ExistingUserController> reboot_timer_; | 300 base::OneShotTimer<ExistingUserController> reboot_timer_; |
270 | 301 |
271 FRIEND_TEST_ALL_PREFIXES(ExistingUserControllerTest, ExistingUserLogin); | 302 FRIEND_TEST_ALL_PREFIXES(ExistingUserControllerTest, ExistingUserLogin); |
303 FRIEND_TEST_ALL_PREFIXES(ExistingUserControllerPublicSessionTest, | |
304 ConfigureAutoLogin); | |
305 FRIEND_TEST_ALL_PREFIXES(ExistingUserControllerPublicSessionTest, | |
306 UserActivityRestartsAutoLogin); | |
307 FRIEND_TEST_ALL_PREFIXES(ExistingUserControllerPublicSessionTest, | |
308 OnAutoLoginFire); | |
272 | 309 |
273 DISALLOW_COPY_AND_ASSIGN(ExistingUserController); | 310 DISALLOW_COPY_AND_ASSIGN(ExistingUserController); |
274 }; | 311 }; |
275 | 312 |
276 } // namespace chromeos | 313 } // namespace chromeos |
277 | 314 |
278 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_EXISTING_USER_CONTROLLER_H_ | 315 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_EXISTING_USER_CONTROLLER_H_ |
OLD | NEW |