Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / profiles / profile_attributes_entry.h
blob898557792594d675337a446ae23b823c990f8b63
1 // Copyright 2015 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_PROFILE_ATTRIBUTES_ENTRY_H_
6 #define CHROME_BROWSER_PROFILES_PROFILE_ATTRIBUTES_ENTRY_H_
8 #include <string>
10 #include "base/files/file_path.h"
11 #include "base/strings/string16.h"
12 #include "base/time/time.h"
14 namespace gfx {
15 class Image;
18 class ProfileInfoCache;
20 class ProfileAttributesEntry {
21 public:
22 ProfileAttributesEntry();
23 virtual ~ProfileAttributesEntry() {}
25 // Gets the name of the profile, which is the one displayed in the User Menu.
26 base::string16 GetName() const;
28 base::string16 GetShortcutName() const;
29 // Gets the path to the profile. Should correspond to the path passed to
30 // ProfileAttributesStorage::GetProfileAttributesWithPath to get this entry.
31 base::FilePath GetPath() const;
32 base::Time GetActiveTime() const;
33 // Gets the user name of the signed in profile. This is typically the email
34 // address used to sign in and the empty string for profiles that aren't
35 // signed in to chrome.
36 base::string16 GetUserName() const;
37 // Gets the icon used as this profile's avatar. This might not be the icon
38 // displayed in the UI if IsUsingGAIAPicture() is true.
39 const gfx::Image& GetAvatarIcon();
40 std::string GetLocalAuthCredentials() const;
41 std::string GetPasswordChangeDetectionToken() const;
42 // Note that a return value of false could mean an error in collection or
43 // that there are currently no background apps running. However, the action
44 // which results is the same in both cases (thus far).
45 bool GetBackgroundStatus() const;
46 // Gets the GAIA full name associated with this profile if it's signed in.
47 base::string16 GetGAIAName() const;
48 // Gets the GAIA given name associated with this profile if it's signed in.
49 base::string16 GetGAIAGivenName() const;
50 // Gets the opaque string representation of the profile's GAIA ID if it's
51 // signed in.
52 std::string GetGAIAId() const;
53 // Returns the GAIA picture for the given profile. This may return NULL
54 // if the profile does not have a GAIA picture or if the picture must be
55 // loaded from disk.
56 const gfx::Image* GetGAIAPicture() const;
57 // Returns true if the profile displays a GAIA picture instead of one of the
58 // locally bundled icons.
59 bool IsUsingGAIAPicture() const;
60 // Returns true if the profile is signed in as a supervised user..
61 bool IsSupervised() const;
62 // Returns true if the profile is signed in as a child account.
63 bool IsChild() const;
64 // Returns true if the profile is a supervised user but not a child account.
65 bool IsLegacySupervised() const;
66 bool IsOmitted() const;
67 bool IsSigninRequired() const;
68 // Gets the supervised user ID of the profile's signed in account, if it's a
69 // supervised user.
70 std::string GetSupervisedUserId() const;
71 // Returns true if the profile is an ephemeral profile.
72 bool IsEphemeral() const;
73 // Returns true if the profile is using a default name, typically of the
74 // format "Person %d".
75 bool IsUsingDefaultName() const;
76 // Returns true if the profile is signed in.
77 bool IsAuthenticated() const;
78 // Returns true if the Profile is using the default avatar, which is one of
79 // the profile icons selectable at profile creation.
80 bool IsUsingDefaultAvatar() const;
81 // Returns true if the profile is signed in but is in an authentication error
82 // state.
83 bool IsAuthError() const;
84 // Returns the index of the default icon used by the profile.
85 size_t GetAvatarIconIndex() const;
87 void SetName(const base::string16& name);
88 void SetShortcutName(const base::string16& name);
89 void SetIsOmitted(bool is_omitted);
90 void SetSupervisedUserId(const std::string& id);
91 void SetLocalAuthCredentials(const std::string& auth);
92 void SetPasswordChangeDetectionToken(const std::string& token);
93 void SetBackgroundStatus(bool running_background_apps);
94 void SetGAIAName(const base::string16& name);
95 void SetGAIAGivenName(const base::string16& name);
96 void SetGAIAPicture(const gfx::Image* image);
97 void SetIsUsingGAIAPicture(bool value);
98 void SetIsSigninRequired(bool value);
99 void SetIsEphemeral(bool value);
100 void SetIsUsingDefaultName(bool value);
101 void SetIsUsingDefaultAvatar(bool value);
102 void SetIsAuthError(bool value);
103 void SetAvatarIconIndex(size_t icon_index);
105 void SetAuthInfo(const std::string& gaia_id,
106 const base::string16& user_name);
108 private:
109 // These members are an implementation detail meant to smooth the migration
110 // of the ProfileInfoCache to the ProfileAttributesStorage interface. They can
111 // be safely removed once the ProfileInfoCache stops using indices
112 // internally.
113 // TODO(anthonyvd): Remove ProfileInfoCache related implementation details
114 // when this class holds the members required to fulfill its own contract.
115 friend class ProfileInfoCache;
116 void Initialize(ProfileInfoCache* cache, const base::FilePath& path);
117 size_t profile_index() const;
118 ProfileInfoCache* profile_info_cache_;
119 base::FilePath profile_path_;
121 DISALLOW_COPY_AND_ASSIGN(ProfileAttributesEntry);
124 #endif // CHROME_BROWSER_PROFILES_PROFILE_ATTRIBUTES_ENTRY_H_