summaryrefslogtreecommitdiffstats
path: root/chrome/browser/profiles/profiles_state.h
blob: 9e54a0acc0acb4a91a7ed918aab734d0429f888a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_PROFILES_PROFILES_STATE_H_
#define CHROME_BROWSER_PROFILES_PROFILES_STATE_H_

#include <vector>
#include "base/strings/string16.h"
#include "chrome/browser/profiles/avatar_menu.h"

class Browser;
class PrefRegistrySimple;
class Profile;
class SigninErrorController;
namespace base { class FilePath; }

namespace profiles {

// Checks if multiple profiles is enabled.
bool IsMultipleProfilesEnabled();

// Returns the path to the default profile directory, based on the given
// user data directory.
base::FilePath GetDefaultProfileDir(const base::FilePath& user_data_dir);

// Register multi-profile related preferences in Local State.
void RegisterPrefs(PrefRegistrySimple* registry);

// 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
// there is only one local profile present, it will return
// IDS_SINGLE_PROFILE_DISPLAY_NAME, unless the profile has a user entered
// custom name.
base::string16 GetAvatarNameForProfile(const base::FilePath& profile_path);

// Returns the string to use in the avatar button for the specified profile.
// This is essentially the name returned by GetAvatarNameForProfile, but it
// may be elided and contain an indicator for supervised users.
base::string16 GetAvatarButtonTextForProfile(Profile* profile);

// Returns the string to use in the fast user switcher menu for the specified
// menu item. Adds a supervision indicator to the profile name if appropriate.
base::string16 GetProfileSwitcherTextForItem(const AvatarMenu::Item& item);

// Update the name of |profile| to |new_profile_name|. This updates the
// profile preferences, which triggers an update in the ProfileInfoCache.
// This method should be called when the user is explicitely changing
// the profile name, as it will always set |prefs::kProfileUsingDefaultName|
// to false.
void UpdateProfileName(Profile* profile,
                       const base::string16& new_profile_name);

// Returns the list of secondary accounts for a specific |profile|, which is
// all the email addresses associated with the profile that are not equal to
// the |primary_account|.
std::vector<std::string> GetSecondaryAccountsForProfile(
    Profile* profile,
    const std::string& primary_account);

// Returns whether the |browser|'s profile is a non-incognito or guest profile.
// The distinction is needed because guest profiles are implemented as
// incognito profiles.
bool IsRegularOrGuestSession(Browser* browser);

// Returns true if sign in is required to browse as this profile.
// TODO(mlerman): Refactor appropriate calls to
// ProfileInfoCache::ProfileIsSigninRequiredAtIndex to call here instead.
bool IsProfileLocked(Profile* profile);

// If the lock-enabled information for this profile is not up to date, starts
// an update for the Gaia profile info.
void UpdateIsProfileLockEnabledIfNeeded(Profile* profile);

// If the --google-profile-info flag is turned on, starts an update for a new
// version of the Gaia profile picture and other profile info.
void UpdateGaiaProfileInfoIfNeeded(Profile* profile);

// Returns the sign-in error controller for the given profile.  Some profiles,
// like guest profiles, may not have a controller so this function may return
// NULL.
SigninErrorController* GetSigninErrorController(Profile* profile);

// If the current active profile (given by prefs::kProfileLastUsed) is locked,
// changes the active profile to the Guest profile. Returns true if the active
// profile had been Guest before calling or became Guest as a result of this
// method.
bool SetActiveProfileToGuestIfLocked();

// 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);

// Marks the right-click user switching tutorial dismissed state as |dismissed|.
void SetFastUserSwitchingTutorialDismissedState(bool dismissed);

// Returns true if the right-click user switching tutorial was previously
// dismissed by a user, false otherwise.
bool GetFastUserSwitchingTutorialDismissedState();

// 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);

}  // namespace profiles

#endif  // CHROME_BROWSER_PROFILES_PROFILES_STATE_H_