Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6961)

Unified Diff: chrome/browser/profiles/profiles_state.cc

Issue 585653002: After locking a profile and showing the User Manager, make Guest the active profile (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698