Commit f1fa44a5 authored by Nicolas Ouellet-Payeur's avatar Nicolas Ouellet-Payeur Committed by Commit Bot

[Profiles] Make DestroyProfileOnBrowserClose work with Background Mode

Don't run DestroyProfileOnBrowserClose logic if Background Mode is
enabled, i.e. wait for the entire browser to exit before destroying
the Profile object.

Bug: 88586, 566835
Change-Id: I593d5537fc494bab1cd435b65cfc57075d92cfe2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2476173Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Commit-Queue: Nicolas Ouellet-Payeur <nicolaso@chromium.org>
Cr-Commit-Position: refs/heads/master@{#819437}
parent 0bd8b8c7
......@@ -1886,14 +1886,18 @@ void ProfileManager::OnBrowserClosed(Browser* browser) {
if (profile->IsGuestSession() || profile->IsEphemeralGuestProfile())
CleanUpGuestProfile();
ProfileAttributesEntry* entry;
bool background_mode =
GetProfileAttributesStorage().GetProfileAttributesWithPath(
profile->GetPath(), &entry) &&
entry->GetBackgroundStatus();
if (base::FeatureList::IsEnabled(features::kDestroyProfileOnBrowserClose) &&
!profile->IsOffTheRecord() &&
!profile->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles)) {
!profile->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles) &&
!background_mode) {
// TODO(crbug.com/88586): Add EarlyProfileCleanup support for Guest and
// Ephemeral profiles.
// TODO(crbug.com/88586): Make sure this works with Background Mode.
// Post a task to remove the Profile, so other OnBrowserClosed() hooks and
// the destructor for Browser can run without referencing a deleted Profile.
content::GetUIThreadTaskRunner({})->PostTask(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment