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_AUTH_AUTHENTICATOR_H_ | 5 #ifndef CHROMEOS_LOGIN_AUTH_AUTHENTICATOR_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_AUTHENTICATOR_H_ | 6 #define CHROMEOS_LOGIN_AUTH_AUTHENTICATOR_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "chromeos/chromeos_export.h" |
12 #include "chromeos/login/auth/auth_status_consumer.h" | 13 #include "chromeos/login/auth/auth_status_consumer.h" |
13 #include "google_apis/gaia/gaia_auth_consumer.h" | 14 #include "google_apis/gaia/gaia_auth_consumer.h" |
14 | 15 |
15 class Profile; | 16 class Profile; |
16 | 17 |
17 namespace chromeos { | 18 namespace chromeos { |
18 | 19 |
19 class UserContext; | 20 class UserContext; |
20 | 21 |
21 // An interface for objects that will authenticate a Chromium OS user. | 22 // An interface for objects that will authenticate a Chromium OS user. |
22 // Callbacks will be called on the UI thread: | 23 // Callbacks will be called on the UI thread: |
23 // 1. On successful authentication, will call consumer_->OnAuthSuccess(). | 24 // 1. On successful authentication, will call consumer_->OnAuthSuccess(). |
24 // 2. On failure, will call consumer_->OnAuthFailure(). | 25 // 2. On failure, will call consumer_->OnAuthFailure(). |
25 // 3. On password change, will call consumer_->OnPasswordChangeDetected(). | 26 // 3. On password change, will call consumer_->OnPasswordChangeDetected(). |
26 class Authenticator : public base::RefCountedThreadSafe<Authenticator> { | 27 class CHROMEOS_EXPORT Authenticator |
| 28 : public base::RefCountedThreadSafe<Authenticator> { |
27 public: | 29 public: |
28 explicit Authenticator(AuthStatusConsumer* consumer); | 30 explicit Authenticator(AuthStatusConsumer* consumer); |
29 | 31 |
30 // Given externally authenticated username and password (part of | 32 // Given externally authenticated username and password (part of |
31 // |user_context|), this method attempts to complete authentication process. | 33 // |user_context|), this method attempts to complete authentication process. |
32 virtual void CompleteLogin(Profile* profile, | 34 virtual void CompleteLogin(Profile* profile, |
33 const UserContext& user_context) = 0; | 35 const UserContext& user_context) = 0; |
34 | 36 |
35 // Given a user credentials in |user_context|, | 37 // Given a user credentials in |user_context|, |
36 // this method attempts to authenticate to login. | 38 // this method attempts to authenticate to login. |
37 // Must be called on the UI thread. | 39 // Must be called on the UI thread. |
38 virtual void AuthenticateToLogin(Profile* profile, | 40 virtual void AuthenticateToLogin(Profile* profile, |
39 const UserContext& user_context) = 0; | 41 const UserContext& user_context) = 0; |
40 | 42 |
41 // Given a user credentials in |user_context|, this method attempts to | 43 // Given a user credentials in |user_context|, this method attempts to |
42 // authenticate to unlock the computer. | 44 // authenticate to unlock the computer. |
43 // Must be called on the UI thread. | 45 // Must be called on the UI thread. |
44 virtual void AuthenticateToUnlock(const UserContext& user_context) = 0; | 46 virtual void AuthenticateToUnlock(const UserContext& user_context) = 0; |
45 | 47 |
46 // Initiates supervised user login. | 48 // Initiates supervised user login. |
47 virtual void LoginAsSupervisedUser( | 49 virtual void LoginAsSupervisedUser(const UserContext& user_context) = 0; |
48 const UserContext& user_context) = 0; | |
49 | 50 |
50 // Initiates retail mode login. | 51 // Initiates retail mode login. |
51 virtual void LoginRetailMode() = 0; | 52 virtual void LoginRetailMode() = 0; |
52 | 53 |
53 // Initiates incognito ("browse without signing in") login. | 54 // Initiates incognito ("browse without signing in") login. |
54 virtual void LoginOffTheRecord() = 0; | 55 virtual void LoginOffTheRecord() = 0; |
55 | 56 |
56 // Initiates login into the public account identified by |username|. | 57 // Initiates login into the public account identified by |username|. |
57 virtual void LoginAsPublicAccount(const std::string& username) = 0; | 58 virtual void LoginAsPublicAccount(const std::string& username) = 0; |
58 | 59 |
(...skipping 13 matching lines...) Expand all Loading... |
72 // Must be called on the UI thread. | 73 // Must be called on the UI thread. |
73 virtual void OnAuthFailure(const AuthFailure& error) = 0; | 74 virtual void OnAuthFailure(const AuthFailure& error) = 0; |
74 | 75 |
75 // Call these methods on the UI thread. | 76 // Call these methods on the UI thread. |
76 // If a password logs the user in online, but cannot be used to | 77 // If a password logs the user in online, but cannot be used to |
77 // mount his cryptohome, we expect that a password change has | 78 // mount his cryptohome, we expect that a password change has |
78 // occurred. | 79 // occurred. |
79 // Call this method to migrate the user's encrypted data | 80 // Call this method to migrate the user's encrypted data |
80 // forward to use his new password. |old_password| is the password | 81 // forward to use his new password. |old_password| is the password |
81 // his data was last encrypted with. | 82 // his data was last encrypted with. |
82 virtual void RecoverEncryptedData( | 83 virtual void RecoverEncryptedData(const std::string& old_password) = 0; |
83 const std::string& old_password) = 0; | |
84 | 84 |
85 // Call this method to erase the user's encrypted data | 85 // Call this method to erase the user's encrypted data |
86 // and create a new cryptohome. | 86 // and create a new cryptohome. |
87 virtual void ResyncEncryptedData() = 0; | 87 virtual void ResyncEncryptedData() = 0; |
88 | 88 |
89 // Profile (usually off the record ) that was used to perform the last | 89 // Profile (usually off the record ) that was used to perform the last |
90 // authentication process. | 90 // authentication process. |
91 Profile* authentication_profile() { return authentication_profile_; } | 91 Profile* authentication_profile() { return authentication_profile_; } |
92 | 92 |
93 // Sets consumer explicitly. | 93 // Sets consumer explicitly. |
94 void SetConsumer(AuthStatusConsumer* consumer); | 94 void SetConsumer(AuthStatusConsumer* consumer); |
95 | 95 |
96 protected: | 96 protected: |
97 virtual ~Authenticator(); | 97 virtual ~Authenticator(); |
98 | 98 |
99 AuthStatusConsumer* consumer_; | 99 AuthStatusConsumer* consumer_; |
100 Profile* authentication_profile_; | 100 Profile* authentication_profile_; |
101 | 101 |
102 private: | 102 private: |
103 friend class base::RefCountedThreadSafe<Authenticator>; | 103 friend class base::RefCountedThreadSafe<Authenticator>; |
104 | 104 |
105 DISALLOW_COPY_AND_ASSIGN(Authenticator); | 105 DISALLOW_COPY_AND_ASSIGN(Authenticator); |
106 }; | 106 }; |
107 | 107 |
108 } // namespace chromeos | 108 } // namespace chromeos |
109 | 109 |
110 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_AUTHENTICATOR_H_ | 110 #endif // CHROMEOS_LOGIN_AUTH_AUTHENTICATOR_H_ |
OLD | NEW |