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

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

Issue 885493005: Setting Guest last-active for the User Manager doesn't create the Guest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac UserManager asyncly creates Guest for Controller Created 5 years, 11 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 3aa232ab99925c7cdc5d2d67d77067344e8bbecf..d3b7221dea823e56469a6a16208470c99840af23 100644
--- a/chrome/browser/profiles/profiles_state.cc
+++ b/chrome/browser/profiles/profiles_state.cc
@@ -171,29 +171,25 @@ SigninErrorController* GetSigninErrorController(Profile* profile) {
return SigninErrorControllerFactory::GetForProfile(profile);
}
-Profile* SetActiveProfileToGuestIfLocked() {
- Profile* active_profile = ProfileManager::GetLastUsedProfile();
- DCHECK(active_profile);
+bool SetActiveProfileToGuestIfLocked() {
+ ProfileManager* profile_manager = g_browser_process->profile_manager();
- if (active_profile->IsGuestSession())
- return active_profile;
+ const base::FilePath& active_profile_path =
+ profile_manager->GetLastUsedProfileDir(profile_manager->user_data_dir());
+ if (active_profile_path == ProfileManager::GetGuestProfilePath())
noms (inactive) 2015/01/29 16:15:13 nit: can we store this into a variable so that we
Mike Lerman 2015/01/29 16:51:40 Done.
+ return true;
- ProfileManager* profile_manager = g_browser_process->profile_manager();
const ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
- size_t index = cache.GetIndexOfProfileWithPath(active_profile->GetPath());
+ size_t index = cache.GetIndexOfProfileWithPath(active_profile_path);
if (!cache.ProfileIsSigninRequiredAtIndex(index))
- return NULL;
-
- // Profile loads synchronously if it was not previously created.
- Profile* guest_profile = profile_manager->GetProfile(
- ProfileManager::GetGuestProfilePath());
- DCHECK(guest_profile);
+ return false;
PrefService* local_state = g_browser_process->local_state();
DCHECK(local_state);
- local_state->SetString(prefs::kProfileLastUsed,
- guest_profile->GetPath().BaseName().MaybeAsASCII());
- return guest_profile;
+ local_state->SetString(
+ prefs::kProfileLastUsed,
+ ProfileManager::GetGuestProfilePath().BaseName().MaybeAsASCII());
+ return true;
}
} // namespace profiles

Powered by Google App Engine
This is Rietveld 408576698