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

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

Issue 2740143002: Change base::Value::ListStorage to std::vector<base::Value> (Closed)
Patch Set: Fix Android Compilation Error 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
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 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 672
673 std::vector<Profile*> to_return; 673 std::vector<Profile*> to_return;
674 if (local_state->HasPrefPath(prefs::kProfilesLastActive) && 674 if (local_state->HasPrefPath(prefs::kProfilesLastActive) &&
675 local_state->GetList(prefs::kProfilesLastActive)) { 675 local_state->GetList(prefs::kProfilesLastActive)) {
676 // Make a copy because the list might change in the calls to GetProfile. 676 // Make a copy because the list might change in the calls to GetProfile.
677 std::unique_ptr<base::ListValue> profile_list( 677 std::unique_ptr<base::ListValue> profile_list(
678 local_state->GetList(prefs::kProfilesLastActive)->DeepCopy()); 678 local_state->GetList(prefs::kProfilesLastActive)->DeepCopy());
679 base::ListValue::const_iterator it; 679 base::ListValue::const_iterator it;
680 for (it = profile_list->begin(); it != profile_list->end(); ++it) { 680 for (it = profile_list->begin(); it != profile_list->end(); ++it) {
681 std::string profile_path; 681 std::string profile_path;
682 if (!(*it)->GetAsString(&profile_path) || 682 if (!it->GetAsString(&profile_path) || profile_path.empty() ||
683 profile_path.empty() ||
684 profile_path == 683 profile_path ==
685 base::FilePath(chrome::kSystemProfileDir).AsUTF8Unsafe()) { 684 base::FilePath(chrome::kSystemProfileDir).AsUTF8Unsafe()) {
686 LOG(WARNING) << "Invalid entry in " << prefs::kProfilesLastActive; 685 LOG(WARNING) << "Invalid entry in " << prefs::kProfilesLastActive;
687 continue; 686 continue;
688 } 687 }
689 Profile* profile = GetProfile(user_data_dir.AppendASCII(profile_path)); 688 Profile* profile = GetProfile(user_data_dir.AppendASCII(profile_path));
690 if (profile) 689 if (profile)
691 to_return.push_back(profile); 690 to_return.push_back(profile);
692 } 691 }
693 } 692 }
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 } 894 }
896 } 895 }
897 896
898 void ProfileManager::CleanUpDeletedProfiles() { 897 void ProfileManager::CleanUpDeletedProfiles() {
899 PrefService* local_state = g_browser_process->local_state(); 898 PrefService* local_state = g_browser_process->local_state();
900 DCHECK(local_state); 899 DCHECK(local_state);
901 const base::ListValue* deleted_profiles = 900 const base::ListValue* deleted_profiles =
902 local_state->GetList(prefs::kProfilesDeleted); 901 local_state->GetList(prefs::kProfilesDeleted);
903 DCHECK(deleted_profiles); 902 DCHECK(deleted_profiles);
904 903
905 for (const std::unique_ptr<base::Value>& value : *deleted_profiles) { 904 for (const base::Value& value : *deleted_profiles) {
906 base::FilePath profile_path; 905 base::FilePath profile_path;
907 bool is_valid_profile_path = 906 bool is_valid_profile_path =
908 base::GetValueAsFilePath(*value, &profile_path) && 907 base::GetValueAsFilePath(value, &profile_path) &&
909 profile_path.DirName() == user_data_dir(); 908 profile_path.DirName() == user_data_dir();
910 // Although it should never happen, make sure this is a valid path in the 909 // Although it should never happen, make sure this is a valid path in the
911 // user_data_dir, so we don't accidentially delete something else. 910 // user_data_dir, so we don't accidentially delete something else.
912 if (is_valid_profile_path) { 911 if (is_valid_profile_path) {
913 if (base::PathExists(profile_path)) { 912 if (base::PathExists(profile_path)) {
914 LOG(WARNING) << "Files of a deleted profile still exist after restart. " 913 LOG(WARNING) << "Files of a deleted profile still exist after restart. "
915 "Cleaning up now."; 914 "Cleaning up now.";
916 BrowserThread::PostTaskAndReply( 915 BrowserThread::PostTaskAndReply(
917 BrowserThread::FILE, FROM_HERE, 916 BrowserThread::FILE, FROM_HERE,
918 base::Bind(&NukeProfileFromDisk, profile_path), 917 base::Bind(&NukeProfileFromDisk, profile_path),
919 base::Bind(&ProfileCleanedUp, value.get())); 918 base::Bind(&ProfileCleanedUp, &value));
920 } else { 919 } else {
921 // Everything is fine, the profile was removed on shutdown. 920 // Everything is fine, the profile was removed on shutdown.
922 BrowserThread::PostTask( 921 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
923 BrowserThread::UI, FROM_HERE, 922 base::Bind(&ProfileCleanedUp, &value));
924 base::Bind(&ProfileCleanedUp, value.get()));
925 } 923 }
926 } else { 924 } else {
927 LOG(ERROR) << "Found invalid profile path in deleted_profiles: " 925 LOG(ERROR) << "Found invalid profile path in deleted_profiles: "
928 << profile_path.AsUTF8Unsafe(); 926 << profile_path.AsUTF8Unsafe();
929 NOTREACHED(); 927 NOTREACHED();
930 } 928 }
931 } 929 }
932 } 930 }
933 931
934 void ProfileManager::InitProfileUserPrefs(Profile* profile) { 932 void ProfileManager::InitProfileUserPrefs(Profile* profile) {
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after
1793 1791
1794 const base::FilePath new_active_profile_dir = 1792 const base::FilePath new_active_profile_dir =
1795 found_entry ? found_entry->GetPath() : GenerateNextProfileDirectoryPath(); 1793 found_entry ? found_entry->GetPath() : GenerateNextProfileDirectoryPath();
1796 FinishDeletingProfile(profile_dir, new_active_profile_dir); 1794 FinishDeletingProfile(profile_dir, new_active_profile_dir);
1797 } 1795 }
1798 #endif // !defined(OS_ANDROID) 1796 #endif // !defined(OS_ANDROID)
1799 1797
1800 ProfileManagerWithoutInit::ProfileManagerWithoutInit( 1798 ProfileManagerWithoutInit::ProfileManagerWithoutInit(
1801 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { 1799 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) {
1802 } 1800 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698