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

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

Issue 2905903002: Delete the PreferenceMACs on profile deletion. (Closed)
Patch Set: Fix to get OSX-only ActiveProfileDeletedNextProfileDeletedToo test to pass Created 3 years, 5 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') | components/prefs/in_memory_pref_store.h » ('j') | 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 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after
1450 } 1450 }
1451 1451
1452 // Create and/or load fallback profile. 1452 // Create and/or load fallback profile.
1453 CreateProfileAsync(fallback_profile_path, 1453 CreateProfileAsync(fallback_profile_path,
1454 base::Bind(&ProfileManager::OnNewActiveProfileLoaded, 1454 base::Bind(&ProfileManager::OnNewActiveProfileLoaded,
1455 base::Unretained(this), profile_dir, 1455 base::Unretained(this), profile_dir,
1456 fallback_profile_path, callback), 1456 fallback_profile_path, callback),
1457 new_profile_name, new_avatar_url, std::string()); 1457 new_profile_name, new_avatar_url, std::string());
1458 } 1458 }
1459 1459
1460 void ProfileManager::FinishDeletingProfile( 1460 void ProfileManager::OnLoadProfileForProfileDeletion(
1461 const base::FilePath& profile_dir, 1461 const base::FilePath& profile_dir,
1462 const base::FilePath& new_active_profile_dir) { 1462 Profile* profile) {
1463 // Update the last used profile pref before closing browser windows. This
1464 // way the correct last used profile is set for any notification observers.
1465 profiles::SetLastUsedProfile(
1466 new_active_profile_dir.BaseName().MaybeAsASCII());
1467
1468 ProfileAttributesStorage& storage = GetProfileAttributesStorage(); 1463 ProfileAttributesStorage& storage = GetProfileAttributesStorage();
1469 // TODO(sail): Due to bug 88586 we don't delete the profile instance. Once we 1464 // TODO(sail): Due to bug 88586 we don't delete the profile instance. Once we
1470 // start deleting the profile instance we need to close background apps too. 1465 // start deleting the profile instance we need to close background apps too.
1471 Profile* profile = GetProfileByPath(profile_dir);
1472
1473 if (profile) { 1466 if (profile) {
1474 // TODO: Migrate additional code in this block to observe this notification 1467 // TODO: Migrate additional code in this block to observe this notification
1475 // instead of being implemented here. 1468 // instead of being implemented here.
1476 content::NotificationService::current()->Notify( 1469 content::NotificationService::current()->Notify(
1477 chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, 1470 chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED,
1478 content::Source<Profile>(profile), 1471 content::Source<Profile>(profile),
1479 content::NotificationService::NoDetails()); 1472 content::NotificationService::NoDetails());
1480 1473
1481 // Disable sync for doomed profile. 1474 // Disable sync for doomed profile.
1482 if (ProfileSyncServiceFactory::GetInstance()->HasProfileSyncService( 1475 if (ProfileSyncServiceFactory::GetInstance()->HasProfileSyncService(
(...skipping 11 matching lines...) Expand all
1494 ->GetForProfile(profile) 1487 ->GetForProfile(profile)
1495 ->RequestStop(browser_sync::ProfileSyncService::CLEAR_DATA); 1488 ->RequestStop(browser_sync::ProfileSyncService::CLEAR_DATA);
1496 } 1489 }
1497 1490
1498 ProfileAttributesEntry* entry; 1491 ProfileAttributesEntry* entry;
1499 bool has_entry = storage.GetProfileAttributesWithPath(profile_dir, &entry); 1492 bool has_entry = storage.GetProfileAttributesWithPath(profile_dir, &entry);
1500 DCHECK(has_entry); 1493 DCHECK(has_entry);
1501 ProfileMetrics::LogProfileDelete(entry->IsAuthenticated()); 1494 ProfileMetrics::LogProfileDelete(entry->IsAuthenticated());
1502 // Some platforms store passwords in keychains. They should be removed. 1495 // Some platforms store passwords in keychains. They should be removed.
1503 scoped_refptr<password_manager::PasswordStore> password_store = 1496 scoped_refptr<password_manager::PasswordStore> password_store =
1504 PasswordStoreFactory::GetForProfile( 1497 PasswordStoreFactory::GetForProfile(profile,
1505 profile, ServiceAccessType::EXPLICIT_ACCESS).get(); 1498 ServiceAccessType::EXPLICIT_ACCESS)
1499 .get();
1506 if (password_store.get()) { 1500 if (password_store.get()) {
1507 password_store->RemoveLoginsCreatedBetween( 1501 password_store->RemoveLoginsCreatedBetween(
1508 base::Time(), base::Time::Max(), base::Closure()); 1502 base::Time(), base::Time::Max(), base::Closure());
1509 } 1503 }
1510 1504
1511 // The Profile Data doesn't get wiped until Chrome closes. Since we promised 1505 // The Profile Data doesn't get wiped until Chrome closes. Since we promised
1512 // that the user's data would be removed, do so immediately. 1506 // that the user's data would be removed, do so immediately.
1513 profiles::RemoveBrowsingDataForProfile(profile_dir); 1507 profiles::RemoveBrowsingDataForProfile(profile_dir);
1508
1509 // Clean-up pref data that won't be cleaned up by NukeProfileFromDisk.
Mr4D (OOO till 08-26) 2017/08/16 14:38:55 Looking at this code path there is no one calling
proberge 2017/08/16 19:49:55 NukeProfileFromDisk should be called for the profi
1510 profile->GetPrefs()->OnStoreDeletionFromDisk();
1514 } else { 1511 } else {
1515 // It is safe to delete a not yet loaded Profile from disk. 1512 // We failed to load the profile, but it's safe to delete a not yet loaded
1513 // Profile from disk.
1516 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 1514 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
1517 base::BindOnce(&NukeProfileFromDisk, profile_dir)); 1515 base::BindOnce(&NukeProfileFromDisk, profile_dir));
1518 } 1516 }
1519 1517
1520 // Queue even a profile that was nuked so it will be MarkedForDeletion and so
1521 // CreateProfileAsync can't create it.
1522 MarkProfileDirectoryForDeletion(profile_dir);
1523 storage.RemoveProfile(profile_dir); 1518 storage.RemoveProfile(profile_dir);
1524 ProfileMetrics::UpdateReportedProfilesStatistics(this); 1519 ProfileMetrics::UpdateReportedProfilesStatistics(this);
1525 } 1520 }
1521
1522 void ProfileManager::FinishDeletingProfile(
1523 const base::FilePath& profile_dir,
1524 const base::FilePath& new_active_profile_dir) {
1525 // Update the last used profile pref before closing browser windows. This
1526 // way the correct last used profile is set for any notification observers.
1527 profiles::SetLastUsedProfile(
1528 new_active_profile_dir.BaseName().MaybeAsASCII());
1529
1530 // Attempt to load the profile before deleting it.
Mr4D (OOO till 08-26) 2017/08/16 14:38:55 Can you please add some more information here towa
proberge 2017/08/16 19:49:55 Done.
1531 LoadProfileByPath(profile_dir, false,
1532 base::Bind(&ProfileManager::OnLoadProfileForProfileDeletion,
1533 base::Unretained(this), profile_dir));
1534
1535 // Prevents CreateProfileAsync from re-creating the profile.
1536 MarkProfileDirectoryForDeletion(profile_dir);
1537 }
1526 #endif // !defined(OS_ANDROID) 1538 #endif // !defined(OS_ANDROID)
1527 1539
1528 ProfileManager::ProfileInfo* ProfileManager::RegisterProfile( 1540 ProfileManager::ProfileInfo* ProfileManager::RegisterProfile(
1529 Profile* profile, 1541 Profile* profile,
1530 bool created) { 1542 bool created) {
1531 TRACE_EVENT0("browser", "ProfileManager::RegisterProfile"); 1543 TRACE_EVENT0("browser", "ProfileManager::RegisterProfile");
1532 ProfileInfo* info = new ProfileInfo(profile, created); 1544 ProfileInfo* info = new ProfileInfo(profile, created);
1533 profiles_info_.insert( 1545 profiles_info_.insert(
1534 std::make_pair(profile->GetPath(), linked_ptr<ProfileInfo>(info))); 1546 std::make_pair(profile->GetPath(), linked_ptr<ProfileInfo>(info)));
1535 return info; 1547 return info;
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1772 1784
1773 const base::FilePath new_active_profile_dir = 1785 const base::FilePath new_active_profile_dir =
1774 found_entry ? found_entry->GetPath() : GenerateNextProfileDirectoryPath(); 1786 found_entry ? found_entry->GetPath() : GenerateNextProfileDirectoryPath();
1775 FinishDeletingProfile(profile_dir, new_active_profile_dir); 1787 FinishDeletingProfile(profile_dir, new_active_profile_dir);
1776 } 1788 }
1777 #endif // !defined(OS_ANDROID) 1789 #endif // !defined(OS_ANDROID)
1778 1790
1779 ProfileManagerWithoutInit::ProfileManagerWithoutInit( 1791 ProfileManagerWithoutInit::ProfileManagerWithoutInit(
1780 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { 1792 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) {
1781 } 1793 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_manager.h ('k') | components/prefs/in_memory_pref_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698