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 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
13 #include "chrome/browser/chromeos/login/user_image.h" | 13 #include "chrome/browser/chromeos/login/user_image.h" |
14 #include "third_party/skia/include/core/SkBitmap.h" | 14 #include "third_party/skia/include/core/SkBitmap.h" |
15 #include "ui/gfx/image/image_skia.h" | 15 #include "ui/gfx/image/image_skia.h" |
16 | 16 |
17 namespace chromeos { | 17 namespace chromeos { |
18 | 18 |
19 extern const int kDefaultImagesCount; | 19 extern const int kDefaultImagesCount; |
20 | 20 |
21 // User context data that is being exchanged between part of ChromeOS | 21 // User context data that is being exchanged between part of ChromeOS |
22 // authentication mechanism. Includes credentials: | 22 // authentication mechanism. Includes credentials: |
23 // |username|, |password|, |auth_code| and |username_hash| which is returned | 23 // |username|, |password|, |auth_code| and |username_hash| which is returned |
24 // back once user homedir is mounted. |username_hash| is used to identify | 24 // back once user homedir is mounted. |username_hash| is used to identify |
25 // user homedir mount point. | 25 // user homedir mount point. |
26 struct UserContext { | 26 struct UserContext { |
27 // The authentication flow used during sign-in. | |
28 enum AuthFlow { | |
29 // Online authentication against GAIA. GAIA did not redirect to a SAML IdP. | |
30 AUTH_FLOW_GAIA_WITHOUT_SAML, | |
31 // Online authentication against GAIA. GAIA redirected to a SAML IdP. | |
32 AUTH_FLOW_GAIA_WITH_SAML, | |
33 // Offline authentication against a cached password. | |
34 AUTH_FLOW_OFFLINE | |
35 }; | |
36 | |
37 UserContext(); | 27 UserContext(); |
38 UserContext(const std::string& username, | 28 UserContext(const std::string& username, |
39 const std::string& password, | 29 const std::string& password, |
40 const std::string& auth_code); | 30 const std::string& auth_code); |
41 UserContext(const std::string& username, | 31 UserContext(const std::string& username, |
42 const std::string& password, | 32 const std::string& password, |
43 const std::string& auth_code, | 33 const std::string& auth_code, |
44 const std::string& username_hash); | 34 const std::string& username_hash); |
45 UserContext(const std::string& username, | 35 UserContext(const std::string& username, |
46 const std::string& password, | 36 const std::string& password, |
47 const std::string& auth_code, | 37 const std::string& auth_code, |
48 const std::string& username_hash, | 38 const std::string& username_hash, |
49 bool using_oauth, | 39 bool using_oauth); |
50 AuthFlow auth_flow); | |
51 virtual ~UserContext(); | 40 virtual ~UserContext(); |
52 bool operator==(const UserContext& context) const; | 41 bool operator==(const UserContext& context) const; |
53 std::string username; | 42 std::string username; |
54 std::string password; | 43 std::string password; |
55 std::string auth_code; | 44 std::string auth_code; |
56 std::string username_hash; | 45 std::string username_hash; |
57 bool using_oauth; | 46 bool using_oauth; |
58 AuthFlow auth_flow; | |
59 }; | 47 }; |
60 | 48 |
61 // A class representing information about a previously logged in user. | 49 // A class representing information about a previously logged in user. |
62 // Each user has a canonical email (username), returned by |email()| and | 50 // Each user has a canonical email (username), returned by |email()| and |
63 // may have a different displayed email (in the raw form as entered by user), | 51 // may have a different displayed email (in the raw form as entered by user), |
64 // returned by |displayed_email()|. | 52 // returned by |displayed_email()|. |
65 // Displayed emails are for use in UI only, anywhere else users must be referred | 53 // Displayed emails are for use in UI only, anywhere else users must be referred |
66 // to by |email()|. | 54 // to by |email()|. |
67 class User { | 55 class User { |
68 public: | 56 public: |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 // Returns the URL of user image, if there is any. Currently only the profile | 143 // Returns the URL of user image, if there is any. Currently only the profile |
156 // image has a URL, for other images empty URL is returned. | 144 // image has a URL, for other images empty URL is returned. |
157 GURL image_url() const { return user_image_.url(); } | 145 GURL image_url() const { return user_image_.url(); } |
158 | 146 |
159 // True if user image is a stub (while real image is being loaded from file). | 147 // True if user image is a stub (while real image is being loaded from file). |
160 bool image_is_stub() const { return image_is_stub_; } | 148 bool image_is_stub() const { return image_is_stub_; } |
161 | 149 |
162 // True if image is being loaded from file. | 150 // True if image is being loaded from file. |
163 bool image_is_loading() const { return image_is_loading_; } | 151 bool image_is_loading() const { return image_is_loading_; } |
164 | 152 |
| 153 // OAuth token status for this user. |
| 154 OAuthTokenStatus oauth_token_status() const { return oauth_token_status_; } |
| 155 |
165 // The displayed user name. | 156 // The displayed user name. |
166 base::string16 display_name() const { return display_name_; } | 157 base::string16 display_name() const { return display_name_; } |
167 | 158 |
168 // The displayed (non-canonical) user email. | 159 // The displayed (non-canonical) user email. |
169 virtual std::string display_email() const; | 160 virtual std::string display_email() const; |
170 | 161 |
171 // OAuth token status for this user. | |
172 OAuthTokenStatus oauth_token_status() const { return oauth_token_status_; } | |
173 | |
174 // True if the user's session can be locked (i.e. the user has a password with | 162 // True if the user's session can be locked (i.e. the user has a password with |
175 // which to unlock the session). | 163 // which to unlock the session). |
176 virtual bool can_lock() const; | 164 virtual bool can_lock() const; |
177 | 165 |
178 virtual std::string username_hash() const; | 166 virtual std::string username_hash() const; |
179 | 167 |
180 // True if current user is logged in. | 168 // True if current user is logged in. |
181 virtual bool is_logged_in() const; | 169 virtual bool is_logged_in() const; |
182 | 170 |
183 // True if current user is active within the current session. | 171 // True if current user is active within the current session. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 | 204 |
217 void SetImage(const UserImage& user_image, int image_index); | 205 void SetImage(const UserImage& user_image, int image_index); |
218 | 206 |
219 void SetImageURL(const GURL& image_url); | 207 void SetImageURL(const GURL& image_url); |
220 | 208 |
221 // Sets a stub image until the next |SetImage| call. |image_index| may be | 209 // Sets a stub image until the next |SetImage| call. |image_index| may be |
222 // one of |kExternalImageIndex| or |kProfileImageIndex|. | 210 // one of |kExternalImageIndex| or |kProfileImageIndex|. |
223 // If |is_loading| is |true|, that means user image is being loaded from file. | 211 // If |is_loading| is |true|, that means user image is being loaded from file. |
224 void SetStubImage(int image_index, bool is_loading); | 212 void SetStubImage(int image_index, bool is_loading); |
225 | 213 |
| 214 void set_oauth_token_status(OAuthTokenStatus status) { |
| 215 oauth_token_status_ = status; |
| 216 } |
| 217 |
226 void set_display_name(const base::string16& display_name) { | 218 void set_display_name(const base::string16& display_name) { |
227 display_name_ = display_name; | 219 display_name_ = display_name; |
228 } | 220 } |
229 | 221 |
230 void set_given_name(const base::string16& given_name) { given_name_ = given_na
me; } | 222 void set_given_name(const base::string16& given_name) { given_name_ = given_na
me; } |
231 | 223 |
232 void set_display_email(const std::string& display_email) { | 224 void set_display_email(const std::string& display_email) { |
233 display_email_ = display_email; | 225 display_email_ = display_email; |
234 } | 226 } |
235 | 227 |
236 const UserImage& user_image() const { return user_image_; } | 228 const UserImage& user_image() const { return user_image_; } |
237 | 229 |
238 void set_oauth_token_status(OAuthTokenStatus status) { | |
239 oauth_token_status_ = status; | |
240 } | |
241 | |
242 void set_username_hash(const std::string& username_hash) { | 230 void set_username_hash(const std::string& username_hash) { |
243 username_hash_ = username_hash; | 231 username_hash_ = username_hash; |
244 } | 232 } |
245 | 233 |
246 void set_is_logged_in(bool is_logged_in) { | 234 void set_is_logged_in(bool is_logged_in) { |
247 is_logged_in_ = is_logged_in; | 235 is_logged_in_ = is_logged_in; |
248 } | 236 } |
249 | 237 |
250 void set_is_active(bool is_active) { | 238 void set_is_active(bool is_active) { |
251 is_active_ = is_active; | 239 is_active_ = is_active; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 | 285 |
298 DISALLOW_COPY_AND_ASSIGN(User); | 286 DISALLOW_COPY_AND_ASSIGN(User); |
299 }; | 287 }; |
300 | 288 |
301 // List of known users. | 289 // List of known users. |
302 typedef std::vector<User*> UserList; | 290 typedef std::vector<User*> UserList; |
303 | 291 |
304 } // namespace chromeos | 292 } // namespace chromeos |
305 | 293 |
306 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_H_ | 294 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_H_ |
OLD | NEW |