Chromium Code Reviews| Index: chrome/browser/profiles/profile_manager.cc |
| diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc |
| index 3dba778821e8415f7f41ed5ce09dd6e52223b168..cf16a4df23cca833e9ac1714ff110447e96208be 100644 |
| --- a/chrome/browser/profiles/profile_manager.cc |
| +++ b/chrome/browser/profiles/profile_manager.cc |
| @@ -815,6 +815,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()->GetProfileByUserUnsafe(user)); |
|
Dmitry Polukhin
2014/09/08 09:51:53
I think you can use new safe version of the functi
Mr4D (OOO till 08-26)
2014/09/08 14:12:16
Done.
|
| + } |
| const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| if (!command_line.HasSwitch(switches::kTestType)) { |
| @@ -1203,6 +1212,22 @@ void ProfileManager::RunCallbacks(const std::vector<CreateCallback>& callbacks, |
| callbacks[i].Run(profile, status); |
| } |
| +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::ProfileInfo::ProfileInfo( |
| Profile* profile, |
| bool created) |
| @@ -1263,20 +1288,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) |