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

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

Issue 2905903002: Delete the PreferenceMACs on profile deletion. (Closed)
Patch Set: Update comments Created 3 years, 4 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 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after
1444 } 1444 }
1445 1445
1446 // Create and/or load fallback profile. 1446 // Create and/or load fallback profile.
1447 CreateProfileAsync(fallback_profile_path, 1447 CreateProfileAsync(fallback_profile_path,
1448 base::Bind(&ProfileManager::OnNewActiveProfileLoaded, 1448 base::Bind(&ProfileManager::OnNewActiveProfileLoaded,
1449 base::Unretained(this), profile_dir, 1449 base::Unretained(this), profile_dir,
1450 fallback_profile_path, callback), 1450 fallback_profile_path, callback),
1451 new_profile_name, new_avatar_url, std::string()); 1451 new_profile_name, new_avatar_url, std::string());
1452 } 1452 }
1453 1453
1454 void ProfileManager::FinishDeletingProfile( 1454 void ProfileManager::OnLoadProfileForProfileDeletion(
1455 const base::FilePath& profile_dir, 1455 const base::FilePath& profile_dir,
1456 const base::FilePath& new_active_profile_dir) { 1456 Profile* profile) {
1457 // Update the last used profile pref before closing browser windows. This
1458 // way the correct last used profile is set for any notification observers.
1459 profiles::SetLastUsedProfile(
1460 new_active_profile_dir.BaseName().MaybeAsASCII());
1461
1462 ProfileAttributesStorage& storage = GetProfileAttributesStorage(); 1457 ProfileAttributesStorage& storage = GetProfileAttributesStorage();
1463 // TODO(sail): Due to bug 88586 we don't delete the profile instance. Once we 1458 // TODO(sail): Due to bug 88586 we don't delete the profile instance. Once we
1464 // start deleting the profile instance we need to close background apps too. 1459 // start deleting the profile instance we need to close background apps too.
1465 Profile* profile = GetProfileByPath(profile_dir);
1466
1467 if (profile) { 1460 if (profile) {
1468 // TODO: Migrate additional code in this block to observe this notification 1461 // TODO: Migrate additional code in this block to observe this notification
1469 // instead of being implemented here. 1462 // instead of being implemented here.
1470 content::NotificationService::current()->Notify( 1463 content::NotificationService::current()->Notify(
1471 chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, 1464 chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED,
1472 content::Source<Profile>(profile), 1465 content::Source<Profile>(profile),
1473 content::NotificationService::NoDetails()); 1466 content::NotificationService::NoDetails());
1474 1467
1475 // Disable sync for doomed profile. 1468 // Disable sync for doomed profile.
1476 if (ProfileSyncServiceFactory::GetInstance()->HasProfileSyncService( 1469 if (ProfileSyncServiceFactory::GetInstance()->HasProfileSyncService(
(...skipping 11 matching lines...) Expand all
1488 ->GetForProfile(profile) 1481 ->GetForProfile(profile)
1489 ->RequestStop(browser_sync::ProfileSyncService::CLEAR_DATA); 1482 ->RequestStop(browser_sync::ProfileSyncService::CLEAR_DATA);
1490 } 1483 }
1491 1484
1492 ProfileAttributesEntry* entry; 1485 ProfileAttributesEntry* entry;
1493 bool has_entry = storage.GetProfileAttributesWithPath(profile_dir, &entry); 1486 bool has_entry = storage.GetProfileAttributesWithPath(profile_dir, &entry);
1494 DCHECK(has_entry); 1487 DCHECK(has_entry);
1495 ProfileMetrics::LogProfileDelete(entry->IsAuthenticated()); 1488 ProfileMetrics::LogProfileDelete(entry->IsAuthenticated());
1496 // Some platforms store passwords in keychains. They should be removed. 1489 // Some platforms store passwords in keychains. They should be removed.
1497 scoped_refptr<password_manager::PasswordStore> password_store = 1490 scoped_refptr<password_manager::PasswordStore> password_store =
1498 PasswordStoreFactory::GetForProfile( 1491 PasswordStoreFactory::GetForProfile(profile,
1499 profile, ServiceAccessType::EXPLICIT_ACCESS).get(); 1492 ServiceAccessType::EXPLICIT_ACCESS)
1493 .get();
1500 if (password_store.get()) { 1494 if (password_store.get()) {
1501 password_store->RemoveLoginsCreatedBetween( 1495 password_store->RemoveLoginsCreatedBetween(
1502 base::Time(), base::Time::Max(), base::Closure()); 1496 base::Time(), base::Time::Max(), base::Closure());
1503 } 1497 }
1504 1498
1505 // The Profile Data doesn't get wiped until Chrome closes. Since we promised 1499 // The Profile Data doesn't get wiped until Chrome closes. Since we promised
1506 // that the user's data would be removed, do so immediately. 1500 // that the user's data would be removed, do so immediately.
1507 profiles::RemoveBrowsingDataForProfile(profile_dir); 1501 profiles::RemoveBrowsingDataForProfile(profile_dir);
1502
1503 // Clean-up pref data that won't be cleaned up by deleting the profile dir.
1504 profile->GetPrefs()->OnStoreDeletionFromDisk();
1508 } else { 1505 } else {
1509 // It is safe to delete a not yet loaded Profile from disk. 1506 // We failed to load the profile, but it's safe to delete a not yet loaded
1507 // Profile from disk.
1510 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 1508 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
1511 base::BindOnce(&NukeProfileFromDisk, profile_dir)); 1509 base::BindOnce(&NukeProfileFromDisk, profile_dir));
1512 } 1510 }
1513 1511
1514 // Queue even a profile that was nuked so it will be MarkedForDeletion and so
1515 // CreateProfileAsync can't create it.
1516 MarkProfileDirectoryForDeletion(profile_dir);
1517 storage.RemoveProfile(profile_dir); 1512 storage.RemoveProfile(profile_dir);
1518 ProfileMetrics::UpdateReportedProfilesStatistics(this); 1513 ProfileMetrics::UpdateReportedProfilesStatistics(this);
1519 } 1514 }
1515
1516 void ProfileManager::FinishDeletingProfile(
1517 const base::FilePath& profile_dir,
1518 const base::FilePath& new_active_profile_dir) {
1519 // Update the last used profile pref before closing browser windows. This
1520 // way the correct last used profile is set for any notification observers.
1521 profiles::SetLastUsedProfile(
1522 new_active_profile_dir.BaseName().MaybeAsASCII());
1523
1524 // Attempt to load the profile before deleting it to properly clean up
1525 // profile-specific data stored outside the profile directory.
1526 LoadProfileByPath(profile_dir, false,
1527 base::Bind(&ProfileManager::OnLoadProfileForProfileDeletion,
1528 base::Unretained(this), profile_dir));
1529
1530 // Prevents CreateProfileAsync from re-creating the profile.
1531 MarkProfileDirectoryForDeletion(profile_dir);
1532 }
1520 #endif // !defined(OS_ANDROID) 1533 #endif // !defined(OS_ANDROID)
1521 1534
1522 ProfileManager::ProfileInfo* ProfileManager::RegisterProfile( 1535 ProfileManager::ProfileInfo* ProfileManager::RegisterProfile(
1523 Profile* profile, 1536 Profile* profile,
1524 bool created) { 1537 bool created) {
1525 TRACE_EVENT0("browser", "ProfileManager::RegisterProfile"); 1538 TRACE_EVENT0("browser", "ProfileManager::RegisterProfile");
1526 auto info = base::MakeUnique<ProfileInfo>(profile, created); 1539 auto info = base::MakeUnique<ProfileInfo>(profile, created);
1527 ProfileInfo* info_raw = info.get(); 1540 ProfileInfo* info_raw = info.get();
1528 profiles_info_.insert(std::make_pair(profile->GetPath(), std::move(info))); 1541 profiles_info_.insert(std::make_pair(profile->GetPath(), std::move(info)));
1529 return info_raw; 1542 return info_raw;
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1768 1781
1769 const base::FilePath new_active_profile_dir = 1782 const base::FilePath new_active_profile_dir =
1770 found_entry ? found_entry->GetPath() : GenerateNextProfileDirectoryPath(); 1783 found_entry ? found_entry->GetPath() : GenerateNextProfileDirectoryPath();
1771 FinishDeletingProfile(profile_dir, new_active_profile_dir); 1784 FinishDeletingProfile(profile_dir, new_active_profile_dir);
1772 } 1785 }
1773 #endif // !defined(OS_ANDROID) 1786 #endif // !defined(OS_ANDROID)
1774 1787
1775 ProfileManagerWithoutInit::ProfileManagerWithoutInit( 1788 ProfileManagerWithoutInit::ProfileManagerWithoutInit(
1776 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { 1789 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) {
1777 } 1790 }
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