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

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

Issue 2918203002: cros: Fix loading user profile w/o UserSessionManager (Closed)
Patch Set: fix tests Created 3 years, 6 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/profile_manager.cc
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc
index 5f2317b7c992597829e7e6a8f91f739b4878e8ca..ca6cf25f02d19c5792d2b8fef8b0dd840095df47 100644
--- a/chrome/browser/profiles/profile_manager.cc
+++ b/chrome/browser/profiles/profile_manager.cc
@@ -633,8 +633,8 @@ Profile* ProfileManager::GetLastUsedProfile(
// If we get here, it means the user has logged in but the profile has not
// finished initializing, so treat the user as not having logged in.
if (!profile) {
- DLOG(WARNING) << "Calling GetLastUsedProfile() before profile "
- << "initialization is completed. Returning login profile.";
+ LOG(WARNING) << "Calling GetLastUsedProfile() before profile "
+ << "initialization is completed. Returning login profile.";
return GetActiveUserOrOffTheRecordProfileFromPath(user_data_dir);
emaxx 2017/06/06 12:11:23 Not insisting (I'm not aware of the general guidel
xiyuan 2017/06/06 20:29:39 I will fix the offending code and change this to a
}
return profile->IsGuestSession() ? profile->GetOffTheRecordProfile() :
@@ -1326,12 +1326,21 @@ Profile* ProfileManager::GetActiveUserOrOffTheRecordProfileFromPath(
return profile;
}
+ // Only allow user profile loading on browser restart, where kLoginUser
+ // switch is present in the command line. For all other cases, the user
+ // profile loading should be from UserSessionManager.
+ const bool allow_user_profile_loading =
emaxx 2017/06/06 12:11:23 I'm a bit unhappy with keeping the lazy profile lo
xiyuan 2017/06/06 20:29:39 Added ProfileManager::CreateInitialProfile() and u
+ base::CommandLine::ForCurrentProcess()->HasSwitch(
+ chromeos::switches::kLoginUser);
+
default_profile_dir = default_profile_dir.Append(GetInitialProfileDir());
ProfileInfo* profile_info = GetProfileInfoByPath(default_profile_dir);
- // Fallback to default off-the-record profile, if user profile has not fully
- // loaded yet.
- if (profile_info && !profile_info->created)
+ // Fallback to default off-the-record profile, if user profile is not loaded
+ // and should not be loaded or has not fully loaded yet.
+ if ((!allow_user_profile_loading && !profile_info) ||
+ (profile_info && !profile_info->created)) {
default_profile_dir = profiles::GetDefaultProfileDir(user_data_dir);
+ }
Profile* profile = GetProfile(default_profile_dir);
// Some unit tests didn't initialize the UserManager.

Powered by Google App Engine
This is Rietveld 408576698