Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1362)

Unified Diff: chrome/browser/profiles/profile_manager.cc

Issue 544383003: Fixing problem that after a browser crash in multi user mode, an incorrect user might show up. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moving function declaration into conditional section Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/profiles/profile_manager.h ('k') | chrome/browser/profiles/profile_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profiles/profile_manager.cc
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc
index 982d0100d93b7090370bf487365f11b48023163d..20cb9d5d2b6f0975a101f129eff1cbe358c3098b 100644
--- a/chrome/browser/profiles/profile_manager.cc
+++ b/chrome/browser/profiles/profile_manager.cc
@@ -817,6 +817,15 @@ void ProfileManager::Observe(
#if defined(OS_CHROMEOS)
if (type == chrome::NOTIFICATION_LOGIN_USER_CHANGED) {
logged_in_ = true;
+ // Find out what the current user is and update it. This has only to be done
+ // when the profile was already loaded, since otherwise this will be set by
+ // the profile loading process.
+ user_manager::UserManager* manager = user_manager::UserManager::Get();
+ const user_manager::User* user = manager->GetActiveUser();
+ if (user && user->is_profile_created()) {
+ UpdateLastUser(
+ chromeos::ProfileHelper::Get()->GetProfileByUser(user));
+ }
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
if (!command_line.HasSwitch(switches::kTestType)) {
@@ -1217,6 +1226,22 @@ ProfileManager::ProfileInfo::~ProfileInfo() {
}
#if !defined(OS_ANDROID) && !defined(OS_IOS)
+void ProfileManager::UpdateLastUser(Profile* last_active) {
+ PrefService* local_state = g_browser_process->local_state();
+ DCHECK(local_state);
+ // Only keep track of profiles that we are managing; tests may create others.
+ if (profiles_info_.find(last_active->GetPath()) != profiles_info_.end()) {
+ local_state->SetString(prefs::kProfileLastUsed,
+ last_active->GetPath().BaseName().MaybeAsASCII());
+
+ ProfileInfoCache& cache = GetProfileInfoCache();
+ size_t profile_index =
+ cache.GetIndexOfProfileWithPath(last_active->GetPath());
+ if (profile_index != std::string::npos)
+ cache.SetProfileActiveTimeAtIndex(profile_index);
+ }
+}
+
ProfileManager::BrowserListObserver::BrowserListObserver(
ProfileManager* manager)
: profile_manager_(manager) {
@@ -1265,20 +1290,7 @@ void ProfileManager::BrowserListObserver::OnBrowserSetLastActive(
if (last_active->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles))
return;
- PrefService* local_state = g_browser_process->local_state();
- DCHECK(local_state);
- // Only keep track of profiles that we are managing; tests may create others.
- if (profile_manager_->profiles_info_.find(
- last_active->GetPath()) != profile_manager_->profiles_info_.end()) {
- local_state->SetString(prefs::kProfileLastUsed,
- last_active->GetPath().BaseName().MaybeAsASCII());
-
- ProfileInfoCache& cache = profile_manager_->GetProfileInfoCache();
- size_t profile_index =
- cache.GetIndexOfProfileWithPath(last_active->GetPath());
- if (profile_index != std::string::npos)
- cache.SetProfileActiveTimeAtIndex(profile_index);
- }
+ profile_manager_->UpdateLastUser(last_active);
}
#endif // !defined(OS_ANDROID) && !defined(OS_IOS)
« no previous file with comments | « chrome/browser/profiles/profile_manager.h ('k') | chrome/browser/profiles/profile_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698