| Index: chrome/browser/profiles/profile_manager.cc
|
| diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc
|
| index 714c2883aa4fb51c8e8260838dcdd9d41b9d6c9c..1afca4f32415183f680ad565dad056842c312016 100644
|
| --- a/chrome/browser/profiles/profile_manager.cc
|
| +++ b/chrome/browser/profiles/profile_manager.cc
|
| @@ -310,17 +310,21 @@ Profile* ProfileManager::GetLastUsedProfile(const FilePath& user_data_dir) {
|
| return GetDefaultProfile(user_data_dir);
|
| #endif
|
|
|
| + return GetProfile(GetLastUsedProfilePath(user_data_dir));
|
| +}
|
| +
|
| +FilePath ProfileManager::GetLastUsedProfilePath(const FilePath& user_data_dir) {
|
| FilePath last_used_profile_dir(user_data_dir);
|
| - std::string last_profile_used;
|
| + std::string last_used_profile;
|
| PrefService* local_state = g_browser_process->local_state();
|
| DCHECK(local_state);
|
|
|
| - if (local_state->HasPrefPath(prefs::kProfileLastUsed))
|
| - last_profile_used = local_state->GetString(prefs::kProfileLastUsed);
|
| - last_used_profile_dir = last_profile_used.empty() ?
|
| - last_used_profile_dir.AppendASCII(chrome::kInitialProfile) :
|
| - last_used_profile_dir.AppendASCII(last_profile_used);
|
| - return GetProfile(last_used_profile_dir);
|
| + if (local_state->HasPrefPath(prefs::kProfileLastUsed)) {
|
| + return last_used_profile_dir.AppendASCII(
|
| + local_state->GetString(prefs::kProfileLastUsed));
|
| + }
|
| +
|
| + return last_used_profile_dir.AppendASCII(chrome::kInitialProfile);
|
| }
|
|
|
| std::vector<Profile*> ProfileManager::GetLastOpenedProfiles(
|
| @@ -840,6 +844,7 @@ void ProfileManager::CreateMultiProfileAsync(
|
|
|
| // static
|
| void ProfileManager::RegisterPrefs(PrefServiceSimple* prefs) {
|
| + prefs->RegisterStringPref(prefs::kAppListProfile, "");
|
| prefs->RegisterStringPref(prefs::kProfileLastUsed, "");
|
| prefs->RegisterIntegerPref(prefs::kProfilesNumCreated, 1);
|
| prefs->RegisterListPref(prefs::kProfilesLastActive);
|
| @@ -992,6 +997,16 @@ void ProfileManager::ScheduleProfileForDeletion(
|
| }
|
| }
|
|
|
| + // If the profile the app list uses just got deleted, reset it to the last
|
| + // used profile.
|
| + // TODO(koz): Manage the kAppListProfile preference not in this class.
|
| + std::string app_list_last_profile = local_state->GetString(
|
| + prefs::kAppListProfile);
|
| + if (profile_dir.BaseName().MaybeAsASCII() == app_list_last_profile) {
|
| + local_state->SetString(prefs::kAppListProfile,
|
| + local_state->GetString(prefs::kProfileLastUsed));
|
| + }
|
| +
|
| // TODO(sail): Due to bug 88586 we don't delete the profile instance. Once we
|
| // start deleting the profile instance we need to close background apps too.
|
| Profile* profile = GetProfileByPath(profile_dir);
|
|
|