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 CHROME_BROWSER_CHROMEOS_LOGIN_USERS_USER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USERS_USER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_USER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_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" | 11 #include "ash/session/user_info.h" |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "chrome/browser/chromeos/login/users/avatar/user_image.h" | 14 #include "components/user_manager/user_image/user_image.h" |
15 #include "components/user_manager/user_type.h" | 15 #include "components/user_manager/user_type.h" |
16 #include "third_party/skia/include/core/SkBitmap.h" | 16 #include "third_party/skia/include/core/SkBitmap.h" |
17 #include "ui/gfx/image/image_skia.h" | 17 #include "ui/gfx/image/image_skia.h" |
18 | 18 |
19 namespace chromeos { | 19 namespace chromeos { |
20 | 20 |
21 extern const int kDefaultImagesCount; | 21 extern const int kDefaultImagesCount; |
22 | 22 |
23 // A class representing information about a previously logged in user. | 23 // A class representing information about a previously logged in user. |
24 // Each user has a canonical email (username), returned by |email()| and | 24 // Each user has a canonical email (username), returned by |email()| and |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 76 |
77 // Whether the user has a default image. | 77 // Whether the user has a default image. |
78 bool HasDefaultImage() const; | 78 bool HasDefaultImage() const; |
79 | 79 |
80 // True if user image can be synced. | 80 // True if user image can be synced. |
81 virtual bool CanSyncImage() const; | 81 virtual bool CanSyncImage() const; |
82 | 82 |
83 int image_index() const { return image_index_; } | 83 int image_index() const { return image_index_; } |
84 bool has_raw_image() const { return user_image_.has_raw_image(); } | 84 bool has_raw_image() const { return user_image_.has_raw_image(); } |
85 // Returns raw representation of static user image. | 85 // Returns raw representation of static user image. |
86 const UserImage::RawImage& raw_image() const { | 86 const user_manager::UserImage::RawImage& raw_image() const { |
87 return user_image_.raw_image(); | 87 return user_image_.raw_image(); |
88 } | 88 } |
89 bool has_animated_image() const { return user_image_.has_animated_image(); } | 89 bool has_animated_image() const { return user_image_.has_animated_image(); } |
90 // Returns raw representation of animated user image. | 90 // Returns raw representation of animated user image. |
91 const UserImage::RawImage& animated_image() const { | 91 const user_manager::UserImage::RawImage& animated_image() const { |
92 return user_image_.animated_image(); | 92 return user_image_.animated_image(); |
93 } | 93 } |
94 | 94 |
95 // Whether |raw_image| contains data in format that is considered safe to | 95 // Whether |raw_image| contains data in format that is considered safe to |
96 // decode in sensitive environment (on Login screen). | 96 // decode in sensitive environment (on Login screen). |
97 bool image_is_safe_format() const { return user_image_.is_safe_format(); } | 97 bool image_is_safe_format() const { return user_image_.is_safe_format(); } |
98 | 98 |
99 // Returns the URL of user image, if there is any. Currently only the profile | 99 // Returns the URL of user image, if there is any. Currently only the profile |
100 // image has a URL, for other images empty URL is returned. | 100 // image has a URL, for other images empty URL is returned. |
101 GURL image_url() const { return user_image_.url(); } | 101 GURL image_url() const { return user_image_.url(); } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 explicit User(const std::string& email); | 156 explicit User(const std::string& email); |
157 virtual ~User(); | 157 virtual ~User(); |
158 | 158 |
159 const std::string* GetAccountLocale() const { | 159 const std::string* GetAccountLocale() const { |
160 return account_locale_.get(); | 160 return account_locale_.get(); |
161 } | 161 } |
162 | 162 |
163 // Setters are private so only UserManager can call them. | 163 // Setters are private so only UserManager can call them. |
164 void SetAccountLocale(const std::string& resolved_account_locale); | 164 void SetAccountLocale(const std::string& resolved_account_locale); |
165 | 165 |
166 void SetImage(const UserImage& user_image, int image_index); | 166 void SetImage(const user_manager::UserImage& user_image, int image_index); |
167 | 167 |
168 void SetImageURL(const GURL& image_url); | 168 void SetImageURL(const GURL& image_url); |
169 | 169 |
170 // Sets a stub image until the next |SetImage| call. |image_index| may be | 170 // Sets a stub image until the next |SetImage| call. |image_index| may be |
171 // one of |kExternalImageIndex| or |kProfileImageIndex|. | 171 // one of |kExternalImageIndex| or |kProfileImageIndex|. |
172 // If |is_loading| is |true|, that means user image is being loaded from file. | 172 // If |is_loading| is |true|, that means user image is being loaded from file. |
173 void SetStubImage(int image_index, bool is_loading); | 173 void SetStubImage(int image_index, bool is_loading); |
174 | 174 |
175 void set_display_name(const base::string16& display_name) { | 175 void set_display_name(const base::string16& display_name) { |
176 display_name_ = display_name; | 176 display_name_ = display_name; |
177 } | 177 } |
178 | 178 |
179 void set_given_name(const base::string16& given_name) { | 179 void set_given_name(const base::string16& given_name) { |
180 given_name_ = given_name; | 180 given_name_ = given_name; |
181 } | 181 } |
182 | 182 |
183 void set_display_email(const std::string& display_email) { | 183 void set_display_email(const std::string& display_email) { |
184 display_email_ = display_email; | 184 display_email_ = display_email; |
185 } | 185 } |
186 | 186 |
187 const UserImage& user_image() const { return user_image_; } | 187 const user_manager::UserImage& user_image() const { return user_image_; } |
188 | 188 |
189 void set_oauth_token_status(OAuthTokenStatus status) { | 189 void set_oauth_token_status(OAuthTokenStatus status) { |
190 oauth_token_status_ = status; | 190 oauth_token_status_ = status; |
191 } | 191 } |
192 | 192 |
193 void set_force_online_signin(bool force_online_signin) { | 193 void set_force_online_signin(bool force_online_signin) { |
194 force_online_signin_ = force_online_signin; | 194 force_online_signin_ = force_online_signin; |
195 } | 195 } |
196 | 196 |
197 void set_username_hash(const std::string& username_hash) { | 197 void set_username_hash(const std::string& username_hash) { |
(...skipping 18 matching lines...) Expand all Loading... |
216 | 216 |
217 // True if user has google account (not a guest or managed user). | 217 // True if user has google account (not a guest or managed user). |
218 bool has_gaia_account() const; | 218 bool has_gaia_account() const; |
219 | 219 |
220 private: | 220 private: |
221 std::string email_; | 221 std::string email_; |
222 base::string16 display_name_; | 222 base::string16 display_name_; |
223 base::string16 given_name_; | 223 base::string16 given_name_; |
224 // The displayed user email, defaults to |email_|. | 224 // The displayed user email, defaults to |email_|. |
225 std::string display_email_; | 225 std::string display_email_; |
226 UserImage user_image_; | 226 user_manager::UserImage user_image_; |
227 OAuthTokenStatus oauth_token_status_; | 227 OAuthTokenStatus oauth_token_status_; |
228 bool force_online_signin_; | 228 bool force_online_signin_; |
229 | 229 |
230 // This is set to chromeos locale if account data has been downloaded. | 230 // This is set to chromeos locale if account data has been downloaded. |
231 // (Or failed to download, but at least one download attempt finished). | 231 // (Or failed to download, but at least one download attempt finished). |
232 // An empty string indicates error in data load, or in | 232 // An empty string indicates error in data load, or in |
233 // translation of Account locale to chromeos locale. | 233 // translation of Account locale to chromeos locale. |
234 scoped_ptr<std::string> account_locale_; | 234 scoped_ptr<std::string> account_locale_; |
235 | 235 |
236 // Used to identify homedir mount point. | 236 // Used to identify homedir mount point. |
(...skipping 23 matching lines...) Expand all Loading... |
260 | 260 |
261 DISALLOW_COPY_AND_ASSIGN(User); | 261 DISALLOW_COPY_AND_ASSIGN(User); |
262 }; | 262 }; |
263 | 263 |
264 // List of known users. | 264 // List of known users. |
265 typedef std::vector<User*> UserList; | 265 typedef std::vector<User*> UserList; |
266 | 266 |
267 } // namespace chromeos | 267 } // namespace chromeos |
268 | 268 |
269 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_USER_H_ | 269 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_USER_H_ |
OLD | NEW |