diff options
author | nkostylev@chromium.org <nkostylev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-30 13:18:02 +0000 |
---|---|---|
committer | nkostylev@chromium.org <nkostylev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-30 13:18:02 +0000 |
commit | 2d9fe795393700cc42552c40974d2bfb6023bade (patch) | |
tree | 489abd124e7132319c29a25453d46d3e400c2540 | |
parent | 4817c9e61709c15d156f8c9568fdfeb650e51d2e (diff) | |
download | chromium_src-2d9fe795393700cc42552c40974d2bfb6023bade.zip chromium_src-2d9fe795393700cc42552c40974d2bfb6023bade.tar.gz chromium_src-2d9fe795393700cc42552c40974d2bfb6023bade.tar.bz2 |
Revert 267174 "Revert of Multiprofile: switch to newly added use..."
> Revert of Multiprofile: switch to newly added user to the session (https://codereview.chromium.org/246253009/)
>
> Reason for revert:
> Suspecting this change as a root cause for superflaky UserAddingScreenTest.AddingSeveralUsers
>
> See http://crbug.com/368621
>
> Original issue's description:
> > Multiprofile: switch to newly added user to the session
> >
> > This CL remember pending user switch and do it as soon as profile
> > ready. From UI perspective this look very smooth because profile loading
> > is actually fast so previous desktop is not shown. But if it will be
> > a problem on slow device we may need to stay on add user screen a bit longer.
> >
> > BUG=333879
> > TEST=manual
> > R=nkostylev@chromium.org
> >
> > Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=266239
>
> TBR=dpolukhin@chromium.org,dpolukhin@google.com
> NOTREECHECKS=true
> NOTRY=true
> BUG=333879,368621
>
> Review URL: https://codereview.chromium.org/257393003
TBR=nkostylev@chromium.org
Review URL: https://codereview.chromium.org/267463002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@267197 0039d316-1c4b-4281-b951-d872f2087c98
4 files changed, 22 insertions, 14 deletions
diff --git a/chrome/browser/chromeos/file_manager/file_manager_browsertest.cc b/chrome/browser/chromeos/file_manager/file_manager_browsertest.cc index b6e4e8e..04e60ce 100644 --- a/chrome/browser/chromeos/file_manager/file_manager_browsertest.cc +++ b/chrome/browser/chromeos/file_manager/file_manager_browsertest.cc @@ -915,9 +915,6 @@ class MultiProfileFileManagerBrowserTest : public FileManagerBrowserTestBase { const TestAccountInfo& info = kTestAccounts[PRIMARY_ACCOUNT_INDEX]; AddUser(info, true); - chromeos::UserManager* const user_manager = chromeos::UserManager::Get(); - if (user_manager->GetActiveUser() != user_manager->FindUser(info.email)) - chromeos::UserManager::Get()->SwitchActiveUser(info.email); FileManagerBrowserTestBase::SetUpOnMainThread(); } diff --git a/chrome/browser/chromeos/login/user_manager_impl.cc b/chrome/browser/chromeos/login/user_manager_impl.cc index 9fcd332..7f27162 100644 --- a/chrome/browser/chromeos/login/user_manager_impl.cc +++ b/chrome/browser/chromeos/login/user_manager_impl.cc @@ -424,9 +424,9 @@ void UserManagerImpl::UserLoggedIn(const std::string& user_id, lru_logged_in_users_.push_back(user); // Reset the new user flag if the user already exists. is_current_user_new_ = false; - // Set active user wallpaper back. - WallpaperManager::Get()->SetUserWallpaperNow(active_user_->email()); NotifyUserAddedToSession(user); + // Remember that we need to switch to this user as soon as profile ready. + pending_user_switch_ = user_id; return; } @@ -971,7 +971,18 @@ void UserManagerImpl::Observe(int type, User* user = GetUserByProfile(profile); if (user != NULL) user->set_profile_is_created(); - + // If there is pending user switch, do it now. + if (!pending_user_switch_.empty()) { + // Call SwitchActiveUser async because otherwise it may cause + // ProfileManager::GetProfile before the profile gets registered + // in ProfileManager. It happens in case of sync profile load when + // NOTIFICATION_PROFILE_CREATED is called synchronously. + base::MessageLoop::current()->PostTask(FROM_HERE, + base::Bind(&UserManagerImpl::SwitchActiveUser, + base::Unretained(this), + pending_user_switch_)); + pending_user_switch_.clear(); + } break; } default: diff --git a/chrome/browser/chromeos/login/user_manager_impl.h b/chrome/browser/chromeos/login/user_manager_impl.h index ef63d1a..1ec2c2e 100644 --- a/chrome/browser/chromeos/login/user_manager_impl.h +++ b/chrome/browser/chromeos/login/user_manager_impl.h @@ -483,6 +483,10 @@ class UserManagerImpl scoped_ptr<policy::CloudExternalDataPolicyObserver> wallpaper_policy_observer_; + // ID of the user just added to the session that needs to be activated + // as soon as user's profile is loaded. + std::string pending_user_switch_; + DISALLOW_COPY_AND_ASSIGN(UserManagerImpl); }; diff --git a/chrome/browser/chromeos/preferences_browsertest.cc b/chrome/browser/chromeos/preferences_browsertest.cc index fe3fb00..b8a5267 100644 --- a/chrome/browser/chromeos/preferences_browsertest.cc +++ b/chrome/browser/chromeos/preferences_browsertest.cc @@ -153,19 +153,15 @@ IN_PROC_BROWSER_TEST_F(PreferencesTest, MultiProfiles) { // Add second user and init its prefs with different values. UserAddingScreen::Get()->Start(); content::RunAllPendingInMessageLoop(); + DisableAnimations(); AddUser(kTestUsers[1]); - EXPECT_TRUE(user1->is_active()); + content::RunAllPendingInMessageLoop(); const User* user2 = user_manager->FindUser(kTestUsers[1]); + EXPECT_TRUE(user2->is_active()); PrefService* prefs2 = user_manager->GetProfileByUser(user2)->GetPrefs(); SetPrefs(prefs2, true); - // First user is still active, so settings was not changed. - EXPECT_TRUE(user1->is_active()); - CheckSettingsCorrespondToPrefs(prefs1); - - // Switch user and check that settings was changed accordingly. - DisableAnimations(); - user_manager->SwitchActiveUser(kTestUsers[1]); + // Check that settings were changed accordingly. EXPECT_TRUE(user2->is_active()); CheckSettingsCorrespondToPrefs(prefs2); |