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