| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/strings/string16.h" | 18 #include "base/strings/string16.h" |
| 19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 20 #include "base/timer/timer.h" | 20 #include "base/timer/timer.h" |
| 21 #include "chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_manager.h" |
| 21 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" | 22 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" |
| 22 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | 23 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
| 23 #include "chrome/browser/chromeos/login/signin/token_handle_util.h" | 24 #include "chrome/browser/chromeos/login/signin/token_handle_util.h" |
| 24 #include "chrome/browser/chromeos/login/ui/login_display.h" | 25 #include "chrome/browser/chromeos/login/ui/login_display.h" |
| 25 #include "chrome/browser/chromeos/settings/cros_settings.h" | 26 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 26 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 27 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| 27 #include "chromeos/login/auth/login_performer.h" | 28 #include "chromeos/login/auth/login_performer.h" |
| 28 #include "chromeos/login/auth/user_context.h" | 29 #include "chromeos/login/auth/user_context.h" |
| 29 #include "components/signin/core/account_id/account_id.h" | 30 #include "components/signin/core/account_id/account_id.h" |
| 30 #include "components/user_manager/user.h" | 31 #include "components/user_manager/user.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 48 class NetworkStateHelper; | 49 class NetworkStateHelper; |
| 49 } | 50 } |
| 50 | 51 |
| 51 // ExistingUserController is used to handle login when someone has | 52 // ExistingUserController is used to handle login when someone has |
| 52 // already logged into the machine. | 53 // already logged into the machine. |
| 53 // To use ExistingUserController create an instance of it and invoke Init. | 54 // To use ExistingUserController create an instance of it and invoke Init. |
| 54 // When Init is called it creates LoginDisplay instance which encapsulates | 55 // When Init is called it creates LoginDisplay instance which encapsulates |
| 55 // all login UI implementation. | 56 // all login UI implementation. |
| 56 // ExistingUserController maintains it's own life cycle and deletes itself when | 57 // ExistingUserController maintains it's own life cycle and deletes itself when |
| 57 // the user logs in (or chooses to see other settings). | 58 // the user logs in (or chooses to see other settings). |
| 58 class ExistingUserController : public LoginDisplay::Delegate, | 59 class ExistingUserController |
| 59 public content::NotificationObserver, | 60 : public LoginDisplay::Delegate, |
| 60 public LoginPerformer::Delegate, | 61 public content::NotificationObserver, |
| 61 public UserSessionManagerDelegate { | 62 public LoginPerformer::Delegate, |
| 63 public UserSessionManagerDelegate, |
| 64 public ArcKioskAppManager::ArcKioskAppManagerObserver { |
| 62 public: | 65 public: |
| 63 // All UI initialization is deferred till Init() call. | 66 // All UI initialization is deferred till Init() call. |
| 64 explicit ExistingUserController(LoginDisplayHost* host); | 67 explicit ExistingUserController(LoginDisplayHost* host); |
| 65 ~ExistingUserController() override; | 68 ~ExistingUserController() override; |
| 66 | 69 |
| 67 // Returns the current existing user controller if it has been created. | 70 // Returns the current existing user controller if it has been created. |
| 68 static ExistingUserController* current_controller() { | 71 static ExistingUserController* current_controller() { |
| 69 return current_controller_; | 72 return current_controller_; |
| 70 } | 73 } |
| 71 | 74 |
| 72 // Creates and shows login UI for known users. | 75 // Creates and shows login UI for known users. |
| 73 void Init(const user_manager::UserList& users); | 76 void Init(const user_manager::UserList& users); |
| 74 | 77 |
| 75 // Start the public session auto-login timer. | 78 // Start the auto-login timer. |
| 76 void StartPublicSessionAutoLoginTimer(); | 79 void StartAutoLoginTimer(); |
| 77 | 80 |
| 78 // Stop the public session auto-login timer when a login attempt begins. | 81 // Stop the auto-login timer when a login attempt begins. |
| 79 void StopPublicSessionAutoLoginTimer(); | 82 void StopAutoLoginTimer(); |
| 80 | 83 |
| 81 // LoginDisplay::Delegate: implementation | 84 // LoginDisplay::Delegate: implementation |
| 82 void CancelPasswordChangedFlow() override; | 85 void CancelPasswordChangedFlow() override; |
| 83 void CompleteLogin(const UserContext& user_context) override; | 86 void CompleteLogin(const UserContext& user_context) override; |
| 84 base::string16 GetConnectedNetworkName() override; | 87 base::string16 GetConnectedNetworkName() override; |
| 85 bool IsSigninInProgress() const override; | 88 bool IsSigninInProgress() const override; |
| 86 void Login(const UserContext& user_context, | 89 void Login(const UserContext& user_context, |
| 87 const SigninSpecifics& specifics) override; | 90 const SigninSpecifics& specifics) override; |
| 88 void MigrateUserData(const std::string& old_password) override; | 91 void MigrateUserData(const std::string& old_password) override; |
| 89 void OnSigninScreenReady() override; | 92 void OnSigninScreenReady() override; |
| 93 void OnGaiaScreenReady() override; |
| 90 void OnStartEnterpriseEnrollment() override; | 94 void OnStartEnterpriseEnrollment() override; |
| 91 void OnStartEnableDebuggingScreen() override; | 95 void OnStartEnableDebuggingScreen() override; |
| 92 void OnStartKioskEnableScreen() override; | 96 void OnStartKioskEnableScreen() override; |
| 93 void OnStartKioskAutolaunchScreen() override; | 97 void OnStartKioskAutolaunchScreen() override; |
| 94 void ResetPublicSessionAutoLoginTimer() override; | 98 void ResetAutoLoginTimer() override; |
| 95 void ResyncUserData() override; | 99 void ResyncUserData() override; |
| 96 void SetDisplayEmail(const std::string& email) override; | 100 void SetDisplayEmail(const std::string& email) override; |
| 97 void ShowWrongHWIDScreen() override; | 101 void ShowWrongHWIDScreen() override; |
| 98 void Signout() override; | 102 void Signout() override; |
| 99 bool IsUserWhitelisted(const AccountId& account_id) override; | 103 bool IsUserWhitelisted(const AccountId& account_id) override; |
| 100 | 104 |
| 101 // content::NotificationObserver implementation. | 105 // content::NotificationObserver implementation. |
| 102 void Observe(int type, | 106 void Observe(int type, |
| 103 const content::NotificationSource& source, | 107 const content::NotificationSource& source, |
| 104 const content::NotificationDetails& details) override; | 108 const content::NotificationDetails& details) override; |
| 105 | 109 |
| 110 // ArcKioskAppManager::ArcKioskAppManagerObserver overrides. |
| 111 void OnArcKioskAppsChanged() override; |
| 112 |
| 106 // Set a delegate that we will pass AuthStatusConsumer events to. | 113 // Set a delegate that we will pass AuthStatusConsumer events to. |
| 107 // Used for testing. | 114 // Used for testing. |
| 108 void set_login_status_consumer(AuthStatusConsumer* consumer) { | 115 void set_login_status_consumer(AuthStatusConsumer* consumer) { |
| 109 auth_status_consumer_ = consumer; | 116 auth_status_consumer_ = consumer; |
| 110 } | 117 } |
| 111 | 118 |
| 112 // Returns the LoginDisplay created and owned by this controller. | 119 // Returns the LoginDisplay created and owned by this controller. |
| 113 // Used for testing. | 120 // Used for testing. |
| 114 LoginDisplay* login_display() { | 121 LoginDisplay* login_display() { |
| 115 return login_display_.get(); | 122 return login_display_.get(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 131 private: | 138 private: |
| 132 friend class ExistingUserControllerTest; | 139 friend class ExistingUserControllerTest; |
| 133 friend class ExistingUserControllerAutoLoginTest; | 140 friend class ExistingUserControllerAutoLoginTest; |
| 134 friend class ExistingUserControllerPublicSessionTest; | 141 friend class ExistingUserControllerPublicSessionTest; |
| 135 friend class MockLoginPerformerDelegate; | 142 friend class MockLoginPerformerDelegate; |
| 136 | 143 |
| 137 void LoginAsGuest(); | 144 void LoginAsGuest(); |
| 138 void LoginAsPublicSession(const UserContext& user_context); | 145 void LoginAsPublicSession(const UserContext& user_context); |
| 139 void LoginAsKioskApp(const std::string& app_id, bool diagnostic_mode); | 146 void LoginAsKioskApp(const std::string& app_id, bool diagnostic_mode); |
| 140 void LoginAsArcKioskApp(const AccountId& account_id); | 147 void LoginAsArcKioskApp(const AccountId& account_id); |
| 141 | 148 // Retrieve public session and ARC kiosk auto-login policy and update the |
| 142 // Retrieve public session auto-login policy and update the timer. | 149 // timer. |
| 143 void ConfigurePublicSessionAutoLogin(); | 150 void ConfigureAutoLogin(); |
| 144 | 151 |
| 145 // Trigger public session auto-login. | 152 // Trigger public session auto-login. |
| 146 void OnPublicSessionAutoLoginTimerFire(); | 153 void OnPublicSessionAutoLoginTimerFire(); |
| 154 // Trigger ARC kiosk auto-login. |
| 155 void OnArcKioskAutoLoginTimerFire(); |
| 147 | 156 |
| 148 // LoginPerformer::Delegate implementation: | 157 // LoginPerformer::Delegate implementation: |
| 149 void OnAuthFailure(const AuthFailure& error) override; | 158 void OnAuthFailure(const AuthFailure& error) override; |
| 150 void OnAuthSuccess(const UserContext& user_context) override; | 159 void OnAuthSuccess(const UserContext& user_context) override; |
| 151 void OnOffTheRecordAuthSuccess() override; | 160 void OnOffTheRecordAuthSuccess() override; |
| 152 void OnPasswordChangeDetected() override; | 161 void OnPasswordChangeDetected() override; |
| 153 void WhiteListCheckFailed(const std::string& email) override; | 162 void WhiteListCheckFailed(const std::string& email) override; |
| 154 void PolicyLoadFailed() override; | 163 void PolicyLoadFailed() override; |
| 155 void SetAuthFlowOffline(bool offline) override; | 164 void SetAuthFlowOffline(bool offline) override; |
| 156 | 165 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 std::unique_ptr<base::ListValue> keyboard_layouts); | 226 std::unique_ptr<base::ListValue> keyboard_layouts); |
| 218 | 227 |
| 219 // Starts the actual login process for a public session. Invoked when all | 228 // Starts the actual login process for a public session. Invoked when all |
| 220 // preconditions have been verified. | 229 // preconditions have been verified. |
| 221 void LoginAsPublicSessionInternal(const UserContext& user_context); | 230 void LoginAsPublicSessionInternal(const UserContext& user_context); |
| 222 | 231 |
| 223 // Performs sets of actions right prior to login has been started. | 232 // Performs sets of actions right prior to login has been started. |
| 224 void PerformPreLoginActions(const UserContext& user_context); | 233 void PerformPreLoginActions(const UserContext& user_context); |
| 225 | 234 |
| 226 // Performs set of actions when login has been completed or has been | 235 // Performs set of actions when login has been completed or has been |
| 227 // cancelled. If |start_public_session_timer| is true than public session | 236 // cancelled. If |start_auto_login_timer| is true than |
| 228 // auto-login timer is started. | 237 // auto-login timer is started. |
| 229 void PerformLoginFinishedActions(bool start_public_session_timer); | 238 void PerformLoginFinishedActions(bool start_auto_login_timer); |
| 230 | 239 |
| 231 // Invokes |continuation| after verifying that the device is not disabled. | 240 // Invokes |continuation| after verifying that the device is not disabled. |
| 232 void ContinueLoginIfDeviceNotDisabled(const base::Closure& continuation); | 241 void ContinueLoginIfDeviceNotDisabled(const base::Closure& continuation); |
| 233 | 242 |
| 234 // Signs in as a new user. This is a continuation of CompleteLogin() that gets | 243 // Signs in as a new user. This is a continuation of CompleteLogin() that gets |
| 235 // invoked after it has been verified that the device is not disabled. | 244 // invoked after it has been verified that the device is not disabled. |
| 236 void DoCompleteLogin(const UserContext& user_context); | 245 void DoCompleteLogin(const UserContext& user_context); |
| 237 | 246 |
| 238 // Signs in as a known user. This is a continuation of Login() that gets | 247 // Signs in as a known user. This is a continuation of Login() that gets |
| 239 // invoked after it has been verified that the device is not disabled. | 248 // invoked after it has been verified that the device is not disabled. |
| 240 void DoLogin(const UserContext& user_context, | 249 void DoLogin(const UserContext& user_context, |
| 241 const SigninSpecifics& specifics); | 250 const SigninSpecifics& specifics); |
| 242 | 251 |
| 243 // Callback invoked when |bootstrap_user_context_initializer_| has finished. | 252 // Callback invoked when |bootstrap_user_context_initializer_| has finished. |
| 244 void OnBootstrapUserContextInitialized(bool success, | 253 void OnBootstrapUserContextInitialized(bool success, |
| 245 const UserContext& user_context); | 254 const UserContext& user_context); |
| 246 | 255 |
| 247 // Callback invoked when |oauth2_token_initializer_| has finished. | 256 // Callback invoked when |oauth2_token_initializer_| has finished. |
| 248 void OnOAuth2TokensFetched(bool success, const UserContext& user_context); | 257 void OnOAuth2TokensFetched(bool success, const UserContext& user_context); |
| 249 | 258 |
| 250 // Callback invoked when |token_handle_util_| finishes token check. | 259 // Callback invoked when |token_handle_util_| finishes token check. |
| 251 void OnTokenHandleChecked( | 260 void OnTokenHandleChecked( |
| 252 const AccountId&, | 261 const AccountId&, |
| 253 TokenHandleUtil::TokenHandleStatus token_handle_status); | 262 TokenHandleUtil::TokenHandleStatus token_handle_status); |
| 254 | 263 |
| 255 // Public session auto-login timer. | 264 // Public session auto-login timer. |
| 256 std::unique_ptr<base::OneShotTimer> auto_login_timer_; | 265 std::unique_ptr<base::OneShotTimer> auto_login_timer_; |
| 257 | 266 |
| 258 // Public session auto-login timeout, in milliseconds. | 267 // Auto-login timeout, in milliseconds. |
| 259 int public_session_auto_login_delay_; | 268 int auto_login_delay_; |
| 260 | 269 |
| 261 // AccountId for public session auto-login. | 270 // AccountId for public session auto-login. |
| 262 AccountId public_session_auto_login_account_id_ = EmptyAccountId(); | 271 AccountId public_session_auto_login_account_id_ = EmptyAccountId(); |
| 263 | 272 |
| 273 // AccountId for ARC kiosk auto-login. |
| 274 AccountId arc_kiosk_auto_login_account_id_ = EmptyAccountId(); |
| 275 |
| 264 // Used to execute login operations. | 276 // Used to execute login operations. |
| 265 std::unique_ptr<LoginPerformer> login_performer_; | 277 std::unique_ptr<LoginPerformer> login_performer_; |
| 266 | 278 |
| 267 // Delegate to forward all authentication status events to. | 279 // Delegate to forward all authentication status events to. |
| 268 // Tests can use this to receive authentication status events. | 280 // Tests can use this to receive authentication status events. |
| 269 AuthStatusConsumer* auth_status_consumer_ = nullptr; | 281 AuthStatusConsumer* auth_status_consumer_ = nullptr; |
| 270 | 282 |
| 271 // AccountId of the last login attempt. | 283 // AccountId of the last login attempt. |
| 272 AccountId last_login_attempt_account_id_ = EmptyAccountId(); | 284 AccountId last_login_attempt_account_id_ = EmptyAccountId(); |
| 273 | 285 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 302 | 314 |
| 303 // True if password has been changed for user who is completing sign in. | 315 // True if password has been changed for user who is completing sign in. |
| 304 // Set in OnLoginSuccess. Before that use LoginPerformer::password_changed(). | 316 // Set in OnLoginSuccess. Before that use LoginPerformer::password_changed(). |
| 305 bool password_changed_ = false; | 317 bool password_changed_ = false; |
| 306 | 318 |
| 307 // Set in OnLoginSuccess. Before that use LoginPerformer::auth_mode(). | 319 // Set in OnLoginSuccess. Before that use LoginPerformer::auth_mode(). |
| 308 // Initialized with AUTH_MODE_EXTENSION as more restricted mode. | 320 // Initialized with AUTH_MODE_EXTENSION as more restricted mode. |
| 309 LoginPerformer::AuthorizationMode auth_mode_ = | 321 LoginPerformer::AuthorizationMode auth_mode_ = |
| 310 LoginPerformer::AUTH_MODE_EXTENSION; | 322 LoginPerformer::AUTH_MODE_EXTENSION; |
| 311 | 323 |
| 312 // Whether the sign-in UI is finished loading. | 324 // When the sign-in or GAIA UI is finished loading |
| 313 bool signin_screen_ready_ = false; | 325 // public session or ARC kiosk are ready to auto-launch. |
| 326 bool auto_launch_ready_ = false; |
| 314 | 327 |
| 315 // Indicates use of local (not GAIA) authentication. | 328 // Indicates use of local (not GAIA) authentication. |
| 316 bool auth_flow_offline_ = false; | 329 bool auth_flow_offline_ = false; |
| 317 | 330 |
| 318 // Time when the signin screen was first displayed. Used to measure the time | 331 // Time when the signin screen was first displayed. Used to measure the time |
| 319 // from showing the screen until a successful login is performed. | 332 // from showing the screen until a successful login is performed. |
| 320 base::Time time_init_; | 333 base::Time time_init_; |
| 321 | 334 |
| 322 // Timer for the interval to wait for the reboot after TPM error UI was shown. | 335 // Timer for the interval to wait for the reboot after TPM error UI was shown. |
| 323 base::OneShotTimer reboot_timer_; | 336 base::OneShotTimer reboot_timer_; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 348 | 361 |
| 349 // Factory of callbacks. | 362 // Factory of callbacks. |
| 350 base::WeakPtrFactory<ExistingUserController> weak_factory_; | 363 base::WeakPtrFactory<ExistingUserController> weak_factory_; |
| 351 | 364 |
| 352 DISALLOW_COPY_AND_ASSIGN(ExistingUserController); | 365 DISALLOW_COPY_AND_ASSIGN(ExistingUserController); |
| 353 }; | 366 }; |
| 354 | 367 |
| 355 } // namespace chromeos | 368 } // namespace chromeos |
| 356 | 369 |
| 357 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_EXISTING_USER_CONTROLLER_H_ | 370 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_EXISTING_USER_CONTROLLER_H_ |
| OLD | NEW |