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

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

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

Powered by Google App Engine
This is Rietveld 408576698