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

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

Issue 2698683002: Forced ephemeral profile deletion on browser removal crash fix. (Closed)
Patch Set: Added DCHECK Created 3 years, 10 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') | no next file » | 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 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(
« no previous file with comments | « chrome/browser/profiles/profile_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698