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 800010b79252d961655dccbf41b14038c5cc50f4..2735519ad44c3de93ba549f0c84a1cfce7d33e00 100644 |
| --- a/chrome/browser/profiles/profile_manager.cc |
| +++ b/chrome/browser/profiles/profile_manager.cc |
| @@ -1367,13 +1367,16 @@ Profile* ProfileManager::CreateAndInitializeProfile( |
| #if !defined(OS_ANDROID) |
| void ProfileManager::EnsureActiveProfileExistsBeforeDeletion( |
| const CreateCallback& callback, const base::FilePath& profile_dir) { |
| - // In case we delete non-active profile, just proceed. |
| - const base::FilePath last_used_profile = |
| + // In case we delete non-active profile and current profile is valid, proceed. |
| + const base::FilePath last_used_profile_path = |
| GetLastUsedProfileDir(user_data_dir_); |
| const base::FilePath guest_profile_path = GetGuestProfilePath(); |
| - if (last_used_profile != profile_dir && |
| - last_used_profile != guest_profile_path) { |
| - FinishDeletingProfile(profile_dir, last_used_profile); |
| + Profile* last_used_profile = GetProfileByPath(last_used_profile_path); |
| + if (last_used_profile_path != profile_dir && |
| + last_used_profile_path != guest_profile_path && |
| + last_used_profile != nullptr && |
|
Bernhard Bauer
2017/01/27 16:17:40
Can the last used profile actually be null?
|
| + !last_used_profile->IsLegacySupervised()) { |
| + FinishDeletingProfile(profile_dir, last_used_profile_path); |
| return; |
| } |