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..ade8c705fb1b4aadc43afaff466ecd3b9d692185 100644 |
--- a/chrome/browser/profiles/profiles_state.cc |
+++ b/chrome/browser/profiles/profiles_state.cc |
@@ -156,4 +156,25 @@ SigninErrorController* GetSigninErrorController(Profile* profile) { |
return token_service ? token_service->signin_error_controller() : NULL; |
} |
+void SetActiveProfileToGuestIfLocked() { |
+ Profile* active_profile = ProfileManager::GetLastUsedProfile(); |
+ DCHECK(active_profile); |
+ |
+ ProfileManager* profile_manager = g_browser_process->profile_manager(); |
+ ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
Alexei Svitkine (slow)
2014/09/19 15:33:36
Nit: Const ref or ptr, please.
noms (inactive)
2014/09/22 15:39:45
Done.
|
+ size_t index = cache.GetIndexOfProfileWithPath(active_profile->GetPath()); |
+ if (!cache.ProfileIsSigninRequiredAtIndex(index)) |
+ return; |
+ |
+ // The guest profile must have been loaded already. |
+ Profile* guest_profile = profile_manager->GetProfile( |
+ ProfileManager::GetGuestProfilePath()); |
+ CHECK(guest_profile); |
+ |
+ PrefService* local_state = g_browser_process->local_state(); |
+ DCHECK(local_state); |
+ local_state->SetString(prefs::kProfileLastUsed, |
+ guest_profile->GetPath().BaseName().MaybeAsASCII()); |
+} |
+ |
} // namespace profiles |