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

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

Issue 50293011: Improve ephemeral profiles clean up code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 1 month 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
Index: chrome/browser/profiles/profile_manager.cc
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc
index 602766ee317e77069c778b85c34ec9515625bb81..9b8966a76c29a43545d9ab57a5dfd058345bdd98 100644
--- a/chrome/browser/profiles/profile_manager.cc
+++ b/chrome/browser/profiles/profile_manager.cc
@@ -165,6 +165,15 @@ bool IsProfileMarkedForDeletion(const base::FilePath& profile_path) {
profile_path) != ProfilesToDelete().end();
}
+// Physically remove deleted profile directories from disk.
+void NukeProfileFromDisk(const base::FilePath& profile) {
jochen (gone - plz use gerrit) 2013/11/05 13:03:25 profile_path
jochen (gone - plz use gerrit) 2013/11/05 16:50:38 What about this?
pastarmovj 2013/11/06 09:49:39 Sorry I renamed the one below but skipped this one
+ // Delete both the profile directory and its corresponding cache.
+ base::FilePath cache_path;
+ chrome::GetUserCacheDirectory(profile, &cache_path);
+ base::DeleteFile(profile, true);
+ base::DeleteFile(cache_path, true);
+}
+
#if defined(OS_CHROMEOS)
void CheckCryptohomeIsMounted(chromeos::DBusMethodCallStatus call_status,
bool is_mounted) {
@@ -198,11 +207,7 @@ void ProfileManager::NukeDeletedProfilesFromDisk() {
ProfilesToDelete().begin();
it != ProfilesToDelete().end();
++it) {
- // Delete both the profile directory and its corresponding cache.
- base::FilePath cache_path;
- chrome::GetUserCacheDirectory(*it, &cache_path);
- base::DeleteFile(*it, true);
- base::DeleteFile(cache_path, true);
+ NukeProfileFromDisk(*it);
}
ProfilesToDelete().clear();
}
@@ -300,6 +305,10 @@ ProfileManager::ProfileManager(const base::FilePath& user_data_dir)
this,
chrome::NOTIFICATION_BROWSER_CLOSE_CANCELLED,
content::NotificationService::AllSources());
+ registrar_.Add(
+ this,
+ chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
+ content::NotificationService::AllSources());
if (ProfileShortcutManager::IsFeatureEnabled() && !user_data_dir_.empty())
profile_shortcut_manager_.reset(ProfileShortcutManager::Create(
@@ -651,6 +660,10 @@ void ProfileManager::Observe(
}
break;
}
+ case chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED: {
+ save_active_profiles = !closing_all_browsers_;
+ break;
+ }
default: {
NOTREACHED();
break;
@@ -862,13 +875,15 @@ void ProfileManager::OnProfileCreated(Profile* profile,
profiles_info_.erase(iter);
}
- // If this was the guest profile, finish setting its incognito status.
- if (profile->GetPath() == ProfileManager::GetGuestProfilePath())
- SetGuestProfilePrefs(profile);
+ if (profile) {
pastarmovj 2013/11/04 15:20:49 This is not related directly to what the rest of t
+ // If this was the guest profile, finish setting its incognito status.
+ if (profile->GetPath() == ProfileManager::GetGuestProfilePath())
+ SetGuestProfilePrefs(profile);
- // Invoke CREATED callback for incognito profiles.
- if (profile && go_off_the_record)
- RunCallbacks(callbacks, profile, Profile::CREATE_STATUS_CREATED);
+ // Invoke CREATED callback for incognito profiles.
+ if (go_off_the_record)
+ RunCallbacks(callbacks, profile, Profile::CREATE_STATUS_CREATED);
+ }
// Invoke INITIALIZED or FAIL for all profiles.
RunCallbacks(callbacks, profile,
@@ -984,6 +999,11 @@ void ProfileManager::AddProfileToCache(Profile* profile) {
username,
icon_index,
managed_user_id);
+
+ if (profile->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles)) {
+ cache.SetProfileIsEphemeralAtIndex(
+ cache.GetIndexOfProfileWithPath(profile->GetPath()), true);
+ }
}
void ProfileManager::InitProfileUserPrefs(Profile* profile) {
@@ -1116,6 +1136,17 @@ void ProfileManager::ScheduleProfileForDeletion(
FinishDeletingProfile(profile_dir);
}
+// static
+void ProfileManager::CleanUpStaleProfiles(
+ std::vector<base::FilePath> profiles) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+
+ for (std::vector<base::FilePath>::iterator it = profiles.begin();
+ it != profiles.end(); ++it) {
+ NukeProfileFromDisk(*it);
+ }
+}
+
void ProfileManager::OnNewActiveProfileLoaded(
const base::FilePath& profile_to_delete_path,
const base::FilePath& last_non_managed_profile_path,
« chrome/browser/profiles/profile_manager.h ('K') | « chrome/browser/profiles/profile_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698