Commit 609c2d1d authored by nkostylev's avatar nkostylev Committed by Commit bot

[session_manager] Move user session initialization code out of ExistingUserController

Added UserSessionManager::InitializeUserSession()
(1) Launches browser for most common case
(2) Continues new user sign in with TOS (public sessions)/image screen (new users)
(3) For kiosk flow delegates launching app to the existing kiosk initialization flow

(1) Currently results in LoginUtils::Get()->DoBrowserLaunch() which may postpone launching browser for these reasons:
(a) There's custom user login flow defined like SupervisedUserCreationFlow. In that case login UI continues to live and custom flow UI is launched in that context.
(b) User has different app locale which requires reloading resource_bundle prior to launching browser
(c) User has custom flags set (or user flags are different from login screen flags defined by the owner), this requires restarting Chrome which will be launched in the active user session.

Small refactoring in ExistingUserController, added

* PerformPreLoginActions() - performs sets of actions right prior to login has been started.
* PerformLoginFinishedActions() - performs set of actions when login has been completed or has been cancelled.

BUG=370175

Review URL: https://codereview.chromium.org/656283002

Cr-Commit-Position: refs/heads/master@{#300708}
parent 8aecd2dd
...@@ -183,7 +183,8 @@ void KioskProfileLoader::OnOnlineChecked( ...@@ -183,7 +183,8 @@ void KioskProfileLoader::OnOnlineChecked(
NOTREACHED(); NOTREACHED();
} }
void KioskProfileLoader::OnProfilePrepared(Profile* profile) { void KioskProfileLoader::OnProfilePrepared(Profile* profile,
bool browser_launched) {
// This object could be deleted any time after successfully reporting // This object could be deleted any time after successfully reporting
// a profile load, so invalidate the LoginUtils delegate now. // a profile load, so invalidate the LoginUtils delegate now.
LoginUtils::Get()->DelegateDeleted(this); LoginUtils::Get()->DelegateDeleted(this);
......
...@@ -57,7 +57,8 @@ class KioskProfileLoader : public LoginPerformer::Delegate, ...@@ -57,7 +57,8 @@ class KioskProfileLoader : public LoginPerformer::Delegate,
const std::string& email, bool success) override; const std::string& email, bool success) override;
// LoginUtils::Delegate implementation: // LoginUtils::Delegate implementation:
virtual void OnProfilePrepared(Profile* profile) override; virtual void OnProfilePrepared(Profile* profile,
bool browser_launched) override;
std::string user_id_; std::string user_id_;
bool use_guest_mount_; bool use_guest_mount_;
......
...@@ -156,20 +156,15 @@ class ExistingUserController : public LoginDisplay::Delegate, ...@@ -156,20 +156,15 @@ class ExistingUserController : public LoginDisplay::Delegate,
const std::string& username, bool success) override; const std::string& username, bool success) override;
// LoginUtils::Delegate implementation: // LoginUtils::Delegate implementation:
virtual void OnProfilePrepared(Profile* profile) override; virtual void OnProfilePrepared(Profile* profile,
bool browser_launched) override;
// Called when device settings change. // Called when device settings change.
void DeviceSettingsChanged(); void DeviceSettingsChanged();
// Starts WizardController with the specified screen.
void ActivateWizard(const std::string& screen_name);
// Returns corresponding native window. // Returns corresponding native window.
gfx::NativeWindow GetNativeWindow() const; gfx::NativeWindow GetNativeWindow() const;
// Adds first-time login URLs.
void InitializeStartUrls() const;
// Show error message. |error_id| error message ID in resources. // Show error message. |error_id| error message ID in resources.
// If |details| string is not empty, it specify additional error text // If |details| string is not empty, it specify additional error text
// provided by authenticator, it is not localized. // provided by authenticator, it is not localized.
...@@ -235,6 +230,14 @@ class ExistingUserController : public LoginDisplay::Delegate, ...@@ -235,6 +230,14 @@ class ExistingUserController : public LoginDisplay::Delegate,
// preconditions have been verified. // preconditions have been verified.
void LoginAsPublicSessionInternal(const UserContext& user_context); void LoginAsPublicSessionInternal(const UserContext& user_context);
// Performs sets of actions right prior to login has been started.
void PerformPreLoginActions(const UserContext& user_context);
// Performs set of actions when login has been completed or has been
// cancelled. If |start_public_session_timer| is true than public session
// auto-login timer is started.
void PerformLoginFinishedActions(bool start_public_session_timer);
// Public session auto-login timer. // Public session auto-login timer.
scoped_ptr<base::OneShotTimer<ExistingUserController> > auto_login_timer_; scoped_ptr<base::OneShotTimer<ExistingUserController> > auto_login_timer_;
......
...@@ -163,6 +163,9 @@ class ExistingUserControllerTest : public policy::DevicePolicyCrosBrowserTest { ...@@ -163,6 +163,9 @@ class ExistingUserControllerTest : public policy::DevicePolicyCrosBrowserTest {
.WillRepeatedly(Return(false)); .WillRepeatedly(Return(false));
EXPECT_CALL(*mock_user_manager_, Shutdown()) EXPECT_CALL(*mock_user_manager_, Shutdown())
.Times(1); .Times(1);
EXPECT_CALL(*mock_user_manager_, FindUser(_))
.Times(AnyNumber())
.WillRepeatedly(ReturnNull());
} }
virtual void SetUpOnMainThread() override { virtual void SetUpOnMainThread() override {
...@@ -175,7 +178,8 @@ class ExistingUserControllerTest : public policy::DevicePolicyCrosBrowserTest { ...@@ -175,7 +178,8 @@ class ExistingUserControllerTest : public policy::DevicePolicyCrosBrowserTest {
profile_prepared_cb_ = profile_prepared_cb_ =
base::Bind(&ExistingUserController::OnProfilePrepared, base::Bind(&ExistingUserController::OnProfilePrepared,
base::Unretained(existing_user_controller()), base::Unretained(existing_user_controller()),
testing_profile_.get()); testing_profile_.get(),
false);
} }
virtual void TearDownOnMainThread() override { virtual void TearDownOnMainThread() override {
...@@ -232,10 +236,8 @@ class ExistingUserControllerTest : public policy::DevicePolicyCrosBrowserTest { ...@@ -232,10 +236,8 @@ class ExistingUserControllerTest : public policy::DevicePolicyCrosBrowserTest {
}; };
IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, ExistingUserLogin) { IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, ExistingUserLogin) {
// This is disabled twice: once right after signin but before checking for
// auto-enrollment, and again after doing an ownership status check.
EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) EXPECT_CALL(*mock_login_display_, SetUIEnabled(false))
.Times(2); .Times(1);
UserContext user_context(kUsername); UserContext user_context(kUsername);
user_context.SetKey(Key(kPassword)); user_context.SetKey(Key(kPassword));
user_context.SetUserIDHash(kUsername); user_context.SetUserIDHash(kUsername);
...@@ -246,10 +248,6 @@ IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, ExistingUserLogin) { ...@@ -246,10 +248,6 @@ IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, ExistingUserLogin) {
.Times(1) .Times(1)
.WillOnce(InvokeWithoutArgs(&profile_prepared_cb_, .WillOnce(InvokeWithoutArgs(&profile_prepared_cb_,
&base::Callback<void(void)>::Run)); &base::Callback<void(void)>::Run));
EXPECT_CALL(*mock_login_utils_,
DoBrowserLaunch(testing_profile_.get(),
mock_login_display_host_.get()))
.Times(1);
EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) EXPECT_CALL(*mock_login_display_, SetUIEnabled(true))
.Times(1); .Times(1);
EXPECT_CALL(*mock_login_display_host_, EXPECT_CALL(*mock_login_display_host_,
...@@ -294,10 +292,6 @@ IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, ...@@ -294,10 +292,6 @@ IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest,
StartWizardPtr(WizardController::kEnrollmentScreenName, StartWizardPtr(WizardController::kEnrollmentScreenName,
_)) _))
.Times(0); .Times(0);
EXPECT_CALL(*mock_login_display_host_,
StartWizardPtr(WizardController::kTermsOfServiceScreenName,
NULL))
.Times(1);
UserContext user_context(kNewUsername); UserContext user_context(kNewUsername);
user_context.SetKey(Key(kPassword)); user_context.SetKey(Key(kPassword));
user_context.SetUserIDHash(kNewUsername); user_context.SetUserIDHash(kNewUsername);
...@@ -327,7 +321,7 @@ IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, ...@@ -327,7 +321,7 @@ IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest,
// This is disabled twice: once right after signin but before checking for // This is disabled twice: once right after signin but before checking for
// auto-enrollment, and again after doing an ownership status check. // auto-enrollment, and again after doing an ownership status check.
EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) EXPECT_CALL(*mock_login_display_, SetUIEnabled(false))
.Times(2) .Times(1)
.InSequence(uiEnabledSequence); .InSequence(uiEnabledSequence);
EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) EXPECT_CALL(*mock_login_display_, SetUIEnabled(true))
.Times(1) .Times(1)
...@@ -437,10 +431,6 @@ class ExistingUserControllerPublicSessionTest ...@@ -437,10 +431,6 @@ class ExistingUserControllerPublicSessionTest
.Times(1) .Times(1)
.WillOnce(InvokeWithoutArgs(&profile_prepared_cb_, .WillOnce(InvokeWithoutArgs(&profile_prepared_cb_,
&base::Callback<void(void)>::Run)); &base::Callback<void(void)>::Run));
EXPECT_CALL(*mock_login_utils_,
DoBrowserLaunch(testing_profile_.get(),
mock_login_display_host_.get()))
.Times(1);
EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) EXPECT_CALL(*mock_login_display_, SetUIEnabled(true))
.Times(1); .Times(1);
EXPECT_CALL(*mock_login_display_host_, EXPECT_CALL(*mock_login_display_host_,
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/prefs/pref_service.h" #include "base/prefs/pref_service.h"
#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/login/ui/login_display_host.h" #include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
#include "chrome/browser/chromeos/login/user_flow.h" #include "chrome/browser/chromeos/login/user_flow.h"
#include "chrome/browser/chromeos/login/users/chrome_user_manager.h" #include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
#include "chrome/browser/chromeos/login/users/supervised_user_manager.h" #include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
...@@ -60,11 +61,11 @@ void FakeLoginUtils::PrepareProfile(const UserContext& user_context, ...@@ -60,11 +61,11 @@ void FakeLoginUtils::PrepareProfile(const UserContext& user_context,
bool has_cookies, bool has_cookies,
bool has_active_session, bool has_active_session,
LoginUtils::Delegate* delegate) { LoginUtils::Delegate* delegate) {
user_manager::UserManager::Get()->UserLoggedIn( user_manager::UserManager* user_manager = user_manager::UserManager::Get();
user_manager->UserLoggedIn(
user_context.GetUserID(), user_context.GetUserIDHash(), false); user_context.GetUserID(), user_context.GetUserIDHash(), false);
user_manager::User* user = user_manager::User* user =
user_manager::UserManager::Get()->FindUserAndModify( user_manager->FindUserAndModify(user_context.GetUserID());
user_context.GetUserID());
DCHECK(user); DCHECK(user);
// Make sure that we get the real Profile instead of the login Profile. // Make sure that we get the real Profile instead of the login Profile.
...@@ -73,9 +74,8 @@ void FakeLoginUtils::PrepareProfile(const UserContext& user_context, ...@@ -73,9 +74,8 @@ void FakeLoginUtils::PrepareProfile(const UserContext& user_context,
profile->GetPrefs()->SetString(prefs::kGoogleServicesUsername, profile->GetPrefs()->SetString(prefs::kGoogleServicesUsername,
user_context.GetUserID()); user_context.GetUserID());
if (user_manager::UserManager::Get()->IsLoggedInAsSupervisedUser()) { if (user_manager->IsLoggedInAsSupervisedUser()) {
user_manager::User* active_user = user_manager::User* active_user = user_manager->GetActiveUser();
user_manager::UserManager::Get()->GetActiveUser();
std::string supervised_user_sync_id = std::string supervised_user_sync_id =
ChromeUserManager::Get()->GetSupervisedUserManager()->GetUserSyncId( ChromeUserManager::Get()->GetSupervisedUserManager()->GetUserSyncId(
active_user->email()); active_user->email());
...@@ -89,8 +89,22 @@ void FakeLoginUtils::PrepareProfile(const UserContext& user_context, ...@@ -89,8 +89,22 @@ void FakeLoginUtils::PrepareProfile(const UserContext& user_context,
chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED,
content::NotificationService::AllSources(), content::NotificationService::AllSources(),
content::Details<Profile>(profile)); content::Details<Profile>(profile));
// Emulate UserSessionManager::InitializeUserSession() for now till
// FakeLoginUtils are deprecated.
bool browser_launched = false;
if (!user_manager->IsLoggedInAsKioskApp()) {
if (user_manager->IsCurrentUserNew()) {
NOTREACHED() << "Method not implemented.";
} else {
browser_launched = true;
LoginUtils::Get()->DoBrowserLaunch(profile,
LoginDisplayHostImpl::default_host());
}
}
if (delegate) if (delegate)
delegate->OnProfilePrepared(profile); delegate->OnProfilePrepared(profile, browser_launched);
} }
void FakeLoginUtils::DelegateDeleted(LoginUtils::Delegate* delegate) { void FakeLoginUtils::DelegateDeleted(LoginUtils::Delegate* delegate) {
......
...@@ -118,14 +118,14 @@ void LoginManagerTest::JSExpect(const std::string& expression) { ...@@ -118,14 +118,14 @@ void LoginManagerTest::JSExpect(const std::string& expression) {
} }
void LoginManagerTest::InitializeWebContents() { void LoginManagerTest::InitializeWebContents() {
LoginDisplayHost* host = LoginDisplayHostImpl::default_host(); LoginDisplayHost* host = LoginDisplayHostImpl::default_host();
EXPECT_TRUE(host != NULL); EXPECT_TRUE(host != NULL);
content::WebContents* web_contents = content::WebContents* web_contents =
host->GetWebUILoginView()->GetWebContents(); host->GetWebUILoginView()->GetWebContents();
EXPECT_TRUE(web_contents != NULL); EXPECT_TRUE(web_contents != NULL);
set_web_contents(web_contents); set_web_contents(web_contents);
js_checker_.set_web_contents(web_contents); js_checker_.set_web_contents(web_contents);
} }
} // namespace chromeos } // namespace chromeos
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h" #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h"
#include "chrome/browser/chromeos/login/ui/input_events_blocker.h" #include "chrome/browser/chromeos/login/ui/input_events_blocker.h"
#include "chrome/browser/chromeos/login/ui/login_display_host.h" #include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/browser/chromeos/login/ui/user_adding_screen.h"
#include "chrome/browser/chromeos/login/user_flow.h" #include "chrome/browser/chromeos/login/user_flow.h"
#include "chrome/browser/chromeos/login/users/chrome_user_manager.h" #include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
#include "chrome/browser/chromeos/login/users/supervised_user_manager.h" #include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
...@@ -200,7 +201,8 @@ class LoginUtilsImpl : public LoginUtils, ...@@ -200,7 +201,8 @@ class LoginUtilsImpl : public LoginUtils,
bool early_restart) override; bool early_restart) override;
// UserSessionManager::Delegate implementation: // UserSessionManager::Delegate implementation:
virtual void OnProfilePrepared(Profile* profile) override; virtual void OnProfilePrepared(Profile* profile,
bool browser_launched) override;
#if defined(ENABLE_RLZ) #if defined(ENABLE_RLZ)
virtual void OnRlzInitialized() override; virtual void OnRlzInitialized() override;
#endif #endif
...@@ -371,12 +373,21 @@ void LoginUtilsImpl::PrepareProfile( ...@@ -371,12 +373,21 @@ void LoginUtilsImpl::PrepareProfile(
// as it coexist with SessionManager. // as it coexist with SessionManager.
delegate_ = delegate; delegate_ = delegate;
UserSessionManager::StartSessionType start_session_type =
UserAddingScreen::Get()->IsRunning() ?
UserSessionManager::SECONDARY_USER_SESSION :
UserSessionManager::PRIMARY_USER_SESSION;
// For the transition part LoginUtils will just delegate profile // For the transition part LoginUtils will just delegate profile
// creation and initialization to SessionManager. Later LoginUtils will be // creation and initialization to SessionManager. Later LoginUtils will be
// removed and all LoginUtils clients will just work with SessionManager // removed and all LoginUtils clients will just work with SessionManager
// directly. // directly.
UserSessionManager::GetInstance()->StartSession( UserSessionManager::GetInstance()->StartSession(user_context,
user_context, authenticator_, has_auth_cookies, has_active_session, this); start_session_type,
authenticator_,
has_auth_cookies,
has_active_session,
this);
} }
void LoginUtilsImpl::DelegateDeleted(LoginUtils::Delegate* delegate) { void LoginUtilsImpl::DelegateDeleted(LoginUtils::Delegate* delegate) {
...@@ -429,9 +440,10 @@ scoped_refptr<Authenticator> LoginUtilsImpl::CreateAuthenticator( ...@@ -429,9 +440,10 @@ scoped_refptr<Authenticator> LoginUtilsImpl::CreateAuthenticator(
return authenticator_; return authenticator_;
} }
void LoginUtilsImpl::OnProfilePrepared(Profile* profile) { void LoginUtilsImpl::OnProfilePrepared(Profile* profile,
bool browser_launched) {
if (delegate_) if (delegate_)
delegate_->OnProfilePrepared(profile); delegate_->OnProfilePrepared(profile, browser_launched);
} }
#if defined(ENABLE_RLZ) #if defined(ENABLE_RLZ)
......
...@@ -29,7 +29,10 @@ class LoginUtils { ...@@ -29,7 +29,10 @@ class LoginUtils {
class Delegate { class Delegate {
public: public:
// Called after profile is loaded and prepared for the session. // Called after profile is loaded and prepared for the session.
virtual void OnProfilePrepared(Profile* profile) = 0; // |browser_launched| will be true is browser has been launched, otherwise
// it will return false and client is responsible on launching browser.
virtual void OnProfilePrepared(Profile* profile,
bool browser_launched) = 0;
#if defined(ENABLE_RLZ) #if defined(ENABLE_RLZ)
// Called after post-profile RLZ initialization. // Called after post-profile RLZ initialization.
......
...@@ -41,7 +41,10 @@ class EasyUnlockKeyManager; ...@@ -41,7 +41,10 @@ class EasyUnlockKeyManager;
class UserSessionManagerDelegate { class UserSessionManagerDelegate {
public: public:
// Called after profile is loaded and prepared for the session. // Called after profile is loaded and prepared for the session.
virtual void OnProfilePrepared(Profile* profile) = 0; // |browser_launched| will be true is browser has been launched, otherwise
// it will return false and client is responsible on launching browser.
virtual void OnProfilePrepared(Profile* profile,
bool browser_launched) = 0;
#if defined(ENABLE_RLZ) #if defined(ENABLE_RLZ)
// Called after post-profile RLZ initialization. // Called after post-profile RLZ initialization.
...@@ -61,10 +64,10 @@ class UserSessionStateObserver { ...@@ -61,10 +64,10 @@ class UserSessionStateObserver {
}; };
// UserSessionManager is responsible for starting user session which includes: // UserSessionManager is responsible for starting user session which includes:
// load and initialize Profile (including custom Profile preferences), // * load and initialize Profile (including custom Profile preferences),
// mark user as logged in and notify observers, // * mark user as logged in and notify observers,
// initialize OAuth2 authentication session, // * initialize OAuth2 authentication session,
// initialize and launch user session based on the user type. // * initialize and launch user session based on the user type.
// Also supports restoring active user sessions after browser crash: // Also supports restoring active user sessions after browser crash:
// load profile, restore OAuth authentication session etc. // load profile, restore OAuth authentication session etc.
class UserSessionManager class UserSessionManager
...@@ -74,6 +77,21 @@ class UserSessionManager ...@@ -74,6 +77,21 @@ class UserSessionManager
public UserSessionManagerDelegate, public UserSessionManagerDelegate,
public user_manager::UserManager::UserSessionStateObserver { public user_manager::UserManager::UserSessionStateObserver {
public: public:
// Context of StartSession calls.
typedef enum {
// Starting primary user session, through login UI.
PRIMARY_USER_SESSION,
// Starting secondary user session, through multi-profiles login UI.
SECONDARY_USER_SESSION,
// Starting primary user session after browser crash.
PRIMARY_USER_SESSION_AFTER_CRASH,
// Starting secondary user session after browser crash.
SECONDARY_USER_SESSION_AFTER_CRASH,
} StartSessionType;
// Returns UserSessionManager instance. // Returns UserSessionManager instance.
static UserSessionManager* GetInstance(); static UserSessionManager* GetInstance();
...@@ -91,6 +109,7 @@ class UserSessionManager ...@@ -91,6 +109,7 @@ class UserSessionManager
// Start user session given |user_context| and |authenticator| which holds // Start user session given |user_context| and |authenticator| which holds
// authentication context (profile). // authentication context (profile).
void StartSession(const UserContext& user_context, void StartSession(const UserContext& user_context,
StartSessionType start_session_type,
scoped_refptr<Authenticator> authenticator, scoped_refptr<Authenticator> authenticator,
bool has_auth_cookies, bool has_auth_cookies,
bool has_active_session, bool has_active_session,
...@@ -198,7 +217,8 @@ class UserSessionManager ...@@ -198,7 +217,8 @@ class UserSessionManager
// UserSessionManagerDelegate overrides: // UserSessionManagerDelegate overrides:
// Used when restoring user sessions after crash. // Used when restoring user sessions after crash.
virtual void OnProfilePrepared(Profile* profile) override; virtual void OnProfilePrepared(Profile* profile,
bool browser_launched) override;
void CreateUserSession(const UserContext& user_context, void CreateUserSession(const UserContext& user_context,
bool has_auth_cookies); bool has_auth_cookies);
...@@ -233,6 +253,18 @@ class UserSessionManager ...@@ -233,6 +253,18 @@ class UserSessionManager
// Finalized profile preparation. // Finalized profile preparation.
void FinalizePrepareProfile(Profile* profile); void FinalizePrepareProfile(Profile* profile);
// Starts out-of-box flow with the specified screen.
void ActivateWizard(const std::string& screen_name);
// Adds first-time login URLs.
void InitializeStartUrls() const;
// Perform session initialization and either move to additional login flows
// such as TOS (public sessions), priority pref sync UI (new users) or
// launch browser.
// Returns true if browser has been launched or false otherwise.
bool InitializeUserSession(Profile* profile);
// Initializes member variables needed for session restore process via // Initializes member variables needed for session restore process via
// OAuthLoginManager. // OAuthLoginManager.
void InitSessionRestoreStrategy(); void InitSessionRestoreStrategy();
...@@ -270,6 +302,7 @@ class UserSessionManager ...@@ -270,6 +302,7 @@ class UserSessionManager
// Authentication/user context. // Authentication/user context.
UserContext user_context_; UserContext user_context_;
scoped_refptr<Authenticator> authenticator_; scoped_refptr<Authenticator> authenticator_;
StartSessionType start_session_type_;
// True if the authentication context's cookie jar contains authentication // True if the authentication context's cookie jar contains authentication
// cookies from the authentication extension login flow. // cookies from the authentication extension login flow.
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "chrome/browser/chromeos/login/supervised/supervised_user_login_flow.h" #include "chrome/browser/chromeos/login/supervised/supervised_user_login_flow.h"
#include "base/base64.h" #include "base/base64.h"
#include "base/command_line.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/metrics/histogram.h" #include "base/metrics/histogram.h"
#include "base/prefs/pref_registry_simple.h" #include "base/prefs/pref_registry_simple.h"
...@@ -18,6 +19,7 @@ ...@@ -18,6 +19,7 @@
#include "chrome/browser/chromeos/login/users/chrome_user_manager.h" #include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
#include "chrome/browser/chromeos/login/users/supervised_user_manager.h" #include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
#include "chrome/browser/chromeos/login/wizard_controller.h" #include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/common/chrome_switches.h"
#include "chromeos/login/auth/key.h" #include "chromeos/login/auth/key.h"
#include "components/user_manager/user_manager.h" #include "components/user_manager/user_manager.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
...@@ -35,6 +37,14 @@ SupervisedUserLoginFlow::SupervisedUserLoginFlow( ...@@ -35,6 +37,14 @@ SupervisedUserLoginFlow::SupervisedUserLoginFlow(
SupervisedUserLoginFlow::~SupervisedUserLoginFlow() {} SupervisedUserLoginFlow::~SupervisedUserLoginFlow() {}
void SupervisedUserLoginFlow::AppendAdditionalCommandLineSwitches() {
user_manager::UserManager* user_manager = user_manager::UserManager::Get();
if (user_manager->IsCurrentUserNew()) {
// Supervised users should launch into empty desktop on first run.
CommandLine::ForCurrentProcess()->AppendSwitch(::switches::kSilentLaunch);
}
}
bool SupervisedUserLoginFlow::CanLockScreen() { bool SupervisedUserLoginFlow::CanLockScreen() {
return true; return true;
} }
...@@ -59,10 +69,6 @@ bool SupervisedUserLoginFlow::HandlePasswordChangeDetected() { ...@@ -59,10 +69,6 @@ bool SupervisedUserLoginFlow::HandlePasswordChangeDetected() {
return false; return false;
} }
void SupervisedUserLoginFlow::HandleOAuthTokenStatusChange(
user_manager::User::OAuthTokenStatus status) {
}
void SupervisedUserLoginFlow::OnSyncSetupDataLoaded( void SupervisedUserLoginFlow::OnSyncSetupDataLoaded(
const std::string& token) { const std::string& token) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
......
...@@ -24,6 +24,7 @@ class SupervisedUserLoginFlow ...@@ -24,6 +24,7 @@ class SupervisedUserLoginFlow
virtual ~SupervisedUserLoginFlow(); virtual ~SupervisedUserLoginFlow();
// ExtendedUserFlow overrides. // ExtendedUserFlow overrides.
virtual void AppendAdditionalCommandLineSwitches() override;
virtual bool CanLockScreen() override; virtual bool CanLockScreen() override;
virtual bool ShouldLaunchBrowser() override; virtual bool ShouldLaunchBrowser() override;
virtual bool ShouldSkipPostLoginScreens() override; virtual bool ShouldSkipPostLoginScreens() override;
...@@ -31,8 +32,6 @@ class SupervisedUserLoginFlow ...@@ -31,8 +32,6 @@ class SupervisedUserLoginFlow
virtual bool HandleLoginFailure(const AuthFailure& failure) override; virtual bool HandleLoginFailure(const AuthFailure& failure) override;
virtual void HandleLoginSuccess(const UserContext& context) override; virtual void HandleLoginSuccess(const UserContext& context) override;
virtual bool HandlePasswordChangeDetected() override; virtual bool HandlePasswordChangeDetected() override;
virtual void HandleOAuthTokenStatusChange(
user_manager::User::OAuthTokenStatus status) override;
virtual void LaunchExtraSteps(Profile* profile) override; virtual void LaunchExtraSteps(Profile* profile) override;
// ExtendedAuthenticator::NewAuthStatusConsumer overrides. // ExtendedAuthenticator::NewAuthStatusConsumer overrides.
......
...@@ -24,8 +24,9 @@ void TestLoginUtils::PrepareProfile( ...@@ -24,8 +24,9 @@ void TestLoginUtils::PrepareProfile(
Delegate* delegate) { Delegate* delegate) {
if (user_context != expected_user_context_) if (user_context != expected_user_context_)
NOTREACHED(); NOTREACHED();
// Profile hasn't been loaded. // Profile hasn't been loaded.
delegate->OnProfilePrepared(NULL); delegate->OnProfilePrepared(NULL, false);
} }
void TestLoginUtils::DelegateDeleted(Delegate* delegate) { void TestLoginUtils::DelegateDeleted(Delegate* delegate) {
......
...@@ -24,6 +24,9 @@ UserFlow::~UserFlow() {} ...@@ -24,6 +24,9 @@ UserFlow::~UserFlow() {}
DefaultUserFlow::~DefaultUserFlow() {} DefaultUserFlow::~DefaultUserFlow() {}
void DefaultUserFlow::AppendAdditionalCommandLineSwitches() {
}
bool DefaultUserFlow::CanLockScreen() { bool DefaultUserFlow::CanLockScreen() {
return true; return true;
} }
...@@ -68,10 +71,17 @@ ExtendedUserFlow::ExtendedUserFlow(const std::string& user_id) ...@@ -68,10 +71,17 @@ ExtendedUserFlow::ExtendedUserFlow(const std::string& user_id)
ExtendedUserFlow::~ExtendedUserFlow() { ExtendedUserFlow::~ExtendedUserFlow() {
} }
void ExtendedUserFlow::AppendAdditionalCommandLineSwitches() {
}
bool ExtendedUserFlow::ShouldShowSettings() { bool ExtendedUserFlow::ShouldShowSettings() {
return true; return true;
} }
void ExtendedUserFlow::HandleOAuthTokenStatusChange(
user_manager::User::OAuthTokenStatus status) {
}
void ExtendedUserFlow::UnregisterFlowSoon() { void ExtendedUserFlow::UnregisterFlowSoon() {
std::string id_copy(user_id()); std::string id_copy(user_id());
base::MessageLoop::current()->PostTask(FROM_HERE, base::MessageLoop::current()->PostTask(FROM_HERE,
......
...@@ -21,6 +21,10 @@ class UserFlow { ...@@ -21,6 +21,10 @@ class UserFlow {
public: public:
UserFlow(); UserFlow();
virtual ~UserFlow() = 0; virtual ~UserFlow() = 0;
// Provides ability to alter command line before session has started.
virtual void AppendAdditionalCommandLineSwitches() = 0;
// Indicates if screen locking should be enabled or disabled for a flow. // Indicates if screen locking should be enabled or disabled for a flow.
virtual bool CanLockScreen() = 0; virtual bool CanLockScreen() = 0;
virtual bool ShouldShowSettings() = 0; virtual bool ShouldShowSettings() = 0;
...@@ -51,6 +55,7 @@ class DefaultUserFlow : public UserFlow { ...@@ -51,6 +55,7 @@ class DefaultUserFlow : public UserFlow {
public: public:
virtual ~DefaultUserFlow(); virtual ~DefaultUserFlow();
virtual void AppendAdditionalCommandLineSwitches() override;
virtual bool CanLockScreen() override; virtual bool CanLockScreen() override;
virtual bool ShouldShowSettings() override; virtual bool ShouldShowSettings() override;
virtual bool ShouldLaunchBrowser() override; virtual bool ShouldLaunchBrowser() override;
...@@ -70,7 +75,10 @@ class ExtendedUserFlow : public UserFlow { ...@@ -70,7 +75,10 @@ class ExtendedUserFlow : public UserFlow {
explicit ExtendedUserFlow(const std::string& user_id); explicit ExtendedUserFlow(const std::string& user_id);
virtual ~ExtendedUserFlow(); virtual ~ExtendedUserFlow();
virtual void AppendAdditionalCommandLineSwitches() override;
virtual bool ShouldShowSettings() override; virtual bool ShouldShowSettings() override;
virtual void HandleOAuthTokenStatusChange(
user_manager::User::OAuthTokenStatus status) override;
protected: protected:
// Subclasses can call this method to unregister flow in the next event. // Subclasses can call this method to unregister flow in the next event.
......
...@@ -25,8 +25,9 @@ std::string CanonicalizeEmailImpl(const std::string& email_address, ...@@ -25,8 +25,9 @@ std::string CanonicalizeEmailImpl(const std::string& email_address,
char at = '@'; char at = '@';
base::SplitString(email_address, at, &parts); base::SplitString(email_address, at, &parts);
if (parts.size() != 2U) { if (parts.size() != 2U) {
NOTREACHED() << "expecting exactly one @, but got " << parts.size()-1 << NOTREACHED() << "expecting exactly one @, but got "
" : " << email_address; << (parts.empty() ? 0 : parts.size() - 1)
<< " : " << email_address;
} else { } else {
if (change_googlemail_to_gmail && parts[1] == kGooglemailDomain) if (change_googlemail_to_gmail && parts[1] == kGooglemailDomain)
parts[1] = kGmailDomain; parts[1] = kGmailDomain;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment