| 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; |
| 90 void OnStartEnterpriseEnrollment() override; | 93 void OnStartEnterpriseEnrollment() override; |
| 91 void OnStartEnableDebuggingScreen() override; | 94 void OnStartEnableDebuggingScreen() override; |
| 92 void OnStartKioskEnableScreen() override; | 95 void OnStartKioskEnableScreen() override; |
| 93 void OnStartKioskAutolaunchScreen() override; | 96 void OnStartKioskAutolaunchScreen() override; |
| 94 void ResetPublicSessionAutoLoginTimer() override; | 97 void ResetPublicSessionAutoLoginTimer() override; |
| 95 void ResyncUserData() override; | 98 void ResyncUserData() override; |
| 96 void SetDisplayEmail(const std::string& email) override; | 99 void SetDisplayEmail(const std::string& email) override; |
| 97 void ShowWrongHWIDScreen() override; | 100 void ShowWrongHWIDScreen() override; |
| 98 void Signout() override; | 101 void Signout() override; |
| 99 bool IsUserWhitelisted(const AccountId& account_id) override; | 102 bool IsUserWhitelisted(const AccountId& account_id) override; |
| 100 | 103 |
| 101 // content::NotificationObserver implementation. | 104 // content::NotificationObserver implementation. |
| 102 void Observe(int type, | 105 void Observe(int type, |
| 103 const content::NotificationSource& source, | 106 const content::NotificationSource& source, |
| 104 const content::NotificationDetails& details) override; | 107 const content::NotificationDetails& details) override; |
| 105 | 108 |
| 109 // ArcKioskAppManager::ArcKioskAppManagerObserver overrides. |
| 110 void OnArcKioskAppsChanged() override; |
| 111 |
| 106 // Set a delegate that we will pass AuthStatusConsumer events to. | 112 // Set a delegate that we will pass AuthStatusConsumer events to. |
| 107 // Used for testing. | 113 // Used for testing. |
| 108 void set_login_status_consumer(AuthStatusConsumer* consumer) { | 114 void set_login_status_consumer(AuthStatusConsumer* consumer) { |
| 109 auth_status_consumer_ = consumer; | 115 auth_status_consumer_ = consumer; |
| 110 } | 116 } |
| 111 | 117 |
| 112 // Returns the LoginDisplay created and owned by this controller. | 118 // Returns the LoginDisplay created and owned by this controller. |
| 113 // Used for testing. | 119 // Used for testing. |
| 114 LoginDisplay* login_display() { | 120 LoginDisplay* login_display() { |
| 115 return login_display_.get(); | 121 return login_display_.get(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 131 private: | 137 private: |
| 132 friend class ExistingUserControllerTest; | 138 friend class ExistingUserControllerTest; |
| 133 friend class ExistingUserControllerAutoLoginTest; | 139 friend class ExistingUserControllerAutoLoginTest; |
| 134 friend class ExistingUserControllerPublicSessionTest; | 140 friend class ExistingUserControllerPublicSessionTest; |
| 135 friend class MockLoginPerformerDelegate; | 141 friend class MockLoginPerformerDelegate; |
| 136 | 142 |
| 137 void LoginAsGuest(); | 143 void LoginAsGuest(); |
| 138 void LoginAsPublicSession(const UserContext& user_context); | 144 void LoginAsPublicSession(const UserContext& user_context); |
| 139 void LoginAsKioskApp(const std::string& app_id, bool diagnostic_mode); | 145 void LoginAsKioskApp(const std::string& app_id, bool diagnostic_mode); |
| 140 void LoginAsArcKioskApp(const AccountId& account_id); | 146 void LoginAsArcKioskApp(const AccountId& account_id); |
| 141 | 147 // Retrieve public session and ARC kiosk auto-login policy and update the |
| 142 // Retrieve public session auto-login policy and update the timer. | 148 // timer. |
| 143 void ConfigurePublicSessionAutoLogin(); | 149 void ConfigureAutoLogin(); |
| 144 | 150 |
| 145 // Trigger public session auto-login. | 151 // Trigger public session auto-login. |
| 146 void OnPublicSessionAutoLoginTimerFire(); | 152 void OnPublicSessionAutoLoginTimerFire(); |
| 153 // Trigger ARC kiosk auto-login. |
| 154 void OnArcKioskAutoLoginTimerFire(); |
| 147 | 155 |
| 148 // LoginPerformer::Delegate implementation: | 156 // LoginPerformer::Delegate implementation: |
| 149 void OnAuthFailure(const AuthFailure& error) override; | 157 void OnAuthFailure(const AuthFailure& error) override; |
| 150 void OnAuthSuccess(const UserContext& user_context) override; | 158 void OnAuthSuccess(const UserContext& user_context) override; |
| 151 void OnOffTheRecordAuthSuccess() override; | 159 void OnOffTheRecordAuthSuccess() override; |
| 152 void OnPasswordChangeDetected() override; | 160 void OnPasswordChangeDetected() override; |
| 153 void WhiteListCheckFailed(const std::string& email) override; | 161 void WhiteListCheckFailed(const std::string& email) override; |
| 154 void PolicyLoadFailed() override; | 162 void PolicyLoadFailed() override; |
| 155 void SetAuthFlowOffline(bool offline) override; | 163 void SetAuthFlowOffline(bool offline) override; |
| 156 | 164 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 void OnOAuth2TokensFetched(bool success, const UserContext& user_context); | 256 void OnOAuth2TokensFetched(bool success, const UserContext& user_context); |
| 249 | 257 |
| 250 // Callback invoked when |token_handle_util_| finishes token check. | 258 // Callback invoked when |token_handle_util_| finishes token check. |
| 251 void OnTokenHandleChecked( | 259 void OnTokenHandleChecked( |
| 252 const AccountId&, | 260 const AccountId&, |
| 253 TokenHandleUtil::TokenHandleStatus token_handle_status); | 261 TokenHandleUtil::TokenHandleStatus token_handle_status); |
| 254 | 262 |
| 255 // Public session auto-login timer. | 263 // Public session auto-login timer. |
| 256 std::unique_ptr<base::OneShotTimer> auto_login_timer_; | 264 std::unique_ptr<base::OneShotTimer> auto_login_timer_; |
| 257 | 265 |
| 258 // Public session auto-login timeout, in milliseconds. | 266 // Auto-login timeout, in milliseconds. |
| 259 int public_session_auto_login_delay_; | 267 int auto_login_delay_; |
| 260 | 268 |
| 261 // AccountId for public session auto-login. | 269 // AccountId for public session auto-login. |
| 262 AccountId public_session_auto_login_account_id_ = EmptyAccountId(); | 270 AccountId public_session_auto_login_account_id_ = EmptyAccountId(); |
| 263 | 271 |
| 272 // AccountId for ARC kiosk auto-login. |
| 273 AccountId arc_kiosk_auto_login_account_id_ = EmptyAccountId(); |
| 274 |
| 264 // Used to execute login operations. | 275 // Used to execute login operations. |
| 265 std::unique_ptr<LoginPerformer> login_performer_; | 276 std::unique_ptr<LoginPerformer> login_performer_; |
| 266 | 277 |
| 267 // Delegate to forward all authentication status events to. | 278 // Delegate to forward all authentication status events to. |
| 268 // Tests can use this to receive authentication status events. | 279 // Tests can use this to receive authentication status events. |
| 269 AuthStatusConsumer* auth_status_consumer_ = nullptr; | 280 AuthStatusConsumer* auth_status_consumer_ = nullptr; |
| 270 | 281 |
| 271 // AccountId of the last login attempt. | 282 // AccountId of the last login attempt. |
| 272 AccountId last_login_attempt_account_id_ = EmptyAccountId(); | 283 AccountId last_login_attempt_account_id_ = EmptyAccountId(); |
| 273 | 284 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 | 359 |
| 349 // Factory of callbacks. | 360 // Factory of callbacks. |
| 350 base::WeakPtrFactory<ExistingUserController> weak_factory_; | 361 base::WeakPtrFactory<ExistingUserController> weak_factory_; |
| 351 | 362 |
| 352 DISALLOW_COPY_AND_ASSIGN(ExistingUserController); | 363 DISALLOW_COPY_AND_ASSIGN(ExistingUserController); |
| 353 }; | 364 }; |
| 354 | 365 |
| 355 } // namespace chromeos | 366 } // namespace chromeos |
| 356 | 367 |
| 357 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_EXISTING_USER_CONTROLLER_H_ | 368 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_EXISTING_USER_CONTROLLER_H_ |
| OLD | NEW |