OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_USER_MANAGER_USER_H_ | 5 #ifndef COMPONENTS_USER_MANAGER_USER_H_ |
6 #define COMPONENTS_USER_MANAGER_USER_H_ | 6 #define COMPONENTS_USER_MANAGER_USER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 POLICY = 5, // Controlled by policy, can't be changed by the user. | 75 POLICY = 5, // Controlled by policy, can't be changed by the user. |
76 WALLPAPER_TYPE_COUNT = 6 | 76 WALLPAPER_TYPE_COUNT = 6 |
77 }; | 77 }; |
78 | 78 |
79 // Returns true if user type has gaia account. | 79 // Returns true if user type has gaia account. |
80 static bool TypeHasGaiaAccount(UserType user_type); | 80 static bool TypeHasGaiaAccount(UserType user_type); |
81 | 81 |
82 // Returns the user type. | 82 // Returns the user type. |
83 virtual UserType GetType() const = 0; | 83 virtual UserType GetType() const = 0; |
84 | 84 |
85 // The email the user used to log in. | 85 /* // The email the user used to log in. |
86 const std::string& email() const { return email_; } | 86 const std::string& GetEmail(); |
87 | 87 */ |
88 // The displayed user name. | 88 // The displayed user name. |
89 base::string16 display_name() const { return display_name_; } | 89 base::string16 display_name() const { return display_name_; } |
90 | 90 |
91 // If the user has to use SAML to log in. | 91 // If the user has to use SAML to log in. |
92 bool using_saml() const { return using_saml_; } | 92 bool using_saml() const { return using_saml_; } |
93 | 93 |
94 // UserInfo | 94 // UserInfo |
95 std::string GetEmail() const override; | 95 std::string GetEmail() const override; |
96 base::string16 GetDisplayName() const override; | 96 base::string16 GetDisplayName() const override; |
97 base::string16 GetGivenName() const override; | 97 base::string16 GetGivenName() const override; |
98 const gfx::ImageSkia& GetImage() const override; | 98 const gfx::ImageSkia& GetImage() const override; |
99 UserID GetUserID() const override; | 99 const UserID& GetUserID() const override; |
100 | 100 |
101 // Allows managing child status of the user. Used for RegularUser. | 101 // Allows managing child status of the user. Used for RegularUser. |
102 virtual void SetIsChild(bool is_child); | 102 virtual void SetIsChild(bool is_child); |
103 | 103 |
104 // Returns true if user has gaia account. True for users of types | 104 // Returns true if user has gaia account. True for users of types |
105 // USER_TYPE_REGULAR and USER_TYPE_CHILD. | 105 // USER_TYPE_REGULAR and USER_TYPE_CHILD. |
106 virtual bool HasGaiaAccount() const; | 106 virtual bool HasGaiaAccount() const; |
107 | 107 |
108 // Returns true if user is supervised. | 108 // Returns true if user is supervised. |
109 virtual bool IsSupervised() const; | 109 virtual bool IsSupervised() const; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 friend class chromeos::UserImageManagerImpl; | 172 friend class chromeos::UserImageManagerImpl; |
173 friend class chromeos::UserSessionManager; | 173 friend class chromeos::UserSessionManager; |
174 | 174 |
175 // For testing: | 175 // For testing: |
176 friend class FakeUserManager; | 176 friend class FakeUserManager; |
177 friend class chromeos::FakeChromeUserManager; | 177 friend class chromeos::FakeChromeUserManager; |
178 friend class chromeos::MockUserManager; | 178 friend class chromeos::MockUserManager; |
179 friend class chromeos::UserAddingScreenTest; | 179 friend class chromeos::UserAddingScreenTest; |
180 | 180 |
181 // Do not allow anyone else to create new User instances. | 181 // Do not allow anyone else to create new User instances. |
182 static User* CreateRegularUser(const UserID& email); | 182 static User* CreateRegularUser(const UserID& user_id); |
183 static User* CreateGuestUser(); | 183 static User* CreateGuestUser(); |
184 static User* CreateKioskAppUser(const UserID& kiosk_app_username); | 184 static User* CreateKioskAppUser(const UserID& kiosk_app); |
185 static User* CreateSupervisedUser(const UserID& username); | 185 static User* CreateSupervisedUser(const UserID& user_id); |
186 static User* CreatePublicAccountUser(const UserID& email); | 186 static User* CreatePublicAccountUser(const UserID& user_id); |
187 | 187 |
188 explicit User(const std::string& email); | 188 explicit User(const UserID& email); |
189 ~User() override; | 189 ~User() override; |
190 | 190 |
191 const std::string* GetAccountLocale() const { return account_locale_.get(); } | 191 const std::string* GetAccountLocale() const { return account_locale_.get(); } |
192 | 192 |
193 // Setters are private so only UserManager can call them. | 193 // Setters are private so only UserManager can call them. |
194 void SetAccountLocale(const std::string& resolved_account_locale); | 194 void SetAccountLocale(const std::string& resolved_account_locale); |
195 | 195 |
196 void SetImage(const UserImage& user_image, int image_index); | 196 void SetImage(const UserImage& user_image, int image_index); |
197 | 197 |
198 void SetImageURL(const GURL& image_url); | 198 void SetImageURL(const GURL& image_url); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 void set_can_lock(bool can_lock) { can_lock_ = can_lock; } | 237 void set_can_lock(bool can_lock) { can_lock_ = can_lock; } |
238 | 238 |
239 void set_is_active(bool is_active) { is_active_ = is_active; } | 239 void set_is_active(bool is_active) { is_active_ = is_active; } |
240 | 240 |
241 void set_profile_is_created() { profile_is_created_ = true; } | 241 void set_profile_is_created() { profile_is_created_ = true; } |
242 | 242 |
243 // True if user has google account (not a guest or managed user). | 243 // True if user has google account (not a guest or managed user). |
244 bool has_gaia_account() const; | 244 bool has_gaia_account() const; |
245 | 245 |
246 private: | 246 private: |
247 std::string email_; | 247 UserID user_id_; |
248 base::string16 display_name_; | 248 base::string16 display_name_; |
249 base::string16 given_name_; | 249 base::string16 given_name_; |
250 // The displayed user email, defaults to |email_|. | 250 // The displayed user email, defaults to |email_|. |
251 std::string display_email_; | 251 std::string display_email_; |
252 bool using_saml_; | 252 bool using_saml_; |
253 UserImage user_image_; | 253 UserImage user_image_; |
254 OAuthTokenStatus oauth_token_status_; | 254 OAuthTokenStatus oauth_token_status_; |
255 bool force_online_signin_; | 255 bool force_online_signin_; |
256 | 256 |
257 // This is set to chromeos locale if account data has been downloaded. | 257 // This is set to chromeos locale if account data has been downloaded. |
(...skipping 29 matching lines...) Expand all Loading... |
287 | 287 |
288 DISALLOW_COPY_AND_ASSIGN(User); | 288 DISALLOW_COPY_AND_ASSIGN(User); |
289 }; | 289 }; |
290 | 290 |
291 // List of known users. | 291 // List of known users. |
292 typedef std::vector<User*> UserList; | 292 typedef std::vector<User*> UserList; |
293 | 293 |
294 } // namespace user_manager | 294 } // namespace user_manager |
295 | 295 |
296 #endif // COMPONENTS_USER_MANAGER_USER_H_ | 296 #endif // COMPONENTS_USER_MANAGER_USER_H_ |
OLD | NEW |