| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_CHROMEOS_LOGIN_USER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "third_party/skia/include/core/SkBitmap.h" | 13 #include "third_party/skia/include/core/SkBitmap.h" |
| 14 | 14 |
| 15 namespace chromeos { | 15 namespace chromeos { |
| 16 | 16 |
| 17 // A class representing information about a previously logged in user. | 17 // A class representing information about a previously logged in user. |
| 18 // Each user has a canonical email (username), returned by |email()| and |
| 19 // may have a different displayed email (in the raw form as entered by user), |
| 20 // returned by |displayed_email()|. |
| 21 // Displayed emails are for use in UI only, anywhere else users must be referred |
| 22 // to by |email()|. |
| 18 class User { | 23 class User { |
| 19 public: | 24 public: |
| 20 // User OAuth token status according to the last check. | 25 // User OAuth token status according to the last check. |
| 21 typedef enum { | 26 typedef enum { |
| 22 OAUTH_TOKEN_STATUS_UNKNOWN = 0, | 27 OAUTH_TOKEN_STATUS_UNKNOWN = 0, |
| 23 OAUTH_TOKEN_STATUS_INVALID = 1, | 28 OAUTH_TOKEN_STATUS_INVALID = 1, |
| 24 OAUTH_TOKEN_STATUS_VALID = 2, | 29 OAUTH_TOKEN_STATUS_VALID = 2, |
| 25 } OAuthTokenStatus; | 30 } OAuthTokenStatus; |
| 26 | 31 |
| 27 // Returned as |image_index| when user-selected file or photo is used as | 32 // Returned as |image_index| when user-selected file or photo is used as |
| (...skipping 10 matching lines...) Expand all Loading... |
| 38 std::string GetDisplayName() const; | 43 std::string GetDisplayName() const; |
| 39 | 44 |
| 40 // Tooltip contains user's display name and his email domain to distinguish | 45 // Tooltip contains user's display name and his email domain to distinguish |
| 41 // this user from the other one with the same display name. | 46 // this user from the other one with the same display name. |
| 42 std::string GetNameTooltip() const; | 47 std::string GetNameTooltip() const; |
| 43 | 48 |
| 44 // Returns true if some users have same display name. | 49 // Returns true if some users have same display name. |
| 45 bool NeedsNameTooltip() const; | 50 bool NeedsNameTooltip() const; |
| 46 | 51 |
| 47 // The image for this user. | 52 // The image for this user. |
| 48 void SetImage(const SkBitmap& image, int image_index); | |
| 49 const SkBitmap& image() const { return image_; } | 53 const SkBitmap& image() const { return image_; } |
| 50 int image_index() const { return image_index_; } | 54 int image_index() const { return image_index_; } |
| 51 | 55 |
| 52 // OAuth token status for this user. | 56 // OAuth token status for this user. |
| 53 OAuthTokenStatus oauth_token_status() const { return oauth_token_status_; } | 57 OAuthTokenStatus oauth_token_status() const { return oauth_token_status_; } |
| 54 void set_oauth_token_status(OAuthTokenStatus status) { | 58 |
| 55 oauth_token_status_ = status; | 59 // The displayed (non-canonical) user email. |
| 56 } | 60 std::string display_email() const { return display_email_; } |
| 57 | 61 |
| 58 private: | 62 private: |
| 59 friend class UserManager; | 63 friend class UserManager; |
| 60 | 64 |
| 61 // Do not allow anyone else to create new User instances. | 65 // Do not allow anyone else to create new User instances. |
| 62 explicit User(const std::string& email); | 66 explicit User(const std::string& email); |
| 63 ~User(); | 67 ~User(); |
| 64 | 68 |
| 69 // Setters are private so only UserManager can call them. |
| 70 void SetImage(const SkBitmap& image, int image_index); |
| 71 |
| 72 void set_oauth_token_status(OAuthTokenStatus status) { |
| 73 oauth_token_status_ = status; |
| 74 } |
| 75 |
| 76 void set_display_email(const std::string& display_email) { |
| 77 display_email_ = display_email; |
| 78 } |
| 79 |
| 65 std::string email_; | 80 std::string email_; |
| 81 // The displayed user email, defaults to |email_|. |
| 82 std::string display_email_; |
| 66 SkBitmap image_; | 83 SkBitmap image_; |
| 67 OAuthTokenStatus oauth_token_status_; | 84 OAuthTokenStatus oauth_token_status_; |
| 68 | 85 |
| 69 // Either index of a default image for the user, |kExternalImageIndex| or | 86 // Either index of a default image for the user, |kExternalImageIndex| or |
| 70 // |kProfileImageIndex|. | 87 // |kProfileImageIndex|. |
| 71 int image_index_; | 88 int image_index_; |
| 72 | 89 |
| 73 DISALLOW_COPY_AND_ASSIGN(User); | 90 DISALLOW_COPY_AND_ASSIGN(User); |
| 74 }; | 91 }; |
| 75 | 92 |
| 76 // List of known users. | 93 // List of known users. |
| 77 typedef std::vector<User*> UserList; | 94 typedef std::vector<User*> UserList; |
| 78 | 95 |
| 79 } // namespace chromeos | 96 } // namespace chromeos |
| 80 | 97 |
| 81 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_H_ | 98 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_H_ |
| OLD | NEW |