1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_PROFILES_PROFILES_STATE_H_
6 #define CHROME_BROWSER_PROFILES_PROFILES_STATE_H_
9 #include "base/strings/string16.h"
12 class PrefRegistrySimple
;
14 class SigninErrorController
;
15 namespace base
{ class FilePath
; }
19 // Checks if multiple profiles is enabled.
20 bool IsMultipleProfilesEnabled();
22 // Returns the path to the default profile directory, based on the given
23 // user data directory.
24 base::FilePath
GetDefaultProfileDir(const base::FilePath
& user_data_dir
);
26 // Register multi-profile related preferences in Local State.
27 void RegisterPrefs(PrefRegistrySimple
* registry
);
29 // Returns the display name of the specified on-the-record profile (or guest),
30 // specified by |profile_path|, used in the avatar button or user manager. If
31 // |profile_path| is the guest path, it will return IDS_GUEST_PROFILE_NAME. If
32 // there is only one local profile present, it will return
33 // IDS_SINGLE_PROFILE_DISPLAY_NAME, unless the profile has a user entered
35 base::string16
GetAvatarNameForProfile(const base::FilePath
& profile_path
);
37 // Returns the string to use in the avatar button for the specified profile.
38 // This is essentially the name returned by GetAvatarNameForProfile, but it
39 // may be elided and contain an indicator for supervised users.
40 base::string16
GetAvatarButtonTextForProfile(Profile
* profile
);
42 // Update the name of |profile| to |new_profile_name|. This updates the
43 // profile preferences, which triggers an update in the ProfileInfoCache.
44 // This method should be called when the user is explicitely changing
45 // the profile name, as it will always set |prefs::kProfileUsingDefaultName|
47 void UpdateProfileName(Profile
* profile
,
48 const base::string16
& new_profile_name
);
50 // Returns the list of secondary accounts for a specific |profile|, which is
51 // all the email addresses associated with the profile that are not equal to
52 // the |primary_account|.
53 std::vector
<std::string
> GetSecondaryAccountsForProfile(
55 const std::string
& primary_account
);
57 // Returns whether the |browser|'s profile is a non-incognito or guest profile.
58 // The distinction is needed because guest profiles are implemented as
59 // incognito profiles.
60 bool IsRegularOrGuestSession(Browser
* browser
);
62 // Returns true if sign in is required to browse as this profile.
63 // TODO(mlerman): Refactor appropriate calls to
64 // ProfileInfoCache::ProfileIsSigninRequiredAtIndex to call here instead.
65 bool IsProfileLocked(Profile
* profile
);
67 // If the lock-enabled information for this profile is not up to date, starts
68 // an update for the Gaia profile info.
69 void UpdateIsProfileLockEnabledIfNeeded(Profile
* profile
);
71 // If the --google-profile-info flag is turned on, starts an update for a new
72 // version of the Gaia profile picture and other profile info.
73 void UpdateGaiaProfileInfoIfNeeded(Profile
* profile
);
75 // Returns the sign-in error controller for the given profile. Some profiles,
76 // like guest profiles, may not have a controller so this function may return
78 SigninErrorController
* GetSigninErrorController(Profile
* profile
);
80 // If the current active profile (given by prefs::kProfileLastUsed) is locked,
81 // changes the active profile to the Guest profile. Returns true if the active
82 // profile had been Guest before calling or became Guest as a result of this
84 bool SetActiveProfileToGuestIfLocked();
86 } // namespace profiles
88 #endif // CHROME_BROWSER_PROFILES_PROFILES_STATE_H_