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 <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 PrefService* local_state = g_browser_process->local_state(); | 607 PrefService* local_state = g_browser_process->local_state(); |
608 DCHECK(local_state); | 608 DCHECK(local_state); |
609 | 609 |
610 std::vector<Profile*> to_return; | 610 std::vector<Profile*> to_return; |
611 if (local_state->HasPrefPath(prefs::kProfilesLastActive) && | 611 if (local_state->HasPrefPath(prefs::kProfilesLastActive) && |
612 local_state->GetList(prefs::kProfilesLastActive)) { | 612 local_state->GetList(prefs::kProfilesLastActive)) { |
613 // Make a copy because the list might change in the calls to GetProfile. | 613 // Make a copy because the list might change in the calls to GetProfile. |
614 std::unique_ptr<base::ListValue> profile_list( | 614 std::unique_ptr<base::ListValue> profile_list( |
615 local_state->GetList(prefs::kProfilesLastActive)->DeepCopy()); | 615 local_state->GetList(prefs::kProfilesLastActive)->DeepCopy()); |
616 base::ListValue::const_iterator it; | 616 base::ListValue::const_iterator it; |
617 std::string profile; | |
618 for (it = profile_list->begin(); it != profile_list->end(); ++it) { | 617 for (it = profile_list->begin(); it != profile_list->end(); ++it) { |
619 if (!(*it)->GetAsString(&profile) || profile.empty() || | 618 std::string profile_path; |
620 profile == base::FilePath(chrome::kSystemProfileDir).AsUTF8Unsafe()) { | 619 if (!(*it)->GetAsString(&profile_path) || |
| 620 profile_path.empty() || |
| 621 profile_path == |
| 622 base::FilePath(chrome::kSystemProfileDir).AsUTF8Unsafe()) { |
621 LOG(WARNING) << "Invalid entry in " << prefs::kProfilesLastActive; | 623 LOG(WARNING) << "Invalid entry in " << prefs::kProfilesLastActive; |
622 continue; | 624 continue; |
623 } | 625 } |
624 to_return.push_back(GetProfile(user_data_dir.AppendASCII(profile))); | 626 Profile* profile = GetProfile(user_data_dir.AppendASCII(profile_path)); |
| 627 if (profile) |
| 628 to_return.push_back(profile); |
625 } | 629 } |
626 } | 630 } |
627 return to_return; | 631 return to_return; |
628 } | 632 } |
629 | 633 |
630 std::vector<Profile*> ProfileManager::GetLoadedProfiles() const { | 634 std::vector<Profile*> ProfileManager::GetLoadedProfiles() const { |
631 std::vector<Profile*> profiles; | 635 std::vector<Profile*> profiles; |
632 for (ProfilesInfoMap::const_iterator iter = profiles_info_.begin(); | 636 for (ProfilesInfoMap::const_iterator iter = profiles_info_.begin(); |
633 iter != profiles_info_.end(); ++iter) { | 637 iter != profiles_info_.end(); ++iter) { |
634 if (iter->second->created) | 638 if (iter->second->created) |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1327 TRACK_SCOPED_REGION( | 1331 TRACK_SCOPED_REGION( |
1328 "Startup", "ProfileManager::CreateAndInitializeProfile"); | 1332 "Startup", "ProfileManager::CreateAndInitializeProfile"); |
1329 SCOPED_UMA_HISTOGRAM_LONG_TIMER("Profile.CreateAndInitializeProfile"); | 1333 SCOPED_UMA_HISTOGRAM_LONG_TIMER("Profile.CreateAndInitializeProfile"); |
1330 | 1334 |
1331 // CHECK that we are not trying to load the same profile twice, to prevent | 1335 // CHECK that we are not trying to load the same profile twice, to prevent |
1332 // profile corruption. Note that this check also covers the case when we have | 1336 // profile corruption. Note that this check also covers the case when we have |
1333 // already started loading the profile but it is not fully initialized yet, | 1337 // already started loading the profile but it is not fully initialized yet, |
1334 // which would make Bad Things happen if we returned it. | 1338 // which would make Bad Things happen if we returned it. |
1335 CHECK(!GetProfileByPathInternal(profile_dir)); | 1339 CHECK(!GetProfileByPathInternal(profile_dir)); |
1336 Profile* profile = CreateProfileHelper(profile_dir); | 1340 Profile* profile = CreateProfileHelper(profile_dir); |
1337 DCHECK(profile); | |
1338 if (profile) { | 1341 if (profile) { |
1339 bool result = AddProfile(profile); | 1342 bool result = AddProfile(profile); |
1340 DCHECK(result); | 1343 DCHECK(result); |
1341 } | 1344 } |
1342 return profile; | 1345 return profile; |
1343 } | 1346 } |
1344 | 1347 |
1345 #if !defined(OS_ANDROID) | 1348 #if !defined(OS_ANDROID) |
1346 void ProfileManager::FinishDeletingProfile( | 1349 void ProfileManager::FinishDeletingProfile( |
1347 const base::FilePath& profile_dir, | 1350 const base::FilePath& profile_dir, |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1636 | 1639 |
1637 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); | 1640 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); |
1638 if (!original_callback.is_null()) | 1641 if (!original_callback.is_null()) |
1639 original_callback.Run(loaded_profile, status); | 1642 original_callback.Run(loaded_profile, status); |
1640 } | 1643 } |
1641 #endif // !defined(OS_ANDROID) | 1644 #endif // !defined(OS_ANDROID) |
1642 | 1645 |
1643 ProfileManagerWithoutInit::ProfileManagerWithoutInit( | 1646 ProfileManagerWithoutInit::ProfileManagerWithoutInit( |
1644 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { | 1647 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { |
1645 } | 1648 } |
OLD | NEW |