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"
10 #include "chrome/browser/profiles/avatar_menu.h"
13 class PrefRegistrySimple
;
15 class SigninErrorController
;
16 namespace base
{ class FilePath
; }
20 // Checks if multiple profiles is enabled.
21 bool IsMultipleProfilesEnabled();
23 // Returns the path to the default profile directory, based on the given
24 // user data directory.
25 base::FilePath
GetDefaultProfileDir(const base::FilePath
& user_data_dir
);
27 // Register multi-profile related preferences in Local State.
28 void RegisterPrefs(PrefRegistrySimple
* registry
);
30 // Returns the display name of the specified on-the-record profile (or guest),
31 // specified by |profile_path|, used in the avatar button or user manager. If
32 // |profile_path| is the guest path, it will return IDS_GUEST_PROFILE_NAME. If
33 // there is only one local profile present, it will return
34 // IDS_SINGLE_PROFILE_DISPLAY_NAME, unless the profile has a user entered
36 base::string16
GetAvatarNameForProfile(const base::FilePath
& profile_path
);
38 // Returns the string to use in the avatar button for the specified profile.
39 // This is essentially the name returned by GetAvatarNameForProfile, but it
40 // may be elided and contain an indicator for supervised users.
41 base::string16
GetAvatarButtonTextForProfile(Profile
* profile
);
43 // Returns the string to use in the fast user switcher menu for the specified
44 // menu item. Adds a supervision indicator to the profile name if appropriate.
45 base::string16
GetProfileSwitcherTextForItem(const AvatarMenu::Item
& item
);
47 // Update the name of |profile| to |new_profile_name|. This updates the
48 // profile preferences, which triggers an update in the ProfileInfoCache.
49 // This method should be called when the user is explicitely changing
50 // the profile name, as it will always set |prefs::kProfileUsingDefaultName|
52 void UpdateProfileName(Profile
* profile
,
53 const base::string16
& new_profile_name
);
55 // Returns the list of secondary accounts for a specific |profile|, which is
56 // all the email addresses associated with the profile that are not equal to
57 // the |primary_account|.
58 std::vector
<std::string
> GetSecondaryAccountsForProfile(
60 const std::string
& primary_account
);
62 // Returns whether the |browser|'s profile is a non-incognito or guest profile.
63 // The distinction is needed because guest profiles are implemented as
64 // incognito profiles.
65 bool IsRegularOrGuestSession(Browser
* browser
);
67 // Returns true if sign in is required to browse as this profile.
68 // TODO(mlerman): Refactor appropriate calls to
69 // ProfileInfoCache::ProfileIsSigninRequiredAtIndex to call here instead.
70 bool IsProfileLocked(Profile
* profile
);
72 // If the lock-enabled information for this profile is not up to date, starts
73 // an update for the Gaia profile info.
74 void UpdateIsProfileLockEnabledIfNeeded(Profile
* profile
);
76 // If the --google-profile-info flag is turned on, starts an update for a new
77 // version of the Gaia profile picture and other profile info.
78 void UpdateGaiaProfileInfoIfNeeded(Profile
* profile
);
80 // Returns the sign-in error controller for the given profile. Some profiles,
81 // like guest profiles, may not have a controller so this function may return
83 SigninErrorController
* GetSigninErrorController(Profile
* profile
);
85 // If the current active profile (given by prefs::kProfileLastUsed) is locked,
86 // changes the active profile to the Guest profile. Returns true if the active
87 // profile had been Guest before calling or became Guest as a result of this
89 bool SetActiveProfileToGuestIfLocked();
91 } // namespace profiles
93 #endif // CHROME_BROWSER_PROFILES_PROFILES_STATE_H_