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

Side by Side Diff: chrome/browser/profiles/profile_manager.cc

Issue 2698683002: Forced ephemeral profile deletion on browser removal crash fix. (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/profiles/profile_manager.h" 5 #include "chrome/browser/profiles/profile_manager.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 // deletion is also cancelled. (crbug.com/289390) 805 // deletion is also cancelled. (crbug.com/289390)
806 BrowserList::CloseAllBrowsersWithProfile( 806 BrowserList::CloseAllBrowsersWithProfile(
807 profile, 807 profile,
808 base::Bind(&ProfileManager::EnsureActiveProfileExistsBeforeDeletion, 808 base::Bind(&ProfileManager::EnsureActiveProfileExistsBeforeDeletion,
809 base::Unretained(this), callback), 809 base::Unretained(this), callback),
810 base::Bind(&CancelProfileDeletion)); 810 base::Bind(&CancelProfileDeletion));
811 } else { 811 } else {
812 EnsureActiveProfileExistsBeforeDeletion(callback, profile_dir); 812 EnsureActiveProfileExistsBeforeDeletion(callback, profile_dir);
813 } 813 }
814 } 814 }
815
816 void ProfileManager::ScheduleForcedEphemeralProfileForDeletion(
817 const base::FilePath& profile_dir) {
818 FinishDeletingProfile(profile_dir, GenerateNextProfileDirectoryPath());
Bernhard Bauer 2017/02/15 18:03:30 Just to confirm: This updates the last used profil
palar 2017/02/16 10:39:04 Exacly. Upon browser start a new profile at the sp
819 }
820
815 #endif // !defined(OS_ANDROID) 821 #endif // !defined(OS_ANDROID)
816 822
817 void ProfileManager::AutoloadProfiles() { 823 void ProfileManager::AutoloadProfiles() {
818 // If running in the background is disabled for the browser, do not autoload 824 // If running in the background is disabled for the browser, do not autoload
819 // any profiles. 825 // any profiles.
820 PrefService* local_state = g_browser_process->local_state(); 826 PrefService* local_state = g_browser_process->local_state();
821 DCHECK(local_state); 827 DCHECK(local_state);
822 if (!local_state->HasPrefPath(prefs::kBackgroundModeEnabled) || 828 if (!local_state->HasPrefPath(prefs::kBackgroundModeEnabled) ||
823 !local_state->GetBoolean(prefs::kBackgroundModeEnabled)) { 829 !local_state->GetBoolean(prefs::kBackgroundModeEnabled)) {
824 return; 830 return;
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
1659 for (auto* browser : *BrowserList::GetInstance()) { 1665 for (auto* browser : *BrowserList::GetInstance()) {
1660 if (browser->profile()->GetOriginalProfile() == original_profile) 1666 if (browser->profile()->GetOriginalProfile() == original_profile)
1661 return; 1667 return;
1662 } 1668 }
1663 1669
1664 base::FilePath path = profile->GetPath(); 1670 base::FilePath path = profile->GetPath();
1665 if (IsProfileDirectoryMarkedForDeletion(path)) { 1671 if (IsProfileDirectoryMarkedForDeletion(path)) {
1666 // Do nothing if the profile is already being deleted. 1672 // Do nothing if the profile is already being deleted.
1667 } else if (profile->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles)) { 1673 } else if (profile->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles)) {
1668 // Delete if the profile is an ephemeral profile. 1674 // Delete if the profile is an ephemeral profile.
1669 g_browser_process->profile_manager()->ScheduleProfileForDeletion( 1675 g_browser_process->profile_manager()
1670 path, ProfileManager::CreateCallback()); 1676 ->ScheduleForcedEphemeralProfileForDeletion(path);
1671 } else { 1677 } else {
1672 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS) 1678 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS)
1673 // Gather statistics and store into ProfileInfoCache. For incognito profile 1679 // Gather statistics and store into ProfileInfoCache. For incognito profile
1674 // we gather the statistics of its parent profile instead, because a window 1680 // we gather the statistics of its parent profile instead, because a window
1675 // of the parent profile was open. 1681 // of the parent profile was open.
1676 if (!profile->IsSystemProfile() && !original_profile->IsSystemProfile()) { 1682 if (!profile->IsSystemProfile() && !original_profile->IsSystemProfile()) {
1677 ProfileStatisticsFactory::GetForProfile(original_profile)-> 1683 ProfileStatisticsFactory::GetForProfile(original_profile)->
1678 GatherStatistics(profiles::ProfileStatisticsCallback()); 1684 GatherStatistics(profiles::ProfileStatisticsCallback());
1679 } 1685 }
1680 #endif 1686 #endif
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 1730
1725 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); 1731 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path);
1726 if (!original_callback.is_null()) 1732 if (!original_callback.is_null())
1727 original_callback.Run(loaded_profile, status); 1733 original_callback.Run(loaded_profile, status);
1728 } 1734 }
1729 #endif // !defined(OS_ANDROID) 1735 #endif // !defined(OS_ANDROID)
1730 1736
1731 ProfileManagerWithoutInit::ProfileManagerWithoutInit( 1737 ProfileManagerWithoutInit::ProfileManagerWithoutInit(
1732 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { 1738 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) {
1733 } 1739 }
OLDNEW
« 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