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

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: bartfab review comments; split out NotificationWatcher 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 13 matching lines...) Expand all
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
64 // LoginDisplay::Delegate: implementation 72 // LoginDisplay::Delegate: implementation
65 virtual void CancelPasswordChangedFlow() OVERRIDE; 73 virtual void CancelPasswordChangedFlow() OVERRIDE;
66 virtual void CreateAccount() OVERRIDE; 74 virtual void CreateAccount() OVERRIDE;
67 virtual void CreateLocallyManagedUser(const string16& display_name, 75 virtual void CreateLocallyManagedUser(const string16& display_name,
68 const std::string& password) OVERRIDE; 76 const std::string& password) OVERRIDE;
69 virtual void CompleteLogin(const std::string& username, 77 virtual void CompleteLogin(const std::string& username,
70 const std::string& password) OVERRIDE; 78 const std::string& password) OVERRIDE;
71 virtual string16 GetConnectedNetworkName() OVERRIDE; 79 virtual string16 GetConnectedNetworkName() OVERRIDE;
72 virtual void Login(const std::string& username, 80 virtual void Login(const std::string& username,
73 const std::string& password) OVERRIDE; 81 const std::string& password) OVERRIDE;
74 virtual void MigrateUserData(const std::string& old_password) OVERRIDE; 82 virtual void MigrateUserData(const std::string& old_password) OVERRIDE;
75 virtual void LoginAsRetailModeUser() OVERRIDE; 83 virtual void LoginAsRetailModeUser() OVERRIDE;
76 virtual void LoginAsGuest() OVERRIDE; 84 virtual void LoginAsGuest() OVERRIDE;
77 virtual void LoginAsPublicAccount(const std::string& username) OVERRIDE; 85 virtual void LoginAsPublicAccount(const std::string& username) OVERRIDE;
86 virtual void OnSigninScreenReady() OVERRIDE;
78 virtual void OnUserSelected(const std::string& username) OVERRIDE; 87 virtual void OnUserSelected(const std::string& username) OVERRIDE;
79 virtual void OnStartEnterpriseEnrollment() OVERRIDE; 88 virtual void OnStartEnterpriseEnrollment() OVERRIDE;
80 virtual void OnStartDeviceReset() OVERRIDE; 89 virtual void OnStartDeviceReset() OVERRIDE;
81 virtual void ResyncUserData() OVERRIDE; 90 virtual void ResyncUserData() OVERRIDE;
82 virtual void SetDisplayEmail(const std::string& email) OVERRIDE; 91 virtual void SetDisplayEmail(const std::string& email) OVERRIDE;
83 virtual void ShowWrongHWIDScreen() OVERRIDE; 92 virtual void ShowWrongHWIDScreen() OVERRIDE;
84 virtual void Signout() OVERRIDE; 93 virtual void Signout() OVERRIDE;
85 94
86 // content::NotificationObserver implementation. 95 // content::NotificationObserver implementation.
87 virtual void Observe(int type, 96 virtual void Observe(int type,
(...skipping 12 matching lines...) Expand all
100 return login_display_.get(); 109 return login_display_.get();
101 } 110 }
102 111
103 // Returns the LoginDisplayHost for this controller. 112 // Returns the LoginDisplayHost for this controller.
104 LoginDisplayHost* login_display_host() { 113 LoginDisplayHost* login_display_host() {
105 return host_; 114 return host_;
106 } 115 }
107 116
108 private: 117 private:
109 friend class ExistingUserControllerTest; 118 friend class ExistingUserControllerTest;
119 friend class ExistingUserControllerPublicSessionTest;
110 friend class MockLoginPerformerDelegate; 120 friend class MockLoginPerformerDelegate;
111 121
122 // Retrieve public session auto-login policy and update the timer.
123 void ConfigurePublicSessionAutoLogin();
124
125 // Trigger public session auto-login.
126 void OnPublicSessionAutoLoginTimerFire();
127
112 // LoginPerformer::Delegate implementation: 128 // LoginPerformer::Delegate implementation:
113 virtual void OnLoginFailure(const LoginFailure& error) OVERRIDE; 129 virtual void OnLoginFailure(const LoginFailure& error) OVERRIDE;
114 virtual void OnLoginSuccess( 130 virtual void OnLoginSuccess(
115 const std::string& username, 131 const std::string& username,
116 const std::string& password, 132 const std::string& password,
117 bool pending_requests, 133 bool pending_requests,
118 bool using_oauth) OVERRIDE; 134 bool using_oauth) OVERRIDE;
119 virtual void OnOffTheRecordLoginSuccess() OVERRIDE; 135 virtual void OnOffTheRecordLoginSuccess() OVERRIDE;
120 virtual void OnPasswordChangeDetected() OVERRIDE; 136 virtual void OnPasswordChangeDetected() OVERRIDE;
121 virtual void WhiteListCheckFailed(const std::string& email) OVERRIDE; 137 virtual void WhiteListCheckFailed(const std::string& email) OVERRIDE;
122 virtual void PolicyLoadFailed() OVERRIDE; 138 virtual void PolicyLoadFailed() OVERRIDE;
123 virtual void OnOnlineChecked( 139 virtual void OnOnlineChecked(
124 const std::string& username, bool success) OVERRIDE; 140 const std::string& username, bool success) OVERRIDE;
125 141
126 // LoginUtils::Delegate implementation: 142 // LoginUtils::Delegate implementation:
127 virtual void OnProfilePrepared(Profile* profile) OVERRIDE; 143 virtual void OnProfilePrepared(Profile* profile) OVERRIDE;
128 144
145 // UserActivityObserver::Observer implementation.
146 virtual void OnUserActivity() OVERRIDE;
147
129 // Starts WizardController with the specified screen. 148 // Starts WizardController with the specified screen.
130 void ActivateWizard(const std::string& screen_name); 149 void ActivateWizard(const std::string& screen_name);
131 150
132 // Returns corresponding native window. 151 // Returns corresponding native window.
133 gfx::NativeWindow GetNativeWindow() const; 152 gfx::NativeWindow GetNativeWindow() const;
134 153
135 // Adds first-time login URLs. 154 // Adds first-time login URLs.
136 void InitializeStartUrls() const; 155 void InitializeStartUrls() const;
137 156
138 // Shows "Release Notes"/"What's new"/Getting started guide on update. 157 // Shows "Release Notes"/"What's new"/Getting started guide on update.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 std::string password, 201 std::string password,
183 LoginPerformer::AuthorizationMode auth_mode); 202 LoginPerformer::AuthorizationMode auth_mode);
184 203
185 void set_login_performer_delegate(LoginPerformer::Delegate* d) { 204 void set_login_performer_delegate(LoginPerformer::Delegate* d) {
186 login_performer_delegate_.reset(d); 205 login_performer_delegate_.reset(d);
187 } 206 }
188 207
189 // Updates the |login_display_| attached to this controller. 208 // Updates the |login_display_| attached to this controller.
190 void UpdateLoginDisplay(const UserList& users); 209 void UpdateLoginDisplay(const UserList& users);
191 210
211 // Accesses (and lazily constructs if necessary) the auto-login timer.
212 base::OneShotTimer<ExistingUserController>& auto_login_timer();
213
214 // Public session auto-login timer.
215 scoped_ptr<base::OneShotTimer<ExistingUserController> > auto_login_timer_;
216
217 // Public session auto-login timeout, in milliseconds.
218 int public_session_auto_login_delay_;
219
220 // Username for public session auto-login.
221 std::string public_session_auto_login_username_;
222
192 // Used to execute login operations. 223 // Used to execute login operations.
193 scoped_ptr<LoginPerformer> login_performer_; 224 scoped_ptr<LoginPerformer> login_performer_;
194 225
195 // Delegate for login performer to be overridden by tests. 226 // Delegate for login performer to be overridden by tests.
196 // |this| is used if |login_performer_delegate_| is NULL. 227 // |this| is used if |login_performer_delegate_| is NULL.
197 scoped_ptr<LoginPerformer::Delegate> login_performer_delegate_; 228 scoped_ptr<LoginPerformer::Delegate> login_performer_delegate_;
198 229
199 // Delegate to forward all login status events to. 230 // Delegate to forward all login status events to.
200 // Tests can use this to receive login status events. 231 // Tests can use this to receive login status events.
201 LoginStatusConsumer* login_status_consumer_; 232 LoginStatusConsumer* login_status_consumer_;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 std::string online_succeeded_for_; 273 std::string online_succeeded_for_;
243 274
244 // True if password has been changed for user who is completing sign in. 275 // True if password has been changed for user who is completing sign in.
245 // Set in OnLoginSuccess. Before that use LoginPerformer::password_changed(). 276 // Set in OnLoginSuccess. Before that use LoginPerformer::password_changed().
246 bool password_changed_; 277 bool password_changed_;
247 278
248 // True if auto-enrollment should be performed before starting the user's 279 // True if auto-enrollment should be performed before starting the user's
249 // session. 280 // session.
250 bool do_auto_enrollment_; 281 bool do_auto_enrollment_;
251 282
283 // Whether the sign-in UI is finished loading.
284 bool signin_screen_ready_;
285
252 // The username used for auto-enrollment, if it was triggered. 286 // The username used for auto-enrollment, if it was triggered.
253 std::string auto_enrollment_username_; 287 std::string auto_enrollment_username_;
254 288
255 // Callback to invoke to resume login, after auto-enrollment has completed. 289 // Callback to invoke to resume login, after auto-enrollment has completed.
256 base::Closure resume_login_callback_; 290 base::Closure resume_login_callback_;
257 291
258 // Time when the signin screen was first displayed. Used to measure the time 292 // Time when the signin screen was first displayed. Used to measure the time
259 // from showing the screen until a successful login is performed. 293 // from showing the screen until a successful login is performed.
260 base::Time time_init_; 294 base::Time time_init_;
261 295
262 // Timer for the interval to wait for the reboot after TPM error UI was shown. 296 // Timer for the interval to wait for the reboot after TPM error UI was shown.
263 base::OneShotTimer<ExistingUserController> reboot_timer_; 297 base::OneShotTimer<ExistingUserController> reboot_timer_;
264 298
265 FRIEND_TEST_ALL_PREFIXES(ExistingUserControllerTest, ExistingUserLogin); 299 FRIEND_TEST_ALL_PREFIXES(ExistingUserControllerTest, ExistingUserLogin);
300 FRIEND_TEST_ALL_PREFIXES(ExistingUserControllerPublicSessionTest,
301 ConfigureAutoLogin);
302 FRIEND_TEST_ALL_PREFIXES(ExistingUserControllerPublicSessionTest,
303 UserActivityRestartsAutoLogin);
304 FRIEND_TEST_ALL_PREFIXES(ExistingUserControllerPublicSessionTest,
305 OnAutoLoginFire);
266 306
267 DISALLOW_COPY_AND_ASSIGN(ExistingUserController); 307 DISALLOW_COPY_AND_ASSIGN(ExistingUserController);
268 }; 308 };
269 309
270 } // namespace chromeos 310 } // namespace chromeos
271 311
272 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_EXISTING_USER_CONTROLLER_H_ 312 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_EXISTING_USER_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698