Chromium Code Reviews| 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 15 matching lines...) Expand all Loading... | |
| 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 implementation | |
|
bartfab (slow)
2013/02/11 17:30:27
Nit: Colon at the end of the line.
dconnelly
2013/02/12 12:19: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 Loading... | |
| 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 Loading... | |
| 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_delay_; | |
| 217 | |
| 218 // Username for public session auto-login. | |
| 219 std::string public_session_auto_login_username_; | |
| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 247 std::string online_succeeded_for_; | 271 std::string online_succeeded_for_; |
| 248 | 272 |
| 249 // 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. |
| 250 // Set in OnLoginSuccess. Before that use LoginPerformer::password_changed(). | 274 // Set in OnLoginSuccess. Before that use LoginPerformer::password_changed(). |
| 251 bool password_changed_; | 275 bool password_changed_; |
| 252 | 276 |
| 253 // 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 |
| 254 // session. | 278 // session. |
| 255 bool do_auto_enrollment_; | 279 bool do_auto_enrollment_; |
| 256 | 280 |
| 281 // Whether the sign-in UI is finished loading. | |
| 282 bool signin_screen_ready_; | |
| 283 | |
| 257 // The username used for auto-enrollment, if it was triggered. | 284 // The username used for auto-enrollment, if it was triggered. |
| 258 std::string auto_enrollment_username_; | 285 std::string auto_enrollment_username_; |
| 259 | 286 |
| 260 // Callback to invoke to resume login, after auto-enrollment has completed. | 287 // Callback to invoke to resume login, after auto-enrollment has completed. |
| 261 base::Closure resume_login_callback_; | 288 base::Closure resume_login_callback_; |
| 262 | 289 |
| 263 // 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 |
| 264 // from showing the screen until a successful login is performed. | 291 // from showing the screen until a successful login is performed. |
| 265 base::Time time_init_; | 292 base::Time time_init_; |
| 266 | 293 |
| 267 // 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. |
| 268 base::OneShotTimer<ExistingUserController> reboot_timer_; | 295 base::OneShotTimer<ExistingUserController> reboot_timer_; |
| 269 | 296 |
| 270 FRIEND_TEST_ALL_PREFIXES(ExistingUserControllerTest, ExistingUserLogin); | 297 FRIEND_TEST_ALL_PREFIXES(ExistingUserControllerTest, ExistingUserLogin); |
| 271 | 298 |
| 272 DISALLOW_COPY_AND_ASSIGN(ExistingUserController); | 299 DISALLOW_COPY_AND_ASSIGN(ExistingUserController); |
| 273 }; | 300 }; |
| 274 | 301 |
| 275 } // namespace chromeos | 302 } // namespace chromeos |
| 276 | 303 |
| 277 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_EXISTING_USER_CONTROLLER_H_ | 304 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_EXISTING_USER_CONTROLLER_H_ |
| OLD | NEW |