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

Side by Side 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, 9 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
« no previous file with comments | « chrome/browser/profiles/profile_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "chrome/browser/sessions/session_service_factory.h" 48 #include "chrome/browser/sessions/session_service_factory.h"
49 #include "chrome/browser/signin/account_fetcher_service_factory.h" 49 #include "chrome/browser/signin/account_fetcher_service_factory.h"
50 #include "chrome/browser/signin/account_reconcilor_factory.h" 50 #include "chrome/browser/signin/account_reconcilor_factory.h"
51 #include "chrome/browser/signin/account_tracker_service_factory.h" 51 #include "chrome/browser/signin/account_tracker_service_factory.h"
52 #include "chrome/browser/signin/cross_device_promo.h" 52 #include "chrome/browser/signin/cross_device_promo.h"
53 #include "chrome/browser/signin/cross_device_promo_factory.h" 53 #include "chrome/browser/signin/cross_device_promo_factory.h"
54 #include "chrome/browser/signin/gaia_cookie_manager_service_factory.h" 54 #include "chrome/browser/signin/gaia_cookie_manager_service_factory.h"
55 #include "chrome/browser/signin/signin_manager_factory.h" 55 #include "chrome/browser/signin/signin_manager_factory.h"
56 #include "chrome/browser/sync/profile_sync_service_factory.h" 56 #include "chrome/browser/sync/profile_sync_service_factory.h"
57 #include "chrome/browser/ui/browser.h" 57 #include "chrome/browser/ui/browser.h"
58 #include "chrome/browser/ui/browser_finder.h"
58 #include "chrome/browser/ui/browser_list.h" 59 #include "chrome/browser/ui/browser_list.h"
59 #include "chrome/browser/ui/sync/sync_promo_ui.h" 60 #include "chrome/browser/ui/sync/sync_promo_ui.h"
60 #include "chrome/common/chrome_constants.h" 61 #include "chrome/common/chrome_constants.h"
61 #include "chrome/common/chrome_paths_internal.h" 62 #include "chrome/common/chrome_paths_internal.h"
62 #include "chrome/common/chrome_switches.h" 63 #include "chrome/common/chrome_switches.h"
63 #include "chrome/common/features.h" 64 #include "chrome/common/features.h"
64 #include "chrome/common/logging_chrome.h" 65 #include "chrome/common/logging_chrome.h"
65 #include "chrome/common/pref_names.h" 66 #include "chrome/common/pref_names.h"
66 #include "chrome/common/url_constants.h" 67 #include "chrome/common/url_constants.h"
67 #include "chrome/grit/generated_resources.h" 68 #include "chrome/grit/generated_resources.h"
(...skipping 1591 matching lines...) Expand 10 before | Expand all | Expand 10 after
1659 for (auto* browser : *BrowserList::GetInstance()) { 1660 for (auto* browser : *BrowserList::GetInstance()) {
1660 if (browser->profile()->GetOriginalProfile() == original_profile) 1661 if (browser->profile()->GetOriginalProfile() == original_profile)
1661 return; 1662 return;
1662 } 1663 }
1663 1664
1664 base::FilePath path = profile->GetPath(); 1665 base::FilePath path = profile->GetPath();
1665 if (IsProfileDirectoryMarkedForDeletion(path)) { 1666 if (IsProfileDirectoryMarkedForDeletion(path)) {
1666 // Do nothing if the profile is already being deleted. 1667 // Do nothing if the profile is already being deleted.
1667 } else if (profile->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles)) { 1668 } else if (profile->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles)) {
1668 // Delete if the profile is an ephemeral profile. 1669 // Delete if the profile is an ephemeral profile.
1669 g_browser_process->profile_manager()->ScheduleProfileForDeletion( 1670 g_browser_process->profile_manager()
1670 path, ProfileManager::CreateCallback()); 1671 ->ScheduleForcedEphemeralProfileForDeletion(path);
1671 } else { 1672 } else {
1672 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS) 1673 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS)
1673 // Gather statistics and store into ProfileInfoCache. For incognito profile 1674 // Gather statistics and store into ProfileInfoCache. For incognito profile
1674 // we gather the statistics of its parent profile instead, because a window 1675 // we gather the statistics of its parent profile instead, because a window
1675 // of the parent profile was open. 1676 // of the parent profile was open.
1676 if (!profile->IsSystemProfile() && !original_profile->IsSystemProfile()) { 1677 if (!profile->IsSystemProfile() && !original_profile->IsSystemProfile()) {
1677 ProfileStatisticsFactory::GetForProfile(original_profile)-> 1678 ProfileStatisticsFactory::GetForProfile(original_profile)->
1678 GatherStatistics(profiles::ProfileStatisticsCallback()); 1679 GatherStatistics(profiles::ProfileStatisticsCallback());
1679 } 1680 }
1680 #endif 1681 #endif
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1719 // the next available profile. 1720 // the next available profile.
1720 EnsureActiveProfileExistsBeforeDeletion(original_callback, 1721 EnsureActiveProfileExistsBeforeDeletion(original_callback,
1721 profile_to_delete_path); 1722 profile_to_delete_path);
1722 return; 1723 return;
1723 } 1724 }
1724 1725
1725 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); 1726 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path);
1726 if (!original_callback.is_null()) 1727 if (!original_callback.is_null())
1727 original_callback.Run(loaded_profile, status); 1728 original_callback.Run(loaded_profile, status);
1728 } 1729 }
1730
1731 namespace {
Mike Lerman 2017/03/01 19:21:20 style nit, no strong preference: shouldn't this go
1732
1733 // Helper function for ScheduleForcedEphemeralProfileForDeletion.
1734 bool IsProfileEphemeral(ProfileAttributesStorage* storage,
1735 const base::FilePath& profile_dir) {
1736 ProfileAttributesEntry* entry = nullptr;
1737 return storage->GetProfileAttributesWithPath(profile_dir, &entry) &&
1738 entry->IsEphemeral();
1739 }
1740
1741 } // namespace
1742
1743 void ProfileManager::ScheduleForcedEphemeralProfileForDeletion(
1744 const base::FilePath& profile_dir) {
1745 DCHECK(!chrome::FindAnyBrowser(GetProfileByPath(profile_dir), true));
1746 DCHECK(IsProfileEphemeral(&GetProfileAttributesStorage(), profile_dir));
1747 FinishDeletingProfile(profile_dir, GenerateNextProfileDirectoryPath());
1748 }
1729 #endif // !defined(OS_ANDROID) 1749 #endif // !defined(OS_ANDROID)
1730 1750
1731 ProfileManagerWithoutInit::ProfileManagerWithoutInit( 1751 ProfileManagerWithoutInit::ProfileManagerWithoutInit(
1732 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { 1752 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) {
1733 } 1753 }
OLDNEW
« 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