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