| OLD | NEW |
| 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 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 | 664 |
| 665 std::vector<Profile*> to_return; | 665 std::vector<Profile*> to_return; |
| 666 if (local_state->HasPrefPath(prefs::kProfilesLastActive) && | 666 if (local_state->HasPrefPath(prefs::kProfilesLastActive) && |
| 667 local_state->GetList(prefs::kProfilesLastActive)) { | 667 local_state->GetList(prefs::kProfilesLastActive)) { |
| 668 // Make a copy because the list might change in the calls to GetProfile. | 668 // Make a copy because the list might change in the calls to GetProfile. |
| 669 std::unique_ptr<base::ListValue> profile_list( | 669 std::unique_ptr<base::ListValue> profile_list( |
| 670 local_state->GetList(prefs::kProfilesLastActive)->DeepCopy()); | 670 local_state->GetList(prefs::kProfilesLastActive)->DeepCopy()); |
| 671 base::ListValue::const_iterator it; | 671 base::ListValue::const_iterator it; |
| 672 for (it = profile_list->begin(); it != profile_list->end(); ++it) { | 672 for (it = profile_list->begin(); it != profile_list->end(); ++it) { |
| 673 std::string profile_path; | 673 std::string profile_path; |
| 674 if (!(*it)->GetAsString(&profile_path) || | 674 if (!it->GetAsString(&profile_path) || profile_path.empty() || |
| 675 profile_path.empty() || | |
| 676 profile_path == | 675 profile_path == |
| 677 base::FilePath(chrome::kSystemProfileDir).AsUTF8Unsafe()) { | 676 base::FilePath(chrome::kSystemProfileDir).AsUTF8Unsafe()) { |
| 678 LOG(WARNING) << "Invalid entry in " << prefs::kProfilesLastActive; | 677 LOG(WARNING) << "Invalid entry in " << prefs::kProfilesLastActive; |
| 679 continue; | 678 continue; |
| 680 } | 679 } |
| 681 Profile* profile = GetProfile(user_data_dir.AppendASCII(profile_path)); | 680 Profile* profile = GetProfile(user_data_dir.AppendASCII(profile_path)); |
| 682 if (profile) | 681 if (profile) |
| 683 to_return.push_back(profile); | 682 to_return.push_back(profile); |
| 684 } | 683 } |
| 685 } | 684 } |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 887 } | 886 } |
| 888 } | 887 } |
| 889 | 888 |
| 890 void ProfileManager::CleanUpDeletedProfiles() { | 889 void ProfileManager::CleanUpDeletedProfiles() { |
| 891 PrefService* local_state = g_browser_process->local_state(); | 890 PrefService* local_state = g_browser_process->local_state(); |
| 892 DCHECK(local_state); | 891 DCHECK(local_state); |
| 893 const base::ListValue* deleted_profiles = | 892 const base::ListValue* deleted_profiles = |
| 894 local_state->GetList(prefs::kProfilesDeleted); | 893 local_state->GetList(prefs::kProfilesDeleted); |
| 895 DCHECK(deleted_profiles); | 894 DCHECK(deleted_profiles); |
| 896 | 895 |
| 897 for (const std::unique_ptr<base::Value>& value : *deleted_profiles) { | 896 for (const base::Value& value : *deleted_profiles) { |
| 898 base::FilePath profile_path; | 897 base::FilePath profile_path; |
| 899 bool is_valid_profile_path = | 898 bool is_valid_profile_path = |
| 900 base::GetValueAsFilePath(*value, &profile_path) && | 899 base::GetValueAsFilePath(value, &profile_path) && |
| 901 profile_path.DirName() == user_data_dir(); | 900 profile_path.DirName() == user_data_dir(); |
| 902 // Although it should never happen, make sure this is a valid path in the | 901 // Although it should never happen, make sure this is a valid path in the |
| 903 // user_data_dir, so we don't accidentially delete something else. | 902 // user_data_dir, so we don't accidentially delete something else. |
| 904 if (is_valid_profile_path) { | 903 if (is_valid_profile_path) { |
| 905 if (base::PathExists(profile_path)) { | 904 if (base::PathExists(profile_path)) { |
| 906 LOG(WARNING) << "Files of a deleted profile still exist after restart. " | 905 LOG(WARNING) << "Files of a deleted profile still exist after restart. " |
| 907 "Cleaning up now."; | 906 "Cleaning up now."; |
| 908 BrowserThread::PostTaskAndReply( | 907 BrowserThread::PostTaskAndReply( |
| 909 BrowserThread::FILE, FROM_HERE, | 908 BrowserThread::FILE, FROM_HERE, |
| 910 base::Bind(&NukeProfileFromDisk, profile_path), | 909 base::Bind(&NukeProfileFromDisk, profile_path), |
| 911 base::Bind(&ProfileCleanedUp, value.get())); | 910 base::Bind(&ProfileCleanedUp, &value)); |
| 912 } else { | 911 } else { |
| 913 // Everything is fine, the profile was removed on shutdown. | 912 // Everything is fine, the profile was removed on shutdown. |
| 914 BrowserThread::PostTask( | 913 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 915 BrowserThread::UI, FROM_HERE, | 914 base::Bind(&ProfileCleanedUp, &value)); |
| 916 base::Bind(&ProfileCleanedUp, value.get())); | |
| 917 } | 915 } |
| 918 } else { | 916 } else { |
| 919 LOG(ERROR) << "Found invalid profile path in deleted_profiles: " | 917 LOG(ERROR) << "Found invalid profile path in deleted_profiles: " |
| 920 << profile_path.AsUTF8Unsafe(); | 918 << profile_path.AsUTF8Unsafe(); |
| 921 NOTREACHED(); | 919 NOTREACHED(); |
| 922 } | 920 } |
| 923 } | 921 } |
| 924 } | 922 } |
| 925 | 923 |
| 926 void ProfileManager::InitProfileUserPrefs(Profile* profile) { | 924 void ProfileManager::InitProfileUserPrefs(Profile* profile) { |
| (...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1765 | 1763 |
| 1766 const base::FilePath new_active_profile_dir = | 1764 const base::FilePath new_active_profile_dir = |
| 1767 found_entry ? found_entry->GetPath() : GenerateNextProfileDirectoryPath(); | 1765 found_entry ? found_entry->GetPath() : GenerateNextProfileDirectoryPath(); |
| 1768 FinishDeletingProfile(profile_dir, new_active_profile_dir); | 1766 FinishDeletingProfile(profile_dir, new_active_profile_dir); |
| 1769 } | 1767 } |
| 1770 #endif // !defined(OS_ANDROID) | 1768 #endif // !defined(OS_ANDROID) |
| 1771 | 1769 |
| 1772 ProfileManagerWithoutInit::ProfileManagerWithoutInit( | 1770 ProfileManagerWithoutInit::ProfileManagerWithoutInit( |
| 1773 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { | 1771 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { |
| 1774 } | 1772 } |
| OLD | NEW |