Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(567)

Side by Side Diff: chrome/browser/chromeos/login/existing_user_controller.h

Issue 12218078: Implement a policy to autologin a public account. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: reset timer on user activity, review comments Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 15 matching lines...) Expand all
35 // already logged into the machine. 36 // already logged into the machine.
36 // To use ExistingUserController create an instance of it and invoke Init. 37 // To use ExistingUserController create an instance of it and invoke Init.
37 // When Init is called it creates LoginDisplay instance which encapsulates 38 // When Init is called it creates LoginDisplay instance which encapsulates
38 // all login UI implementation. 39 // all login UI implementation.
39 // ExistingUserController maintains it's own life cycle and deletes itself when 40 // ExistingUserController maintains it's own life cycle and deletes itself when
40 // the user logs in (or chooses to see other settings). 41 // the user logs in (or chooses to see other settings).
41 class ExistingUserController : public LoginDisplay::Delegate, 42 class ExistingUserController : public LoginDisplay::Delegate,
42 public content::NotificationObserver, 43 public content::NotificationObserver,
43 public LoginPerformer::Delegate, 44 public LoginPerformer::Delegate,
44 public LoginUtils::Delegate, 45 public LoginUtils::Delegate,
45 public PasswordChangedView::Delegate { 46 public PasswordChangedView::Delegate,
47 public ash::UserActivityObserver {
46 public: 48 public:
47 // All UI initialization is deferred till Init() call. 49 // All UI initialization is deferred till Init() call.
48 explicit ExistingUserController(LoginDisplayHost* host); 50 explicit ExistingUserController(LoginDisplayHost* host);
49 virtual ~ExistingUserController(); 51 virtual ~ExistingUserController();
50 52
51 // Returns the current existing user controller if it has been created. 53 // Returns the current existing user controller if it has been created.
52 static ExistingUserController* current_controller() { 54 static ExistingUserController* current_controller() {
53 return current_controller_; 55 return current_controller_;
54 } 56 }
55 57
56 // Creates and shows login UI for known users. 58 // Creates and shows login UI for known users.
57 void Init(const UserList& users); 59 void Init(const UserList& users);
58 60
59 // Tells the controller to enter the Enterprise Enrollment screen when 61 // Tells the controller to enter the Enterprise Enrollment screen when
60 // appropriate. 62 // appropriate.
61 void DoAutoEnrollment(); 63 void DoAutoEnrollment();
62 64
63 // Tells the controller to resume a pending login. 65 // Tells the controller to resume a pending login.
64 void ResumeLogin(); 66 void ResumeLogin();
65 67
68 // Start the public session auto-login timer.
69 void StartPublicSessionAutoLoginTimer();
70
71 // Stop the public session auto-login timer when a login attempt begins.
72 void StopPublicSessionAutoLoginTimer();
73
74 // UserActivityObserver::Observer overrides:
bartfab (slow) 2013/02/11 17:11:21 nit: s/overrides/implementation/ or s/overrides//
dconnelly 2013/02/11 17:21:41 Done.
75 virtual void OnUserActivity() OVERRIDE;
76
66 // LoginDisplay::Delegate: implementation 77 // LoginDisplay::Delegate: implementation
67 virtual void CancelPasswordChangedFlow() OVERRIDE; 78 virtual void CancelPasswordChangedFlow() OVERRIDE;
68 virtual void CreateAccount() OVERRIDE; 79 virtual void CreateAccount() OVERRIDE;
69 virtual void CreateLocallyManagedUser(const string16& display_name, 80 virtual void CreateLocallyManagedUser(const string16& display_name,
70 const std::string& password) OVERRIDE; 81 const std::string& password) OVERRIDE;
71 virtual void CompleteLogin(const std::string& username, 82 virtual void CompleteLogin(const std::string& username,
72 const std::string& password) OVERRIDE; 83 const std::string& password) OVERRIDE;
73 virtual string16 GetConnectedNetworkName() OVERRIDE; 84 virtual string16 GetConnectedNetworkName() OVERRIDE;
74 virtual void Login(const std::string& username, 85 virtual void Login(const std::string& username,
75 const std::string& password) OVERRIDE; 86 const std::string& password) OVERRIDE;
76 virtual void MigrateUserData(const std::string& old_password) OVERRIDE; 87 virtual void MigrateUserData(const std::string& old_password) OVERRIDE;
77 virtual void LoginAsRetailModeUser() OVERRIDE; 88 virtual void LoginAsRetailModeUser() OVERRIDE;
78 virtual void LoginAsGuest() OVERRIDE; 89 virtual void LoginAsGuest() OVERRIDE;
79 virtual void LoginAsPublicAccount(const std::string& username) OVERRIDE; 90 virtual void LoginAsPublicAccount(const std::string& username) OVERRIDE;
91 virtual void OnSigninScreenReady() OVERRIDE;
80 virtual void OnUserSelected(const std::string& username) OVERRIDE; 92 virtual void OnUserSelected(const std::string& username) OVERRIDE;
81 virtual void OnStartEnterpriseEnrollment() OVERRIDE; 93 virtual void OnStartEnterpriseEnrollment() OVERRIDE;
82 virtual void OnStartDeviceReset() OVERRIDE; 94 virtual void OnStartDeviceReset() OVERRIDE;
83 virtual void ResyncUserData() OVERRIDE; 95 virtual void ResyncUserData() OVERRIDE;
84 virtual void SetDisplayEmail(const std::string& email) OVERRIDE; 96 virtual void SetDisplayEmail(const std::string& email) OVERRIDE;
85 virtual void Signout() OVERRIDE; 97 virtual void Signout() OVERRIDE;
86 98
87 // content::NotificationObserver implementation. 99 // content::NotificationObserver implementation.
88 virtual void Observe(int type, 100 virtual void Observe(int type,
89 const content::NotificationSource& source, 101 const content::NotificationSource& source,
(...skipping 13 matching lines...) Expand all
103 115
104 // Returns the LoginDisplayHost for this controller. 116 // Returns the LoginDisplayHost for this controller.
105 LoginDisplayHost* login_display_host() { 117 LoginDisplayHost* login_display_host() {
106 return host_; 118 return host_;
107 } 119 }
108 120
109 private: 121 private:
110 friend class ExistingUserControllerTest; 122 friend class ExistingUserControllerTest;
111 friend class MockLoginPerformerDelegate; 123 friend class MockLoginPerformerDelegate;
112 124
125 // Retrieve public session auto-login policy and update the timer.
126 void ConfigurePublicSessionAutoLogin();
127
113 // LoginPerformer::Delegate implementation: 128 // LoginPerformer::Delegate implementation:
114 virtual void OnLoginFailure(const LoginFailure& error) OVERRIDE; 129 virtual void OnLoginFailure(const LoginFailure& error) OVERRIDE;
115 virtual void OnLoginSuccess( 130 virtual void OnLoginSuccess(
116 const std::string& username, 131 const std::string& username,
117 const std::string& password, 132 const std::string& password,
118 bool pending_requests, 133 bool pending_requests,
119 bool using_oauth) OVERRIDE; 134 bool using_oauth) OVERRIDE;
120 virtual void OnOffTheRecordLoginSuccess() OVERRIDE; 135 virtual void OnOffTheRecordLoginSuccess() OVERRIDE;
121 virtual void OnPasswordChangeDetected() OVERRIDE; 136 virtual void OnPasswordChangeDetected() OVERRIDE;
122 virtual void WhiteListCheckFailed(const std::string& email) OVERRIDE; 137 virtual void WhiteListCheckFailed(const std::string& email) OVERRIDE;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 std::string password, 202 std::string password,
188 LoginPerformer::AuthorizationMode auth_mode); 203 LoginPerformer::AuthorizationMode auth_mode);
189 204
190 void set_login_performer_delegate(LoginPerformer::Delegate* d) { 205 void set_login_performer_delegate(LoginPerformer::Delegate* d) {
191 login_performer_delegate_.reset(d); 206 login_performer_delegate_.reset(d);
192 } 207 }
193 208
194 // Updates the |login_display_| attached to this controller. 209 // Updates the |login_display_| attached to this controller.
195 void UpdateLoginDisplay(const UserList& users); 210 void UpdateLoginDisplay(const UserList& users);
196 211
212 // Public session auto-login timer.
213 base::OneShotTimer<ExistingUserController> auto_login_timer_;
214
215 // Public session auto-login timeout, in milliseconds.
216 int public_session_auto_login_timer_;
bartfab (slow) 2013/02/11 17:11:21 nit: Calling this "timer" is not really accurate.
dconnelly 2013/02/11 17:21:41 Done.
217
218 // Username for public session auto-login.
219 std::string public_session_auto_login_username_;
bartfab (slow) 2013/02/11 17:11:21 I think in the case of device local accounts (aka
220
197 // Used to execute login operations. 221 // Used to execute login operations.
198 scoped_ptr<LoginPerformer> login_performer_; 222 scoped_ptr<LoginPerformer> login_performer_;
199 223
200 // Delegate for login performer to be overridden by tests. 224 // Delegate for login performer to be overridden by tests.
201 // |this| is used if |login_performer_delegate_| is NULL. 225 // |this| is used if |login_performer_delegate_| is NULL.
202 scoped_ptr<LoginPerformer::Delegate> login_performer_delegate_; 226 scoped_ptr<LoginPerformer::Delegate> login_performer_delegate_;
203 227
204 // Delegate to forward all login status events to. 228 // Delegate to forward all login status events to.
205 // Tests can use this to receive login status events. 229 // Tests can use this to receive login status events.
206 LoginStatusConsumer* login_status_consumer_; 230 LoginStatusConsumer* login_status_consumer_;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 std::string online_succeeded_for_; 274 std::string online_succeeded_for_;
251 275
252 // True if password has been changed for user who is completing sign in. 276 // True if password has been changed for user who is completing sign in.
253 // Set in OnLoginSuccess. Before that use LoginPerformer::password_changed(). 277 // Set in OnLoginSuccess. Before that use LoginPerformer::password_changed().
254 bool password_changed_; 278 bool password_changed_;
255 279
256 // True if auto-enrollment should be performed before starting the user's 280 // True if auto-enrollment should be performed before starting the user's
257 // session. 281 // session.
258 bool do_auto_enrollment_; 282 bool do_auto_enrollment_;
259 283
284 // Whether the sign-in UI is finished loading.
285 bool signin_screen_ready_;
286
260 // The username used for auto-enrollment, if it was triggered. 287 // The username used for auto-enrollment, if it was triggered.
261 std::string auto_enrollment_username_; 288 std::string auto_enrollment_username_;
262 289
263 // Callback to invoke to resume login, after auto-enrollment has completed. 290 // Callback to invoke to resume login, after auto-enrollment has completed.
264 base::Closure resume_login_callback_; 291 base::Closure resume_login_callback_;
265 292
266 // Time when the signin screen was first displayed. Used to measure the time 293 // Time when the signin screen was first displayed. Used to measure the time
267 // from showing the screen until a successful login is performed. 294 // from showing the screen until a successful login is performed.
268 base::Time time_init_; 295 base::Time time_init_;
269 296
270 // Timer for the interval to wait for the reboot after TPM error UI was shown. 297 // Timer for the interval to wait for the reboot after TPM error UI was shown.
271 base::OneShotTimer<ExistingUserController> reboot_timer_; 298 base::OneShotTimer<ExistingUserController> reboot_timer_;
272 299
273 FRIEND_TEST_ALL_PREFIXES(ExistingUserControllerTest, ExistingUserLogin); 300 FRIEND_TEST_ALL_PREFIXES(ExistingUserControllerTest, ExistingUserLogin);
274 301
275 DISALLOW_COPY_AND_ASSIGN(ExistingUserController); 302 DISALLOW_COPY_AND_ASSIGN(ExistingUserController);
276 }; 303 };
277 304
278 } // namespace chromeos 305 } // namespace chromeos
279 306
280 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_EXISTING_USER_CONTROLLER_H_ 307 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_EXISTING_USER_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698