OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_USERS_USER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USERS_USER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_USER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_USER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "ash/session/user_info.h" | 11 #include "ash/session/user_info.h" |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "chrome/browser/chromeos/login/users/avatar/user_image.h" | 14 #include "chrome/browser/chromeos/login/users/avatar/user_image.h" |
15 #include "third_party/skia/include/core/SkBitmap.h" | 15 #include "third_party/skia/include/core/SkBitmap.h" |
16 #include "ui/gfx/image/image_skia.h" | 16 #include "ui/gfx/image/image_skia.h" |
17 | 17 |
18 namespace chromeos { | 18 namespace chromeos { |
19 | 19 |
20 extern const int kDefaultImagesCount; | 20 extern const int kDefaultImagesCount; |
21 | 21 |
22 // Information that is passed around while authentication is in progress. The | |
23 // credentials may consist of a |user_id|, |password| pair or a GAIA | |
24 // |auth_code|. The |user_id_hash| is used to locate the user's home directory | |
25 // mount point for the user. It is set when the mount has been completed. | |
26 class UserContext { | |
27 public: | |
28 // The authentication flow used during sign-in. | |
29 enum AuthFlow { | |
30 // Online authentication against GAIA. GAIA did not redirect to a SAML IdP. | |
31 AUTH_FLOW_GAIA_WITHOUT_SAML, | |
32 // Online authentication against GAIA. GAIA redirected to a SAML IdP. | |
33 AUTH_FLOW_GAIA_WITH_SAML, | |
34 // Offline authentication against a cached key. | |
35 AUTH_FLOW_OFFLINE | |
36 }; | |
37 | |
38 UserContext(); | |
39 UserContext(const UserContext& other); | |
40 explicit UserContext(const std::string& user_id); | |
41 ~UserContext(); | |
42 | |
43 bool operator==(const UserContext& context) const; | |
44 | |
45 const std::string& GetUserID() const; | |
46 const std::string& GetPassword() const; | |
47 bool DoesNeedPasswordHashing() const; | |
48 const std::string& GetKeyLabel() const; | |
49 const std::string& GetAuthCode() const; | |
50 const std::string& GetUserIDHash() const; | |
51 bool IsUsingOAuth() const; | |
52 AuthFlow GetAuthFlow() const; | |
53 | |
54 bool HasCredentials() const; | |
55 | |
56 void SetUserID(const std::string& user_id); | |
57 void SetPassword(const std::string& password); | |
58 void SetDoesNeedPasswordHashing(bool does_need_password_hashing); | |
59 void SetKeyLabel(const std::string& key_label); | |
60 void SetAuthCode(const std::string& auth_code); | |
61 void SetUserIDHash(const std::string& user_id_hash); | |
62 void SetIsUsingOAuth(bool is_using_oauth); | |
63 void SetAuthFlow(AuthFlow auth_flow); | |
64 | |
65 void ClearSecrets(); | |
66 | |
67 private: | |
68 std::string user_id_; | |
69 std::string password_; | |
70 bool does_need_password_hashing_; | |
71 std::string key_label_; | |
72 std::string auth_code_; | |
73 std::string user_id_hash_; | |
74 bool is_using_oauth_; | |
75 AuthFlow auth_flow_; | |
76 }; | |
77 | |
78 // A class representing information about a previously logged in user. | 22 // A class representing information about a previously logged in user. |
79 // Each user has a canonical email (username), returned by |email()| and | 23 // Each user has a canonical email (username), returned by |email()| and |
80 // 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), |
81 // returned by |displayed_email()|. | 25 // returned by |displayed_email()|. |
82 // 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 |
83 // to by |email()|. | 27 // to by |email()|. |
84 class User : public ash::UserInfo { | 28 class User : public ash::UserInfo { |
85 public: | 29 public: |
86 // The user type. Used in a histogram; do not modify existing types. | 30 // The user type. Used in a histogram; do not modify existing types. |
87 typedef enum { | 31 typedef enum { |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 | 277 |
334 DISALLOW_COPY_AND_ASSIGN(User); | 278 DISALLOW_COPY_AND_ASSIGN(User); |
335 }; | 279 }; |
336 | 280 |
337 // List of known users. | 281 // List of known users. |
338 typedef std::vector<User*> UserList; | 282 typedef std::vector<User*> UserList; |
339 | 283 |
340 } // namespace chromeos | 284 } // namespace chromeos |
341 | 285 |
342 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_USER_H_ | 286 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_USER_H_ |
OLD | NEW |