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 #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 "chrome/browser/chromeos/login/user_image.h" |
13 #include "third_party/skia/include/core/SkBitmap.h" | 14 #include "third_party/skia/include/core/SkBitmap.h" |
14 | 15 |
15 // The demo user is represented by a domainless username. | 16 // The demo user is represented by a domainless username. |
16 const char kDemoUser[] = "demouser"; | 17 const char kDemoUser[] = "demouser"; |
17 | 18 |
18 namespace chromeos { | 19 namespace chromeos { |
19 | 20 |
20 // A class representing information about a previously logged in user. | 21 // A class representing information about a previously logged in user. |
21 // Each user has a canonical email (username), returned by |email()| and | 22 // Each user has a canonical email (username), returned by |email()| and |
22 // may have a different displayed email (in the raw form as entered by user), | 23 // may have a different displayed email (in the raw form as entered by user), |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 std::string GetAccountName() const; | 56 std::string GetAccountName() const; |
56 | 57 |
57 // Tooltip contains user's display name and his email domain to distinguish | 58 // Tooltip contains user's display name and his email domain to distinguish |
58 // this user from the other one with the same display name. | 59 // this user from the other one with the same display name. |
59 std::string GetNameTooltip() const; | 60 std::string GetNameTooltip() const; |
60 | 61 |
61 // Returns true if some users have same display name. | 62 // Returns true if some users have same display name. |
62 bool NeedsNameTooltip() const; | 63 bool NeedsNameTooltip() const; |
63 | 64 |
64 // The image for this user. | 65 // The image for this user. |
65 const SkBitmap& image() const { return image_; } | 66 const SkBitmap& image() const { return user_image_.image(); } |
66 int image_index() const { return image_index_; } | 67 int image_index() const { return image_index_; } |
| 68 bool has_animated_image() const { return user_image_.has_animated_image(); } |
| 69 |
| 70 bool GetAnimatedImage(UserImage::RawImage* raw_image) const; |
67 | 71 |
68 // The thumbnail of user custom wallpaper. | 72 // The thumbnail of user custom wallpaper. |
69 const SkBitmap& wallpaper_thumbnail() const { return wallpaper_thumbnail_; } | 73 const SkBitmap& wallpaper_thumbnail() const { return wallpaper_thumbnail_; } |
70 | 74 |
71 // True if user image is a stub (while real image is being loaded from file). | 75 // True if user image is a stub (while real image is being loaded from file). |
72 bool image_is_stub() const { return image_is_stub_; } | 76 bool image_is_stub() const { return image_is_stub_; } |
73 | 77 |
74 // OAuth token status for this user. | 78 // OAuth token status for this user. |
75 OAuthTokenStatus oauth_token_status() const { return oauth_token_status_; } | 79 OAuthTokenStatus oauth_token_status() const { return oauth_token_status_; } |
76 | 80 |
77 // The displayed (non-canonical) user email. | 81 // The displayed (non-canonical) user email. |
78 std::string display_email() const { return display_email_; } | 82 std::string display_email() const { return display_email_; } |
79 | 83 |
80 bool is_demo_user() const { return is_demo_user_; } | 84 bool is_demo_user() const { return is_demo_user_; } |
81 bool is_guest() const { return is_guest_; } | 85 bool is_guest() const { return is_guest_; } |
82 | 86 |
83 private: | 87 private: |
84 friend class UserManagerImpl; | 88 friend class UserManagerImpl; |
85 friend class MockUserManager; | 89 friend class MockUserManager; |
86 friend class UserManagerTest; | 90 friend class UserManagerTest; |
87 | 91 |
88 // Do not allow anyone else to create new User instances. | 92 // Do not allow anyone else to create new User instances. |
89 User(const std::string& email, bool is_guest); | 93 User(const std::string& email, bool is_guest); |
90 ~User(); | 94 ~User(); |
91 | 95 |
92 // Setters are private so only UserManager can call them. | 96 // Setters are private so only UserManager can call them. |
93 void SetImage(const SkBitmap& image, int image_index); | 97 void SetImage(const UserImage& user_image, int image_index); |
| 98 |
94 // Sets a stub image until the next |SetImage| call. |image_index| may be | 99 // Sets a stub image until the next |SetImage| call. |image_index| may be |
95 // one of |kExternalImageIndex| or |kProfileImageIndex|. | 100 // one of |kExternalImageIndex| or |kProfileImageIndex|. |
96 void SetStubImage(int image_index); | 101 void SetStubImage(int image_index); |
97 | 102 |
98 // Set thumbnail of user custom wallpaper. | 103 // Set thumbnail of user custom wallpaper. |
99 void SetWallpaperThumbnail(const SkBitmap& wallpaper_thumbnail); | 104 void SetWallpaperThumbnail(const SkBitmap& wallpaper_thumbnail); |
100 | 105 |
101 void set_oauth_token_status(OAuthTokenStatus status) { | 106 void set_oauth_token_status(OAuthTokenStatus status) { |
102 oauth_token_status_ = status; | 107 oauth_token_status_ = status; |
103 } | 108 } |
104 | 109 |
105 void set_display_email(const std::string& display_email) { | 110 void set_display_email(const std::string& display_email) { |
106 display_email_ = display_email; | 111 display_email_ = display_email; |
107 } | 112 } |
108 | 113 |
109 std::string email_; | 114 std::string email_; |
110 // The displayed user email, defaults to |email_|. | 115 // The displayed user email, defaults to |email_|. |
111 std::string display_email_; | 116 std::string display_email_; |
112 SkBitmap image_; | 117 UserImage user_image_; |
113 OAuthTokenStatus oauth_token_status_; | 118 OAuthTokenStatus oauth_token_status_; |
114 SkBitmap wallpaper_thumbnail_; | 119 SkBitmap wallpaper_thumbnail_; |
115 | 120 |
116 // Either index of a default image for the user, |kExternalImageIndex| or | 121 // Either index of a default image for the user, |kExternalImageIndex| or |
117 // |kProfileImageIndex|. | 122 // |kProfileImageIndex|. |
118 int image_index_; | 123 int image_index_; |
119 | 124 |
120 // True if current user image is a stub set by a |SetStubImage| call. | 125 // True if current user image is a stub set by a |SetStubImage| call. |
121 bool image_is_stub_; | 126 bool image_is_stub_; |
122 | 127 |
123 // Is this a guest account? | 128 // Is this a guest account? |
124 bool is_guest_; | 129 bool is_guest_; |
125 | 130 |
126 // Is this a demo user account? | 131 // Is this a demo user account? |
127 bool is_demo_user_; | 132 bool is_demo_user_; |
128 | 133 |
129 DISALLOW_COPY_AND_ASSIGN(User); | 134 DISALLOW_COPY_AND_ASSIGN(User); |
130 }; | 135 }; |
131 | 136 |
132 // List of known users. | 137 // List of known users. |
133 typedef std::vector<User*> UserList; | 138 typedef std::vector<User*> UserList; |
134 | 139 |
135 } // namespace chromeos | 140 } // namespace chromeos |
136 | 141 |
137 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_H_ | 142 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_H_ |
OLD | NEW |