Chromium Code Reviews| Index: chrome/browser/profiles/profiles_state.cc |
| diff --git a/chrome/browser/profiles/profiles_state.cc b/chrome/browser/profiles/profiles_state.cc |
| index 2a254993e1c8b363d3941bca7913cca7cdcfb58a..f44f7f60c3949ca02366d250bb0f67260b023b45 100644 |
| --- a/chrome/browser/profiles/profiles_state.cc |
| +++ b/chrome/browser/profiles/profiles_state.cc |
| @@ -57,7 +57,7 @@ base::string16 GetAvatarNameForProfile(const base::FilePath& profile_path) { |
| if (profile_path == ProfileManager::GetGuestProfilePath()) { |
| display_name = l10n_util::GetStringUTF16(IDS_GUEST_PROFILE_NAME); |
| } else { |
| - ProfileInfoCache& cache = |
| + const ProfileInfoCache& cache = |
| g_browser_process->profile_manager()->GetProfileInfoCache(); |
| size_t index = cache.GetIndexOfProfileWithPath(profile_path); |
| @@ -98,7 +98,7 @@ base::string16 GetAvatarButtonTextForProfile(Profile* profile) { |
| void UpdateProfileName(Profile* profile, |
| const base::string16& new_profile_name) { |
| - ProfileInfoCache& cache = |
| + const ProfileInfoCache& cache = |
| g_browser_process->profile_manager()->GetProfileInfoCache(); |
| size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath()); |
| if (profile_index == std::string::npos) |
| @@ -156,4 +156,26 @@ SigninErrorController* GetSigninErrorController(Profile* profile) { |
| return token_service ? token_service->signin_error_controller() : NULL; |
| } |
| +Profile* SetActiveProfileToGuestIfLocked() { |
| + Profile* active_profile = ProfileManager::GetLastUsedProfile(); |
| + DCHECK(active_profile); |
| + |
| + ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| + const ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
| + size_t index = cache.GetIndexOfProfileWithPath(active_profile->GetPath()); |
| + if (!cache.ProfileIsSigninRequiredAtIndex(index)) |
| + return NULL; |
| + |
| + // The guest profile must have been loaded already. |
| + Profile* guest_profile = profile_manager->GetProfile( |
| + ProfileManager::GetGuestProfilePath()); |
| + CHECK(guest_profile); |
|
Alexei Svitkine (slow)
2014/09/22 16:58:00
Nit: DCHECK().
If it's NULL, it will crash on lin
noms (inactive)
2014/09/22 21:41:49
Done.
|
| + |
| + PrefService* local_state = g_browser_process->local_state(); |
| + DCHECK(local_state); |
| + local_state->SetString(prefs::kProfileLastUsed, |
| + guest_profile->GetPath().BaseName().MaybeAsASCII()); |
| + return guest_profile; |
| +} |
| + |
| } // namespace profiles |