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" | |
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 13 matching lines...) Loading... | |
33 // ExistingUserController is used to handle login when someone has | 34 // ExistingUserController is used to handle login when someone has |
34 // already logged into the machine. | 35 // already logged into the machine. |
35 // To use ExistingUserController create an instance of it and invoke Init. | 36 // To use ExistingUserController create an instance of it and invoke Init. |
36 // When Init is called it creates LoginDisplay instance which encapsulates | 37 // When Init is called it creates LoginDisplay instance which encapsulates |
37 // all login UI implementation. | 38 // all login UI implementation. |
38 // ExistingUserController maintains it's own life cycle and deletes itself when | 39 // ExistingUserController maintains it's own life cycle and deletes itself when |
39 // the user logs in (or chooses to see other settings). | 40 // the user logs in (or chooses to see other settings). |
40 class ExistingUserController : public LoginDisplay::Delegate, | 41 class ExistingUserController : public LoginDisplay::Delegate, |
41 public content::NotificationObserver, | 42 public content::NotificationObserver, |
42 public LoginPerformer::Delegate, | 43 public LoginPerformer::Delegate, |
43 public LoginUtils::Delegate { | 44 public LoginUtils::Delegate, |
45 public ash::UserActivityObserver { | |
44 public: | 46 public: |
45 // All UI initialization is deferred till Init() call. | 47 // All UI initialization is deferred till Init() call. |
46 explicit ExistingUserController(LoginDisplayHost* host); | 48 explicit ExistingUserController(LoginDisplayHost* host); |
47 virtual ~ExistingUserController(); | 49 virtual ~ExistingUserController(); |
48 | 50 |
49 // Returns the current existing user controller if it has been created. | 51 // Returns the current existing user controller if it has been created. |
50 static ExistingUserController* current_controller() { | 52 static ExistingUserController* current_controller() { |
51 return current_controller_; | 53 return current_controller_; |
52 } | 54 } |
53 | 55 |
54 // Creates and shows login UI for known users. | 56 // Creates and shows login UI for known users. |
55 void Init(const UserList& users); | 57 void Init(const UserList& users); |
56 | 58 |
57 // Tells the controller to enter the Enterprise Enrollment screen when | 59 // Tells the controller to enter the Enterprise Enrollment screen when |
58 // appropriate. | 60 // appropriate. |
59 void DoAutoEnrollment(); | 61 void DoAutoEnrollment(); |
60 | 62 |
61 // Tells the controller to resume a pending login. | 63 // Tells the controller to resume a pending login. |
62 void ResumeLogin(); | 64 void ResumeLogin(); |
63 | 65 |
66 // Start the public session auto-login timer. | |
67 void StartPublicSessionAutoLoginTimer(); | |
68 | |
69 // Stop the public session auto-login timer when a login attempt begins. | |
70 void StopPublicSessionAutoLoginTimer(); | |
71 | |
72 // UserActivityObserver::Observer implementation. | |
bartfab (slow)
2013/02/25 16:51:23
The overrides should follow the order in which the
dconnelly
2013/02/26 18:04:15
Done.
| |
73 virtual void OnUserActivity() OVERRIDE; | |
74 | |
64 // LoginDisplay::Delegate: implementation | 75 // LoginDisplay::Delegate: implementation |
65 virtual void CancelPasswordChangedFlow() OVERRIDE; | 76 virtual void CancelPasswordChangedFlow() OVERRIDE; |
66 virtual void CreateAccount() OVERRIDE; | 77 virtual void CreateAccount() OVERRIDE; |
67 virtual void CreateLocallyManagedUser(const string16& display_name, | 78 virtual void CreateLocallyManagedUser(const string16& display_name, |
68 const std::string& password) OVERRIDE; | 79 const std::string& password) OVERRIDE; |
69 virtual void CompleteLogin(const std::string& username, | 80 virtual void CompleteLogin(const std::string& username, |
70 const std::string& password) OVERRIDE; | 81 const std::string& password) OVERRIDE; |
71 virtual string16 GetConnectedNetworkName() OVERRIDE; | 82 virtual string16 GetConnectedNetworkName() OVERRIDE; |
72 virtual void Login(const std::string& username, | 83 virtual void Login(const std::string& username, |
73 const std::string& password) OVERRIDE; | 84 const std::string& password) OVERRIDE; |
74 virtual void MigrateUserData(const std::string& old_password) OVERRIDE; | 85 virtual void MigrateUserData(const std::string& old_password) OVERRIDE; |
75 virtual void LoginAsRetailModeUser() OVERRIDE; | 86 virtual void LoginAsRetailModeUser() OVERRIDE; |
76 virtual void LoginAsGuest() OVERRIDE; | 87 virtual void LoginAsGuest() OVERRIDE; |
77 virtual void LoginAsPublicAccount(const std::string& username) OVERRIDE; | 88 virtual void LoginAsPublicAccount(const std::string& username) OVERRIDE; |
89 virtual void OnSigninScreenReady() OVERRIDE; | |
78 virtual void OnUserSelected(const std::string& username) OVERRIDE; | 90 virtual void OnUserSelected(const std::string& username) OVERRIDE; |
79 virtual void OnStartEnterpriseEnrollment() OVERRIDE; | 91 virtual void OnStartEnterpriseEnrollment() OVERRIDE; |
80 virtual void OnStartDeviceReset() OVERRIDE; | 92 virtual void OnStartDeviceReset() OVERRIDE; |
81 virtual void ResyncUserData() OVERRIDE; | 93 virtual void ResyncUserData() OVERRIDE; |
82 virtual void SetDisplayEmail(const std::string& email) OVERRIDE; | 94 virtual void SetDisplayEmail(const std::string& email) OVERRIDE; |
83 virtual void ShowWrongHWIDScreen() OVERRIDE; | 95 virtual void ShowWrongHWIDScreen() OVERRIDE; |
84 virtual void Signout() OVERRIDE; | 96 virtual void Signout() OVERRIDE; |
85 | 97 |
86 // content::NotificationObserver implementation. | 98 // content::NotificationObserver implementation. |
87 virtual void Observe(int type, | 99 virtual void Observe(int type, |
(...skipping 12 matching lines...) Loading... | |
100 return login_display_.get(); | 112 return login_display_.get(); |
101 } | 113 } |
102 | 114 |
103 // Returns the LoginDisplayHost for this controller. | 115 // Returns the LoginDisplayHost for this controller. |
104 LoginDisplayHost* login_display_host() { | 116 LoginDisplayHost* login_display_host() { |
105 return host_; | 117 return host_; |
106 } | 118 } |
107 | 119 |
108 private: | 120 private: |
109 friend class ExistingUserControllerTest; | 121 friend class ExistingUserControllerTest; |
122 friend class ExistingUserControllerAutoLoginUnitTests; | |
123 friend class ExistingUserControllerAutoLoginIntegrationTests; | |
110 friend class MockLoginPerformerDelegate; | 124 friend class MockLoginPerformerDelegate; |
111 | 125 |
126 // Retrieve public session auto-login policy and update the timer. | |
127 void ConfigurePublicSessionAutoLogin(); | |
128 | |
129 // Trigger public session auto-login. | |
130 void OnPublicSessionAutoLoginTimerFire(); | |
131 | |
112 // LoginPerformer::Delegate implementation: | 132 // LoginPerformer::Delegate implementation: |
113 virtual void OnLoginFailure(const LoginFailure& error) OVERRIDE; | 133 virtual void OnLoginFailure(const LoginFailure& error) OVERRIDE; |
114 virtual void OnLoginSuccess( | 134 virtual void OnLoginSuccess( |
115 const std::string& username, | 135 const std::string& username, |
116 const std::string& password, | 136 const std::string& password, |
117 bool pending_requests, | 137 bool pending_requests, |
118 bool using_oauth) OVERRIDE; | 138 bool using_oauth) OVERRIDE; |
119 virtual void OnOffTheRecordLoginSuccess() OVERRIDE; | 139 virtual void OnOffTheRecordLoginSuccess() OVERRIDE; |
120 virtual void OnPasswordChangeDetected() OVERRIDE; | 140 virtual void OnPasswordChangeDetected() OVERRIDE; |
121 virtual void WhiteListCheckFailed(const std::string& email) OVERRIDE; | 141 virtual void WhiteListCheckFailed(const std::string& email) OVERRIDE; |
(...skipping 60 matching lines...) Loading... | |
182 std::string password, | 202 std::string password, |
183 LoginPerformer::AuthorizationMode auth_mode); | 203 LoginPerformer::AuthorizationMode auth_mode); |
184 | 204 |
185 void set_login_performer_delegate(LoginPerformer::Delegate* d) { | 205 void set_login_performer_delegate(LoginPerformer::Delegate* d) { |
186 login_performer_delegate_.reset(d); | 206 login_performer_delegate_.reset(d); |
187 } | 207 } |
188 | 208 |
189 // Updates the |login_display_| attached to this controller. | 209 // Updates the |login_display_| attached to this controller. |
190 void UpdateLoginDisplay(const UserList& users); | 210 void UpdateLoginDisplay(const UserList& users); |
191 | 211 |
212 // Public session auto-login timer. | |
213 base::OneShotTimer<ExistingUserController> auto_login_timer_; | |
bartfab (slow)
2013/02/25 16:51:23
When I was adding the session length limiter, ther
dconnelly
2013/02/26 18:04:15
Done.
| |
214 | |
215 // Public session auto-login timeout, in milliseconds. | |
216 int public_session_auto_login_delay_; | |
217 | |
218 // Username for public session auto-login. | |
219 std::string public_session_auto_login_username_; | |
220 | |
192 // Used to execute login operations. | 221 // Used to execute login operations. |
193 scoped_ptr<LoginPerformer> login_performer_; | 222 scoped_ptr<LoginPerformer> login_performer_; |
194 | 223 |
195 // Delegate for login performer to be overridden by tests. | 224 // Delegate for login performer to be overridden by tests. |
196 // |this| is used if |login_performer_delegate_| is NULL. | 225 // |this| is used if |login_performer_delegate_| is NULL. |
197 scoped_ptr<LoginPerformer::Delegate> login_performer_delegate_; | 226 scoped_ptr<LoginPerformer::Delegate> login_performer_delegate_; |
198 | 227 |
199 // Delegate to forward all login status events to. | 228 // Delegate to forward all login status events to. |
200 // Tests can use this to receive login status events. | 229 // Tests can use this to receive login status events. |
201 LoginStatusConsumer* login_status_consumer_; | 230 LoginStatusConsumer* login_status_consumer_; |
(...skipping 40 matching lines...) Loading... | |
242 std::string online_succeeded_for_; | 271 std::string online_succeeded_for_; |
243 | 272 |
244 // True if password has been changed for user who is completing sign in. | 273 // True if password has been changed for user who is completing sign in. |
245 // Set in OnLoginSuccess. Before that use LoginPerformer::password_changed(). | 274 // Set in OnLoginSuccess. Before that use LoginPerformer::password_changed(). |
246 bool password_changed_; | 275 bool password_changed_; |
247 | 276 |
248 // True if auto-enrollment should be performed before starting the user's | 277 // True if auto-enrollment should be performed before starting the user's |
249 // session. | 278 // session. |
250 bool do_auto_enrollment_; | 279 bool do_auto_enrollment_; |
251 | 280 |
281 // Whether the sign-in UI is finished loading. | |
282 bool signin_screen_ready_; | |
283 | |
252 // The username used for auto-enrollment, if it was triggered. | 284 // The username used for auto-enrollment, if it was triggered. |
253 std::string auto_enrollment_username_; | 285 std::string auto_enrollment_username_; |
254 | 286 |
255 // Callback to invoke to resume login, after auto-enrollment has completed. | 287 // Callback to invoke to resume login, after auto-enrollment has completed. |
256 base::Closure resume_login_callback_; | 288 base::Closure resume_login_callback_; |
257 | 289 |
258 // Time when the signin screen was first displayed. Used to measure the time | 290 // Time when the signin screen was first displayed. Used to measure the time |
259 // from showing the screen until a successful login is performed. | 291 // from showing the screen until a successful login is performed. |
260 base::Time time_init_; | 292 base::Time time_init_; |
261 | 293 |
262 // Timer for the interval to wait for the reboot after TPM error UI was shown. | 294 // Timer for the interval to wait for the reboot after TPM error UI was shown. |
263 base::OneShotTimer<ExistingUserController> reboot_timer_; | 295 base::OneShotTimer<ExistingUserController> reboot_timer_; |
264 | 296 |
265 FRIEND_TEST_ALL_PREFIXES(ExistingUserControllerTest, ExistingUserLogin); | 297 FRIEND_TEST_ALL_PREFIXES(ExistingUserControllerTest, ExistingUserLogin); |
298 FRIEND_TEST_ALL_PREFIXES(ExistingUserControllerPublicSessionTest, | |
bartfab (slow)
2013/02/25 16:51:23
Since you already added the base classes of your t
dconnelly
2013/02/26 18:04:15
I tried that, it doesn't work. From https://code.
bartfab (slow)
2013/02/28 10:21:33
Yes. You need to implement the accesses to the Exi
| |
299 ConfigureAutoLogin); | |
300 FRIEND_TEST_ALL_PREFIXES(ExistingUserControllerPublicSessionTest, | |
301 OnAutoLoginFire); | |
266 | 302 |
267 DISALLOW_COPY_AND_ASSIGN(ExistingUserController); | 303 DISALLOW_COPY_AND_ASSIGN(ExistingUserController); |
268 }; | 304 }; |
269 | 305 |
270 } // namespace chromeos | 306 } // namespace chromeos |
271 | 307 |
272 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_EXISTING_USER_CONTROLLER_H_ | 308 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_EXISTING_USER_CONTROLLER_H_ |
OLD | NEW |