Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(182)

Side by Side Diff: components/user_manager/user.h

Issue 1412813003: This CL replaces user_manager::UserID with AccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@468875--Chrome-OS-handles-deletion-of-Gmail-account-poorly--Create-AccountID-structure-part2--user_names
Patch Set: Update after review. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // TODO: rename this to GetUserEmail()
achuithb 2015/10/28 23:11:46 TODO(alemate), please reference bug
Alexander Alekseev 2015/10/29 02:00:42 Done.
87 const std::string& email() const;
87 88
88 // The displayed user name. 89 // The displayed user name.
89 base::string16 display_name() const { return display_name_; } 90 base::string16 display_name() const { return display_name_; }
90 91
91 // If the user has to use SAML to log in. 92 // If the user has to use SAML to log in.
92 bool using_saml() const { return using_saml_; } 93 bool using_saml() const { return using_saml_; }
93 94
94 // UserInfo 95 // UserInfo
95 std::string GetEmail() const override; 96 std::string GetEmail() const override;
96 base::string16 GetDisplayName() const override; 97 base::string16 GetDisplayName() const override;
97 base::string16 GetGivenName() const override; 98 base::string16 GetGivenName() const override;
98 const gfx::ImageSkia& GetImage() const override; 99 const gfx::ImageSkia& GetImage() const override;
99 UserID GetUserID() const override; 100 AccountId GetAccountId() const override;
100 101
101 // Allows managing child status of the user. Used for RegularUser. 102 // Allows managing child status of the user. Used for RegularUser.
102 virtual void SetIsChild(bool is_child); 103 virtual void SetIsChild(bool is_child);
103 104
104 // Returns true if user has gaia account. True for users of types 105 // Returns true if user has gaia account. True for users of types
105 // USER_TYPE_REGULAR and USER_TYPE_CHILD. 106 // USER_TYPE_REGULAR and USER_TYPE_CHILD.
106 virtual bool HasGaiaAccount() const; 107 virtual bool HasGaiaAccount() const;
107 108
108 // Returns true if user is supervised. 109 // Returns true if user is supervised.
109 virtual bool IsSupervised() const; 110 virtual bool IsSupervised() const;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 friend class chromeos::UserImageManagerImpl; 176 friend class chromeos::UserImageManagerImpl;
176 friend class chromeos::UserSessionManager; 177 friend class chromeos::UserSessionManager;
177 178
178 // For testing: 179 // For testing:
179 friend class FakeUserManager; 180 friend class FakeUserManager;
180 friend class chromeos::FakeChromeUserManager; 181 friend class chromeos::FakeChromeUserManager;
181 friend class chromeos::MockUserManager; 182 friend class chromeos::MockUserManager;
182 friend class chromeos::UserAddingScreenTest; 183 friend class chromeos::UserAddingScreenTest;
183 184
184 // Do not allow anyone else to create new User instances. 185 // Do not allow anyone else to create new User instances.
185 static User* CreateRegularUser(const UserID& email); 186 static User* CreateRegularUser(const AccountId& account_id);
186 static User* CreateGuestUser(); 187 static User* CreateGuestUser();
187 static User* CreateKioskAppUser(const UserID& kiosk_app_username); 188 static User* CreateKioskAppUser(const AccountId& kiosk_app_account_id);
188 static User* CreateSupervisedUser(const UserID& username); 189 static User* CreateSupervisedUser(const AccountId& account_id);
189 static User* CreatePublicAccountUser(const UserID& email); 190 static User* CreatePublicAccountUser(const AccountId& account_id);
190 191
191 explicit User(const std::string& email); 192 explicit User(const AccountId& account_id);
192 ~User() override; 193 ~User() override;
193 194
194 const std::string* GetAccountLocale() const { return account_locale_.get(); } 195 const std::string* GetAccountLocale() const { return account_locale_.get(); }
195 196
196 // Setters are private so only UserManager can call them. 197 // Setters are private so only UserManager can call them.
197 void SetAccountLocale(const std::string& resolved_account_locale); 198 void SetAccountLocale(const std::string& resolved_account_locale);
198 199
199 void SetImage(const UserImage& user_image, int image_index); 200 void SetImage(const UserImage& user_image, int image_index);
200 201
201 void SetImageURL(const GURL& image_url); 202 void SetImageURL(const GURL& image_url);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 void set_profile_is_created() { profile_is_created_ = true; } 245 void set_profile_is_created() { profile_is_created_ = true; }
245 246
246 // True if user has google account (not a guest or managed user). 247 // True if user has google account (not a guest or managed user).
247 bool has_gaia_account() const; 248 bool has_gaia_account() const;
248 249
249 void set_affiliation(bool is_affiliated) { 250 void set_affiliation(bool is_affiliated) {
250 is_affiliated_ = is_affiliated; 251 is_affiliated_ = is_affiliated;
251 } 252 }
252 253
253 private: 254 private:
254 std::string email_; 255 AccountId account_id_;
255 base::string16 display_name_; 256 base::string16 display_name_;
256 base::string16 given_name_; 257 base::string16 given_name_;
257 // The displayed user email, defaults to |email_|. 258 // The displayed user email, defaults to |email_|.
258 std::string display_email_; 259 std::string display_email_;
259 bool using_saml_; 260 bool using_saml_;
achuithb 2015/10/28 23:11:46 missed this one
Alexander Alekseev 2015/10/29 02:00:43 Done.
260 UserImage user_image_; 261 UserImage user_image_;
261 OAuthTokenStatus oauth_token_status_; 262 OAuthTokenStatus oauth_token_status_ = OAUTH_TOKEN_STATUS_UNKNOWN;
262 bool force_online_signin_; 263 bool force_online_signin_ = false;
263 264
264 // This is set to chromeos locale if account data has been downloaded. 265 // This is set to chromeos locale if account data has been downloaded.
265 // (Or failed to download, but at least one download attempt finished). 266 // (Or failed to download, but at least one download attempt finished).
266 // An empty string indicates error in data load, or in 267 // An empty string indicates error in data load, or in
267 // translation of Account locale to chromeos locale. 268 // translation of Account locale to chromeos locale.
268 scoped_ptr<std::string> account_locale_; 269 scoped_ptr<std::string> account_locale_;
269 270
270 // Used to identify homedir mount point. 271 // Used to identify homedir mount point.
271 std::string username_hash_; 272 std::string username_hash_;
272 273
273 // Either index of a default image for the user, |USER_IMAGE_EXTERNAL| or 274 // Either index of a default image for the user, |USER_IMAGE_EXTERNAL| or
274 // |USER_IMAGE_PROFILE|. 275 // |USER_IMAGE_PROFILE|.
275 int image_index_; 276 int image_index_ = USER_IMAGE_INVALID;
276 277
277 // True if current user image is a stub set by a |SetStubImage| call. 278 // True if current user image is a stub set by a |SetStubImage| call.
278 bool image_is_stub_; 279 bool image_is_stub_ = false;
279 280
280 // True if current user image is being loaded from file. 281 // True if current user image is being loaded from file.
281 bool image_is_loading_; 282 bool image_is_loading_ = false;
282 283
283 // True if user is able to lock screen. 284 // True if user is able to lock screen.
284 bool can_lock_; 285 bool can_lock_ = false;
285 286
286 // True if user is currently logged in in current session. 287 // True if user is currently logged in in current session.
287 bool is_logged_in_; 288 bool is_logged_in_ = false;
288 289
289 // True if user is currently logged in and active in current session. 290 // True if user is currently logged in and active in current session.
290 bool is_active_; 291 bool is_active_ = false;
291 292
292 // True if user Profile is created 293 // True if user Profile is created
293 bool profile_is_created_; 294 bool profile_is_created_ = false;
294 295
295 // True if the user is affiliated to the device. 296 // True if the user is affiliated to the device.
296 bool is_affiliated_; 297 bool is_affiliated_ = false;
297 298
298 DISALLOW_COPY_AND_ASSIGN(User); 299 DISALLOW_COPY_AND_ASSIGN(User);
299 }; 300 };
300 301
301 // List of known users. 302 // List of known users.
302 typedef std::vector<User*> UserList; 303 typedef std::vector<User*> UserList;
achuithb 2015/10/28 23:11:46 since you're here, let's switch to using UserList
Alexander Alekseev 2015/10/29 02:00:42 Done.
303 304
304 } // namespace user_manager 305 } // namespace user_manager
305 306
306 #endif // COMPONENTS_USER_MANAGER_USER_H_ 307 #endif // COMPONENTS_USER_MANAGER_USER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698