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

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

Issue 25495003: Schedule an ephemeral profile for deletion once the last browser is closed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix the browser test to run on linux_aura. Created 7 years, 2 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 | « no previous file | chrome/browser/profiles/profile_manager_browsertest.cc » ('j') | 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 6140d201f264a2dcd22f13cda83b38abbe0ead3d..5256afc691898388a0c47fdc239908601dca96f8 100644
--- a/chrome/browser/profiles/profile_manager.cc
+++ b/chrome/browser/profiles/profile_manager.cc
@@ -36,6 +36,7 @@
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_iterator.h"
#include "chrome/browser/ui/sync/sync_promo_ui.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths_internal.h"
@@ -690,7 +691,23 @@ void ProfileManager::BrowserListObserver::OnBrowserAdded(
Browser* browser) {}
void ProfileManager::BrowserListObserver::OnBrowserRemoved(
- Browser* browser) {}
+ Browser* browser) {
+ Profile* profile = browser->profile();
+ for (chrome::BrowserIterator it; !it.done(); it.Next()) {
+ if (it->profile()->GetOriginalProfile() == profile->GetOriginalProfile())
+ // Not the last window for this profile.
+ return;
+ }
+
+ // If the last browser of a profile that is scheduled for deletion is closed
+ // do that now.
+ base::FilePath path = profile->GetPath();
+ if (profile->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles) &&
+ !IsProfileMarkedForDeletion(path)) {
+ g_browser_process->profile_manager()->ScheduleProfileForDeletion(
+ path, ProfileManager::CreateCallback());
+ }
+}
void ProfileManager::BrowserListObserver::OnBrowserSetLastActive(
Browser* browser) {
« no previous file with comments | « no previous file | chrome/browser/profiles/profile_manager_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698