diff --git a/chrome/browser/profiles/profiles_state.cc b/chrome/browser/profiles/profiles_state.cc index 8af902cc691e6a..40d7b4d93ab305 100644 --- a/chrome/browser/profiles/profiles_state.cc +++ b/chrome/browser/profiles/profiles_state.cc @@ -67,6 +67,18 @@ void RegisterPrefs(PrefRegistrySimple* registry) { registry->RegisterBooleanPref(prefs::kForceBrowserSignin, false); } +void SetLastUsedProfile(const std::string& profile_dir) { + // We should never be saving the System Profile as the last one used since it + // shouldn't have a browser. + if (profile_dir == base::FilePath(chrome::kSystemProfileDir).AsUTF8Unsafe()) + return; + + PrefService* local_state = g_browser_process->local_state(); + DCHECK(local_state); + local_state->SetString(prefs::kProfileLastUsed, profile_dir); +} + +#if !defined(OS_ANDROID) base::string16 GetAvatarNameForProfile(const base::FilePath& profile_path) { base::string16 display_name; @@ -160,7 +172,7 @@ std::vector GetSecondaryAccountsForProfile( return accounts; } -#endif +#endif // !defined(OS_CHROMEOS) bool IsRegularOrGuestSession(Browser* browser) { Profile* profile = browser->profile(); @@ -222,7 +234,7 @@ bool SetActiveProfileToGuestIfLocked() { return true; } -#endif +#endif // !defined(OS_CHROMEOS) void RemoveBrowsingDataForProfile(const base::FilePath& profile_path) { // The BrowsingDataRemover relies on the ResourceDispatcherHost, which is @@ -245,17 +257,6 @@ void RemoveBrowsingDataForProfile(const base::FilePath& profile_path) { ChromeBrowsingDataRemoverDelegate::ALL_ORIGIN_TYPES); } -void SetLastUsedProfile(const std::string& profile_dir) { - // We should never be saving the System Profile as the last one used since it - // shouldn't have a browser. - if (profile_dir == base::FilePath(chrome::kSystemProfileDir).AsUTF8Unsafe()) - return; - - PrefService* local_state = g_browser_process->local_state(); - DCHECK(local_state); - local_state->SetString(prefs::kProfileLastUsed, profile_dir); -} - #if !defined(OS_CHROMEOS) bool AreAllNonChildNonSupervisedProfilesLocked() { bool at_least_one_regular_profile_present = false; @@ -287,5 +288,6 @@ bool IsPublicSession() { #endif return false; } +#endif // !defined(OS_ANDROID) } // namespace profiles diff --git a/chrome/browser/profiles/profiles_state.h b/chrome/browser/profiles/profiles_state.h index e4a11b1eb20cfb..4e9d425fc6e7dd 100644 --- a/chrome/browser/profiles/profiles_state.h +++ b/chrome/browser/profiles/profiles_state.h @@ -8,9 +8,11 @@ #include #include "base/strings/string16.h" +#include "build/build_config.h" #if !defined(OS_CHROMEOS) #include + #include "chrome/browser/profiles/avatar_menu.h" #endif @@ -18,6 +20,7 @@ class Browser; class PrefRegistrySimple; class Profile; class SigninErrorController; + namespace base { class FilePath; } namespace profiles { @@ -36,6 +39,11 @@ base::FilePath GetDefaultProfileDir(const base::FilePath& user_data_dir); // Register multi-profile related preferences in Local State. void RegisterPrefs(PrefRegistrySimple* registry); +// Sets the last used profile pref to |profile_dir|, unless |profile_dir| is the +// System Profile directory, which is an invalid last used profile. +void SetLastUsedProfile(const std::string& profile_dir); + +#if !defined(OS_ANDROID) // Returns the display name of the specified on-the-record profile (or guest), // specified by |profile_path|, used in the avatar button or user manager. If // |profile_path| is the guest path, it will return IDS_GUEST_PROFILE_NAME. If @@ -67,7 +75,7 @@ void UpdateProfileName(Profile* profile, std::vector GetSecondaryAccountsForProfile( Profile* profile, const std::string& primary_account); -#endif +#endif // !defined(OS_CHROMEOS) // Returns whether the |browser|'s profile is a non-incognito or guest profile. // The distinction is needed because guest profiles are implemented as @@ -99,16 +107,12 @@ SigninErrorController* GetSigninErrorController(Profile* profile); // profile had been Guest before calling or became Guest as a result of this // method. bool SetActiveProfileToGuestIfLocked(); -#endif +#endif // !defined(OS_CHROMEOS) // If the profile given by |profile_path| is loaded in the ProfileManager, use // a BrowsingDataRemover to delete all the Profile's data. void RemoveBrowsingDataForProfile(const base::FilePath& profile_path); -// Sets the last used profile pref to |profile_dir|, unless |profile_dir| is the -// System Profile directory, which is an invalid last used profile. -void SetLastUsedProfile(const std::string& profile_dir); - #if !defined(OS_CHROMEOS) // Returns true if there exists at least one non-supervised or non-child profile // and they are all locked. @@ -117,6 +121,7 @@ bool AreAllNonChildNonSupervisedProfilesLocked(); // Returns whether a public session is being run currently. bool IsPublicSession(); +#endif // !defined(OS_ANDROID) } // namespace profiles