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 "third_party/skia/include/core/SkBitmap.h" | 13 #include "third_party/skia/include/core/SkBitmap.h" |
14 | 14 |
15 // The demo user is represented by a domainless username. | 15 // The demo user is represented by a domainless username. |
16 const char kDemoUser[] = "demouser"; | 16 const char kDemoUser[] = "demouser"; |
17 | 17 |
18 namespace chromeos { | 18 namespace chromeos { |
19 | 19 |
20 class UserImage; | |
21 | |
20 // A class representing information about a previously logged in user. | 22 // A class representing information about a previously logged in user. |
21 // Each user has a canonical email (username), returned by |email()| and | 23 // 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), | 24 // may have a different displayed email (in the raw form as entered by user), |
23 // returned by |displayed_email()|. | 25 // returned by |displayed_email()|. |
24 // Displayed emails are for use in UI only, anywhere else users must be referred | 26 // Displayed emails are for use in UI only, anywhere else users must be referred |
25 // to by |email()|. | 27 // to by |email()|. |
26 class User { | 28 class User { |
27 public: | 29 public: |
28 // User OAuth token status according to the last check. | 30 // User OAuth token status according to the last check. |
29 typedef enum { | 31 typedef enum { |
(...skipping 27 matching lines...) Expand all Loading... | |
57 // Tooltip contains user's display name and his email domain to distinguish | 59 // Tooltip contains user's display name and his email domain to distinguish |
58 // this user from the other one with the same display name. | 60 // this user from the other one with the same display name. |
59 std::string GetNameTooltip() const; | 61 std::string GetNameTooltip() const; |
60 | 62 |
61 // Returns true if some users have same display name. | 63 // Returns true if some users have same display name. |
62 bool NeedsNameTooltip() const; | 64 bool NeedsNameTooltip() const; |
63 | 65 |
64 // The image for this user. | 66 // The image for this user. |
65 const SkBitmap& image() const { return image_; } | 67 const SkBitmap& image() const { return image_; } |
66 int image_index() const { return image_index_; } | 68 int image_index() const { return image_index_; } |
69 bool has_gif_image() const { return has_gif_image_; } | |
Ivan Korotkov
2012/05/29 10:50:23
This may be kind of "architecture astronautism" bu
ygorshenin1
2012/05/30 12:17:34
Done.
| |
70 | |
71 bool gif_image(std::vector<unsigned char>* raw_data) const { | |
Ivan Korotkov
2012/05/29 10:50:23
Only trivial inline setters/getters should be unix
ygorshenin1
2012/05/30 12:17:34
Done.
| |
72 if (raw_data && has_gif_image()) { | |
73 *raw_data = gif_image_; | |
74 return true; | |
75 } | |
76 return false; | |
77 } | |
67 | 78 |
68 // The thumbnail of user custom wallpaper. | 79 // The thumbnail of user custom wallpaper. |
69 const SkBitmap& wallpaper_thumbnail() const { return wallpaper_thumbnail_; } | 80 const SkBitmap& wallpaper_thumbnail() const { return wallpaper_thumbnail_; } |
70 | 81 |
71 // True if user image is a stub (while real image is being loaded from file). | 82 // 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_; } | 83 bool image_is_stub() const { return image_is_stub_; } |
73 | 84 |
74 // OAuth token status for this user. | 85 // OAuth token status for this user. |
75 OAuthTokenStatus oauth_token_status() const { return oauth_token_status_; } | 86 OAuthTokenStatus oauth_token_status() const { return oauth_token_status_; } |
76 | 87 |
77 // The displayed (non-canonical) user email. | 88 // The displayed (non-canonical) user email. |
78 std::string display_email() const { return display_email_; } | 89 std::string display_email() const { return display_email_; } |
79 | 90 |
80 bool is_demo_user() const { return is_demo_user_; } | 91 bool is_demo_user() const { return is_demo_user_; } |
81 bool is_guest() const { return is_guest_; } | 92 bool is_guest() const { return is_guest_; } |
82 | 93 |
83 private: | 94 private: |
84 friend class UserManagerImpl; | 95 friend class UserManagerImpl; |
85 friend class MockUserManager; | 96 friend class MockUserManager; |
86 friend class UserManagerTest; | 97 friend class UserManagerTest; |
87 | 98 |
88 // Do not allow anyone else to create new User instances. | 99 // Do not allow anyone else to create new User instances. |
89 User(const std::string& email, bool is_guest); | 100 User(const std::string& email, bool is_guest); |
90 ~User(); | 101 ~User(); |
91 | 102 |
92 // Setters are private so only UserManager can call them. | 103 // Setters are private so only UserManager can call them. |
93 void SetImage(const SkBitmap& image, int image_index); | 104 void SetImage(const UserImage& user_image, int image_index); |
105 | |
94 // Sets a stub image until the next |SetImage| call. |image_index| may be | 106 // Sets a stub image until the next |SetImage| call. |image_index| may be |
95 // one of |kExternalImageIndex| or |kProfileImageIndex|. | 107 // one of |kExternalImageIndex| or |kProfileImageIndex|. |
96 void SetStubImage(int image_index); | 108 void SetStubImage(int image_index); |
97 | 109 |
98 // Set thumbnail of user custom wallpaper. | 110 // Set thumbnail of user custom wallpaper. |
99 void SetWallpaperThumbnail(const SkBitmap& wallpaper_thumbnail); | 111 void SetWallpaperThumbnail(const SkBitmap& wallpaper_thumbnail); |
100 | 112 |
101 void set_oauth_token_status(OAuthTokenStatus status) { | 113 void set_oauth_token_status(OAuthTokenStatus status) { |
102 oauth_token_status_ = status; | 114 oauth_token_status_ = status; |
103 } | 115 } |
104 | 116 |
105 void set_display_email(const std::string& display_email) { | 117 void set_display_email(const std::string& display_email) { |
106 display_email_ = display_email; | 118 display_email_ = display_email; |
107 } | 119 } |
108 | 120 |
109 std::string email_; | 121 std::string email_; |
110 // The displayed user email, defaults to |email_|. | 122 // The displayed user email, defaults to |email_|. |
111 std::string display_email_; | 123 std::string display_email_; |
112 SkBitmap image_; | 124 SkBitmap image_; |
Ivan Korotkov
2012/05/29 10:50:23
It looks like there is some duplication between th
ygorshenin1
2012/05/30 12:17:34
Done.
| |
125 bool has_gif_image_; | |
126 std::vector<unsigned char> gif_image_; | |
Ivan Korotkov
2012/05/29 10:50:23
Use UserImage::RawImage instead.
ygorshenin1
2012/05/30 12:17:34
As recommended to use UserImage instead of SkBitma
| |
113 OAuthTokenStatus oauth_token_status_; | 127 OAuthTokenStatus oauth_token_status_; |
114 SkBitmap wallpaper_thumbnail_; | 128 SkBitmap wallpaper_thumbnail_; |
115 | 129 |
116 // Either index of a default image for the user, |kExternalImageIndex| or | 130 // Either index of a default image for the user, |kExternalImageIndex| or |
117 // |kProfileImageIndex|. | 131 // |kProfileImageIndex|. |
118 int image_index_; | 132 int image_index_; |
119 | 133 |
120 // True if current user image is a stub set by a |SetStubImage| call. | 134 // True if current user image is a stub set by a |SetStubImage| call. |
121 bool image_is_stub_; | 135 bool image_is_stub_; |
122 | 136 |
123 // Is this a guest account? | 137 // Is this a guest account? |
124 bool is_guest_; | 138 bool is_guest_; |
125 | 139 |
126 // Is this a demo user account? | 140 // Is this a demo user account? |
127 bool is_demo_user_; | 141 bool is_demo_user_; |
128 | 142 |
129 DISALLOW_COPY_AND_ASSIGN(User); | 143 DISALLOW_COPY_AND_ASSIGN(User); |
130 }; | 144 }; |
131 | 145 |
132 // List of known users. | 146 // List of known users. |
133 typedef std::vector<User*> UserList; | 147 typedef std::vector<User*> UserList; |
134 | 148 |
135 } // namespace chromeos | 149 } // namespace chromeos |
136 | 150 |
137 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_H_ | 151 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_H_ |
OLD | NEW |