diff options
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 858172b..a626517c4 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); |