| 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 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 // CrOS multi-profiles implementation is different so GetLastUsedProfile | 507 // CrOS multi-profiles implementation is different so GetLastUsedProfile |
| 508 // has custom implementation too. | 508 // has custom implementation too. |
| 509 base::FilePath profile_dir; | 509 base::FilePath profile_dir; |
| 510 // In case of multi-profiles we ignore "last used profile" preference | 510 // In case of multi-profiles we ignore "last used profile" preference |
| 511 // since it may refer to profile that has been in use in previous session. | 511 // since it may refer to profile that has been in use in previous session. |
| 512 // That profile dir may not be mounted in this session so instead return | 512 // That profile dir may not be mounted in this session so instead return |
| 513 // active profile from current session. | 513 // active profile from current session. |
| 514 profile_dir = chromeos::ProfileHelper::Get()->GetActiveUserProfileDir(); | 514 profile_dir = chromeos::ProfileHelper::Get()->GetActiveUserProfileDir(); |
| 515 | 515 |
| 516 base::FilePath profile_path(user_data_dir); | 516 base::FilePath profile_path(user_data_dir); |
| 517 Profile* profile = GetProfile(profile_path.Append(profile_dir)); | 517 Profile* profile = GetProfileByPath(profile_path.Append(profile_dir)); |
| 518 // If we get here, it means the user has logged in but the profile has not |
| 519 // finished initializing, so treat the user as not having logged in. |
| 520 if (!profile) { |
| 521 DLOG(WARNING) << "Calling GetLastUsedProfile() before profile " |
| 522 << "initialization is completed. Returning login profile."; |
| 523 return GetActiveUserOrOffTheRecordProfileFromPath(user_data_dir); |
| 524 } |
| 518 return profile->IsGuestSession() ? profile->GetOffTheRecordProfile() : | 525 return profile->IsGuestSession() ? profile->GetOffTheRecordProfile() : |
| 519 profile; | 526 profile; |
| 520 } | 527 } |
| 521 #endif | 528 #else |
| 522 | 529 |
| 523 return GetProfile(GetLastUsedProfileDir(user_data_dir)); | 530 return GetProfile(GetLastUsedProfileDir(user_data_dir)); |
| 531 #endif |
| 524 } | 532 } |
| 525 | 533 |
| 526 base::FilePath ProfileManager::GetLastUsedProfileDir( | 534 base::FilePath ProfileManager::GetLastUsedProfileDir( |
| 527 const base::FilePath& user_data_dir) { | 535 const base::FilePath& user_data_dir) { |
| 528 return user_data_dir.AppendASCII(GetLastUsedProfileName()); | 536 return user_data_dir.AppendASCII(GetLastUsedProfileName()); |
| 529 } | 537 } |
| 530 | 538 |
| 531 std::string ProfileManager::GetLastUsedProfileName() { | 539 std::string ProfileManager::GetLastUsedProfileName() { |
| 532 PrefService* local_state = g_browser_process->local_state(); | 540 PrefService* local_state = g_browser_process->local_state(); |
| 533 DCHECK(local_state); | 541 DCHECK(local_state); |
| (...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1555 | 1563 |
| 1556 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); | 1564 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); |
| 1557 if (!original_callback.is_null()) | 1565 if (!original_callback.is_null()) |
| 1558 original_callback.Run(loaded_profile, status); | 1566 original_callback.Run(loaded_profile, status); |
| 1559 } | 1567 } |
| 1560 #endif // !defined(OS_ANDROID) | 1568 #endif // !defined(OS_ANDROID) |
| 1561 | 1569 |
| 1562 ProfileManagerWithoutInit::ProfileManagerWithoutInit( | 1570 ProfileManagerWithoutInit::ProfileManagerWithoutInit( |
| 1563 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { | 1571 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { |
| 1564 } | 1572 } |
| OLD | NEW |