Chromium Code Reviews| 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 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 #include "components/user_manager/user_id.h" | 13 #include "components/signin/core/account_id/account_id.h" |
| 14 #include "components/user_manager/user_image/user_image.h" | 14 #include "components/user_manager/user_image/user_image.h" |
| 15 #include "components/user_manager/user_info.h" | 15 #include "components/user_manager/user_info.h" |
| 16 #include "components/user_manager/user_manager_export.h" | 16 #include "components/user_manager/user_manager_export.h" |
| 17 #include "components/user_manager/user_type.h" | 17 #include "components/user_manager/user_type.h" |
| 18 #include "third_party/skia/include/core/SkBitmap.h" | 18 #include "third_party/skia/include/core/SkBitmap.h" |
| 19 #include "ui/gfx/image/image_skia.h" | 19 #include "ui/gfx/image/image_skia.h" |
| 20 | 20 |
| 21 namespace chromeos { | 21 namespace chromeos { |
| 22 class ChromeUserManagerImpl; | 22 class ChromeUserManagerImpl; |
| 23 class FakeChromeUserManager; | 23 class FakeChromeUserManager; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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& email() const; |
|
achuithb
2015/10/23 00:08:52
Add a TODO to rename this to GetUserEmail()
Alexander Alekseev
2015/10/23 09:11:24
Done.
| |
| 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 AccountId GetUserID() const override; |
|
achuithb
2015/10/23 00:08:52
GetAccountID()
Alexander Alekseev
2015/10/23 09:11:24
Done.
| |
| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 175 friend class chromeos::UserImageManagerImpl; | 175 friend class chromeos::UserImageManagerImpl; |
| 176 friend class chromeos::UserSessionManager; | 176 friend class chromeos::UserSessionManager; |
| 177 | 177 |
| 178 // For testing: | 178 // For testing: |
| 179 friend class FakeUserManager; | 179 friend class FakeUserManager; |
| 180 friend class chromeos::FakeChromeUserManager; | 180 friend class chromeos::FakeChromeUserManager; |
| 181 friend class chromeos::MockUserManager; | 181 friend class chromeos::MockUserManager; |
| 182 friend class chromeos::UserAddingScreenTest; | 182 friend class chromeos::UserAddingScreenTest; |
| 183 | 183 |
| 184 // Do not allow anyone else to create new User instances. | 184 // Do not allow anyone else to create new User instances. |
| 185 static User* CreateRegularUser(const UserID& email); | 185 static User* CreateRegularUser(const AccountId& user_id); |
|
achuithb
2015/10/23 00:08:52
account_id, here and below
Alexander Alekseev
2015/10/23 09:11:24
Done.
| |
| 186 static User* CreateGuestUser(); | 186 static User* CreateGuestUser(); |
| 187 static User* CreateKioskAppUser(const UserID& kiosk_app_username); | 187 static User* CreateKioskAppUser(const AccountId& kiosk_app_username); |
|
achuithb
2015/10/23 00:08:52
kiosk_app_account_id
Alexander Alekseev
2015/10/23 09:11:24
Done.
| |
| 188 static User* CreateSupervisedUser(const UserID& username); | 188 static User* CreateSupervisedUser(const AccountId& user_id); |
| 189 static User* CreatePublicAccountUser(const UserID& email); | 189 static User* CreatePublicAccountUser(const AccountId& user_id); |
| 190 | 190 |
| 191 explicit User(const std::string& email); | 191 explicit User(const AccountId& email); |
|
achuithb
2015/10/23 00:08:52
account_id
Alexander Alekseev
2015/10/23 09:11:24
Done.
| |
| 192 ~User() override; | 192 ~User() override; |
| 193 | 193 |
| 194 const std::string* GetAccountLocale() const { return account_locale_.get(); } | 194 const std::string* GetAccountLocale() const { return account_locale_.get(); } |
| 195 | 195 |
| 196 // Setters are private so only UserManager can call them. | 196 // Setters are private so only UserManager can call them. |
| 197 void SetAccountLocale(const std::string& resolved_account_locale); | 197 void SetAccountLocale(const std::string& resolved_account_locale); |
| 198 | 198 |
| 199 void SetImage(const UserImage& user_image, int image_index); | 199 void SetImage(const UserImage& user_image, int image_index); |
| 200 | 200 |
| 201 void SetImageURL(const GURL& image_url); | 201 void SetImageURL(const GURL& image_url); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 void set_profile_is_created() { profile_is_created_ = true; } | 244 void set_profile_is_created() { profile_is_created_ = true; } |
| 245 | 245 |
| 246 // True if user has google account (not a guest or managed user). | 246 // True if user has google account (not a guest or managed user). |
| 247 bool has_gaia_account() const; | 247 bool has_gaia_account() const; |
| 248 | 248 |
| 249 void set_affiliation(bool is_affiliated) { | 249 void set_affiliation(bool is_affiliated) { |
| 250 is_affiliated_ = is_affiliated; | 250 is_affiliated_ = is_affiliated; |
| 251 } | 251 } |
| 252 | 252 |
| 253 private: | 253 private: |
| 254 std::string email_; | 254 AccountId account_id_; |
| 255 base::string16 display_name_; | 255 base::string16 display_name_; |
| 256 base::string16 given_name_; | 256 base::string16 given_name_; |
| 257 // The displayed user email, defaults to |email_|. | 257 // The displayed user email, defaults to |email_|. |
| 258 std::string display_email_; | 258 std::string display_email_; |
| 259 bool using_saml_; | 259 bool using_saml_; |
| 260 UserImage user_image_; | 260 UserImage user_image_; |
| 261 OAuthTokenStatus oauth_token_status_; | 261 OAuthTokenStatus oauth_token_status_; |
| 262 bool force_online_signin_; | 262 bool force_online_signin_; |
| 263 | 263 |
| 264 // This is set to chromeos locale if account data has been downloaded. | 264 // This is set to chromeos locale if account data has been downloaded. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 297 | 297 |
| 298 DISALLOW_COPY_AND_ASSIGN(User); | 298 DISALLOW_COPY_AND_ASSIGN(User); |
| 299 }; | 299 }; |
| 300 | 300 |
| 301 // List of known users. | 301 // List of known users. |
| 302 typedef std::vector<User*> UserList; | 302 typedef std::vector<User*> UserList; |
| 303 | 303 |
| 304 } // namespace user_manager | 304 } // namespace user_manager |
| 305 | 305 |
| 306 #endif // COMPONENTS_USER_MANAGER_USER_H_ | 306 #endif // COMPONENTS_USER_MANAGER_USER_H_ |
| OLD | NEW |