Index: chrome/browser/profiles/profile_manager.cc |
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc |
index 2735519ad44c3de93ba549f0c84a1cfce7d33e00..bc04a193f627bb518263b7ea5ca4f82bf2cdf4c0 100644 |
--- a/chrome/browser/profiles/profile_manager.cc |
+++ b/chrome/browser/profiles/profile_manager.cc |
@@ -55,6 +55,7 @@ |
#include "chrome/browser/signin/signin_manager_factory.h" |
#include "chrome/browser/sync/profile_sync_service_factory.h" |
#include "chrome/browser/ui/browser.h" |
+#include "chrome/browser/ui/browser_finder.h" |
#include "chrome/browser/ui/browser_list.h" |
#include "chrome/browser/ui/sync/sync_promo_ui.h" |
#include "chrome/common/chrome_constants.h" |
@@ -1666,8 +1667,8 @@ void ProfileManager::BrowserListObserver::OnBrowserRemoved( |
// Do nothing if the profile is already being deleted. |
} else if (profile->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles)) { |
// Delete if the profile is an ephemeral profile. |
- g_browser_process->profile_manager()->ScheduleProfileForDeletion( |
- path, ProfileManager::CreateCallback()); |
+ g_browser_process->profile_manager() |
+ ->ScheduleForcedEphemeralProfileForDeletion(path); |
} else { |
#if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS) |
// Gather statistics and store into ProfileInfoCache. For incognito profile |
@@ -1726,6 +1727,25 @@ void ProfileManager::OnNewActiveProfileLoaded( |
if (!original_callback.is_null()) |
original_callback.Run(loaded_profile, status); |
} |
+ |
+namespace { |
Mike Lerman
2017/03/01 19:21:20
style nit, no strong preference: shouldn't this go
|
+ |
+// Helper function for ScheduleForcedEphemeralProfileForDeletion. |
+bool IsProfileEphemeral(ProfileAttributesStorage* storage, |
+ const base::FilePath& profile_dir) { |
+ ProfileAttributesEntry* entry = nullptr; |
+ return storage->GetProfileAttributesWithPath(profile_dir, &entry) && |
+ entry->IsEphemeral(); |
+} |
+ |
+} // namespace |
+ |
+void ProfileManager::ScheduleForcedEphemeralProfileForDeletion( |
+ const base::FilePath& profile_dir) { |
+ DCHECK(!chrome::FindAnyBrowser(GetProfileByPath(profile_dir), true)); |
+ DCHECK(IsProfileEphemeral(&GetProfileAttributesStorage(), profile_dir)); |
+ FinishDeletingProfile(profile_dir, GenerateNextProfileDirectoryPath()); |
+} |
#endif // !defined(OS_ANDROID) |
ProfileManagerWithoutInit::ProfileManagerWithoutInit( |