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 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
615 std::unique_ptr<base::ListValue> profile_list( | 615 std::unique_ptr<base::ListValue> profile_list( |
616 local_state->GetList(prefs::kProfilesLastActive)->DeepCopy()); | 616 local_state->GetList(prefs::kProfilesLastActive)->DeepCopy()); |
617 base::ListValue::const_iterator it; | 617 base::ListValue::const_iterator it; |
618 std::string profile; | 618 std::string profile; |
619 for (it = profile_list->begin(); it != profile_list->end(); ++it) { | 619 for (it = profile_list->begin(); it != profile_list->end(); ++it) { |
620 if (!(*it)->GetAsString(&profile) || profile.empty() || | 620 if (!(*it)->GetAsString(&profile) || profile.empty() || |
621 profile == base::FilePath(chrome::kSystemProfileDir).AsUTF8Unsafe()) { | 621 profile == base::FilePath(chrome::kSystemProfileDir).AsUTF8Unsafe()) { |
622 LOG(WARNING) << "Invalid entry in " << prefs::kProfilesLastActive; | 622 LOG(WARNING) << "Invalid entry in " << prefs::kProfilesLastActive; |
623 continue; | 623 continue; |
624 } | 624 } |
625 to_return.push_back(GetProfile(user_data_dir.AppendASCII(profile))); | 625 Profile* profile = GetProfile(user_data_dir.AppendASCII(profile)); |
626 if (profile) | |
627 to_return.push_back(profile); | |
626 } | 628 } |
627 } | 629 } |
628 return to_return; | 630 return to_return; |
629 } | 631 } |
630 | 632 |
631 std::vector<Profile*> ProfileManager::GetLoadedProfiles() const { | 633 std::vector<Profile*> ProfileManager::GetLoadedProfiles() const { |
632 std::vector<Profile*> profiles; | 634 std::vector<Profile*> profiles; |
633 for (ProfilesInfoMap::const_iterator iter = profiles_info_.begin(); | 635 for (ProfilesInfoMap::const_iterator iter = profiles_info_.begin(); |
634 iter != profiles_info_.end(); ++iter) { | 636 iter != profiles_info_.end(); ++iter) { |
635 if (iter->second->created) | 637 if (iter->second->created) |
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1331 TRACK_SCOPED_REGION( | 1333 TRACK_SCOPED_REGION( |
1332 "Startup", "ProfileManager::CreateAndInitializeProfile"); | 1334 "Startup", "ProfileManager::CreateAndInitializeProfile"); |
1333 SCOPED_UMA_HISTOGRAM_LONG_TIMER("Profile.CreateAndInitializeProfile"); | 1335 SCOPED_UMA_HISTOGRAM_LONG_TIMER("Profile.CreateAndInitializeProfile"); |
1334 | 1336 |
1335 // CHECK that we are not trying to load the same profile twice, to prevent | 1337 // CHECK that we are not trying to load the same profile twice, to prevent |
1336 // profile corruption. Note that this check also covers the case when we have | 1338 // profile corruption. Note that this check also covers the case when we have |
1337 // already started loading the profile but it is not fully initialized yet, | 1339 // already started loading the profile but it is not fully initialized yet, |
1338 // which would make Bad Things happen if we returned it. | 1340 // which would make Bad Things happen if we returned it. |
1339 CHECK(!GetProfileByPathInternal(profile_dir)); | 1341 CHECK(!GetProfileByPathInternal(profile_dir)); |
1340 Profile* profile = CreateProfileHelper(profile_dir); | 1342 Profile* profile = CreateProfileHelper(profile_dir); |
1341 DCHECK(profile); | |
1342 if (profile) { | 1343 if (profile) { |
1343 bool result = AddProfile(profile); | 1344 bool result = AddProfile(profile); |
Peter Kasting
2016/05/31 19:12:30
Nit: You don't need to do this in this change, but
WC Leung
2016/06/01 18:56:55
You're right. Anyway the code here is having an ag
| |
1344 DCHECK(result); | 1345 DCHECK(result); |
1345 } | 1346 } |
1346 return profile; | 1347 return profile; |
1347 } | 1348 } |
1348 | 1349 |
1349 #if !defined(OS_ANDROID) | 1350 #if !defined(OS_ANDROID) |
1350 void ProfileManager::FinishDeletingProfile( | 1351 void ProfileManager::FinishDeletingProfile( |
1351 const base::FilePath& profile_dir, | 1352 const base::FilePath& profile_dir, |
1352 const base::FilePath& new_active_profile_dir) { | 1353 const base::FilePath& new_active_profile_dir) { |
1353 // Update the last used profile pref before closing browser windows. This | 1354 // Update the last used profile pref before closing browser windows. This |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1640 | 1641 |
1641 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); | 1642 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); |
1642 if (!original_callback.is_null()) | 1643 if (!original_callback.is_null()) |
1643 original_callback.Run(loaded_profile, status); | 1644 original_callback.Run(loaded_profile, status); |
1644 } | 1645 } |
1645 #endif // !defined(OS_ANDROID) | 1646 #endif // !defined(OS_ANDROID) |
1646 | 1647 |
1647 ProfileManagerWithoutInit::ProfileManagerWithoutInit( | 1648 ProfileManagerWithoutInit::ProfileManagerWithoutInit( |
1648 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { | 1649 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { |
1649 } | 1650 } |
OLD | NEW |