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

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: don't do anything if you're already a guest profile 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
« no previous file with comments | « chrome/browser/profiles/profiles_state.h ('k') | chrome/browser/ui/cocoa/profiles/user_manager_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..48f0152b9dde19b3ad421ec2bcaa807db5be8fe8 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,29 @@ SigninErrorController* GetSigninErrorController(Profile* profile) {
return token_service ? token_service->signin_error_controller() : NULL;
}
+Profile* SetActiveProfileToGuestIfLocked() {
+ Profile* active_profile = ProfileManager::GetLastUsedProfile();
+ DCHECK(active_profile);
+
+ if (active_profile->IsGuestSession())
+ return 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());
+ DCHECK(guest_profile);
+
+ 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
« no previous file with comments | « chrome/browser/profiles/profiles_state.h ('k') | chrome/browser/ui/cocoa/profiles/user_manager_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698