| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "ash/session/user_info.h" | |
| 12 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 13 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 14 #include "chrome/browser/chromeos/login/user_image.h" | 13 #include "chrome/browser/chromeos/login/user_image.h" |
| 15 #include "third_party/skia/include/core/SkBitmap.h" | 14 #include "third_party/skia/include/core/SkBitmap.h" |
| 16 #include "ui/gfx/image/image_skia.h" | 15 #include "ui/gfx/image/image_skia.h" |
| 17 | 16 |
| 18 namespace chromeos { | 17 namespace chromeos { |
| 19 | 18 |
| 20 extern const int kDefaultImagesCount; | 19 extern const int kDefaultImagesCount; |
| 21 | 20 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 bool using_oauth; | 62 bool using_oauth; |
| 64 AuthFlow auth_flow; | 63 AuthFlow auth_flow; |
| 65 }; | 64 }; |
| 66 | 65 |
| 67 // A class representing information about a previously logged in user. | 66 // A class representing information about a previously logged in user. |
| 68 // Each user has a canonical email (username), returned by |email()| and | 67 // Each user has a canonical email (username), returned by |email()| and |
| 69 // may have a different displayed email (in the raw form as entered by user), | 68 // may have a different displayed email (in the raw form as entered by user), |
| 70 // returned by |displayed_email()|. | 69 // returned by |displayed_email()|. |
| 71 // Displayed emails are for use in UI only, anywhere else users must be referred | 70 // Displayed emails are for use in UI only, anywhere else users must be referred |
| 72 // to by |email()|. | 71 // to by |email()|. |
| 73 class User : public ash::UserInfo { | 72 class User { |
| 74 public: | 73 public: |
| 75 // The user type. Used in a histogram; do not modify existing types. | 74 // The user type. Used in a histogram; do not modify existing types. |
| 76 typedef enum { | 75 typedef enum { |
| 77 // Regular user, has a user name and password. | 76 // Regular user, has a user name and password. |
| 78 USER_TYPE_REGULAR = 0, | 77 USER_TYPE_REGULAR = 0, |
| 79 // Guest user, logs in without authentication. | 78 // Guest user, logs in without authentication. |
| 80 USER_TYPE_GUEST = 1, | 79 USER_TYPE_GUEST = 1, |
| 81 // Retail mode user, logs in without authentication. This is a special user | 80 // Retail mode user, logs in without authentication. This is a special user |
| 82 // type used in retail mode only. | 81 // type used in retail mode only. |
| 83 USER_TYPE_RETAIL_MODE = 2, | 82 USER_TYPE_RETAIL_MODE = 2, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 POLICY = 5, // Controlled by policy, can't be changed by the user. | 116 POLICY = 5, // Controlled by policy, can't be changed by the user. |
| 118 WALLPAPER_TYPE_COUNT = 6 | 117 WALLPAPER_TYPE_COUNT = 6 |
| 119 }; | 118 }; |
| 120 | 119 |
| 121 // Returns the user type. | 120 // Returns the user type. |
| 122 virtual UserType GetType() const = 0; | 121 virtual UserType GetType() const = 0; |
| 123 | 122 |
| 124 // The email the user used to log in. | 123 // The email the user used to log in. |
| 125 const std::string& email() const { return email_; } | 124 const std::string& email() const { return email_; } |
| 126 | 125 |
| 127 // The displayed user name. | 126 // Returns the human name to display for this user. |
| 128 base::string16 display_name() const { return display_name_; } | 127 base::string16 GetDisplayName() const; |
| 129 | 128 |
| 130 // ash::UserInfo | 129 // Returns given name of user, or empty string if given name is unknown. |
| 131 virtual std::string GetEmail() const OVERRIDE; | 130 const base::string16& given_name() const { return given_name_; } |
| 132 virtual base::string16 GetDisplayName() const OVERRIDE; | |
| 133 virtual base::string16 GetGivenName() const OVERRIDE; | |
| 134 virtual const gfx::ImageSkia& GetImage() const OVERRIDE; | |
| 135 virtual std::string GetUserID() const OVERRIDE; | |
| 136 | 131 |
| 137 // Returns the account name part of the email. Use the display form of the | 132 // Returns the account name part of the email. Use the display form of the |
| 138 // email if available and use_display_name == true. Otherwise use canonical. | 133 // email if available and use_display_name == true. Otherwise use canonical. |
| 139 std::string GetAccountName(bool use_display_email) const; | 134 std::string GetAccountName(bool use_display_email) const; |
| 140 | 135 |
| 136 // The image for this user. |
| 137 const gfx::ImageSkia& image() const { return user_image_.image(); } |
| 138 |
| 141 // Whether the user has a default image. | 139 // Whether the user has a default image. |
| 142 bool HasDefaultImage() const; | 140 bool HasDefaultImage() const; |
| 143 | 141 |
| 144 // True if user image can be synced. | 142 // True if user image can be synced. |
| 145 virtual bool CanSyncImage() const; | 143 virtual bool CanSyncImage() const; |
| 146 | 144 |
| 147 int image_index() const { return image_index_; } | 145 int image_index() const { return image_index_; } |
| 148 bool has_raw_image() const { return user_image_.has_raw_image(); } | 146 bool has_raw_image() const { return user_image_.has_raw_image(); } |
| 149 // Returns raw representation of static user image. | 147 // Returns raw representation of static user image. |
| 150 const UserImage::RawImage& raw_image() const { | 148 const UserImage::RawImage& raw_image() const { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 163 // Returns the URL of user image, if there is any. Currently only the profile | 161 // Returns the URL of user image, if there is any. Currently only the profile |
| 164 // image has a URL, for other images empty URL is returned. | 162 // image has a URL, for other images empty URL is returned. |
| 165 GURL image_url() const { return user_image_.url(); } | 163 GURL image_url() const { return user_image_.url(); } |
| 166 | 164 |
| 167 // True if user image is a stub (while real image is being loaded from file). | 165 // True if user image is a stub (while real image is being loaded from file). |
| 168 bool image_is_stub() const { return image_is_stub_; } | 166 bool image_is_stub() const { return image_is_stub_; } |
| 169 | 167 |
| 170 // True if image is being loaded from file. | 168 // True if image is being loaded from file. |
| 171 bool image_is_loading() const { return image_is_loading_; } | 169 bool image_is_loading() const { return image_is_loading_; } |
| 172 | 170 |
| 171 // The displayed user name. |
| 172 base::string16 display_name() const { return display_name_; } |
| 173 |
| 173 // The displayed (non-canonical) user email. | 174 // The displayed (non-canonical) user email. |
| 174 virtual std::string display_email() const; | 175 virtual std::string display_email() const; |
| 175 | 176 |
| 176 // OAuth token status for this user. | 177 // OAuth token status for this user. |
| 177 OAuthTokenStatus oauth_token_status() const { return oauth_token_status_; } | 178 OAuthTokenStatus oauth_token_status() const { return oauth_token_status_; } |
| 178 | 179 |
| 179 // Whether online authentication against GAIA should be enforced during the | 180 // Whether online authentication against GAIA should be enforced during the |
| 180 // user's next sign-in. | 181 // user's next sign-in. |
| 181 bool force_online_signin() const { return force_online_signin_; } | 182 bool force_online_signin() const { return force_online_signin_; } |
| 182 | 183 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 | 321 |
| 321 DISALLOW_COPY_AND_ASSIGN(User); | 322 DISALLOW_COPY_AND_ASSIGN(User); |
| 322 }; | 323 }; |
| 323 | 324 |
| 324 // List of known users. | 325 // List of known users. |
| 325 typedef std::vector<User*> UserList; | 326 typedef std::vector<User*> UserList; |
| 326 | 327 |
| 327 } // namespace chromeos | 328 } // namespace chromeos |
| 328 | 329 |
| 329 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_H_ | 330 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_H_ |
| OLD | NEW |