OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_PARALLEL_AUTHENTICATOR_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_PARALLEL_AUTHENTICATOR_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_PARALLEL_AUTHENTICATOR_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_PARALLEL_AUTHENTICATOR_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 UNLOCK, // Screen unlock succeeded. | 77 UNLOCK, // Screen unlock succeeded. |
78 LOCAL_LOGIN, // Login with localaccount succeded. | 78 LOCAL_LOGIN, // Login with localaccount succeded. |
79 ONLINE_FAILED, // Online login disallowed, but offline succeeded. | 79 ONLINE_FAILED, // Online login disallowed, but offline succeeded. |
80 LOGIN_FAILED // Login denied. | 80 LOGIN_FAILED // Login denied. |
81 }; | 81 }; |
82 | 82 |
83 explicit ParallelAuthenticator(LoginStatusConsumer* consumer); | 83 explicit ParallelAuthenticator(LoginStatusConsumer* consumer); |
84 virtual ~ParallelAuthenticator(); | 84 virtual ~ParallelAuthenticator(); |
85 | 85 |
86 // Authenticator overrides. | 86 // Authenticator overrides. |
87 virtual bool CompleteLogin(Profile* profile, | 87 virtual void CompleteLogin(Profile* profile, |
88 const std::string& username, | 88 const std::string& username, |
89 const std::string& password) OVERRIDE; | 89 const std::string& password) OVERRIDE; |
90 | 90 |
91 // Given a |username| and |password|, this method attempts to authenticate to | 91 // Given a |username| and |password|, this method attempts to authenticate to |
92 // the Google accounts servers and your Chrome OS device simultaneously. | 92 // the Google accounts servers and your Chrome OS device simultaneously. |
93 // As soon as we have successfully mounted the encrypted home directory for | 93 // As soon as we have successfully mounted the encrypted home directory for |
94 // |username|, we will call consumer_->OnLoginSuccess() with |username| and a | 94 // |username|, we will call consumer_->OnLoginSuccess() with |username| and a |
95 // vector of authentication cookies. If we're still waiting for an online | 95 // vector of authentication cookies. If we're still waiting for an online |
96 // result at that time, we'll also pass back a flag indicating that more | 96 // result at that time, we'll also pass back a flag indicating that more |
97 // callbacks are on the way; if not, we pass back false. When the pending | 97 // callbacks are on the way; if not, we pass back false. When the pending |
98 // request completes, either consumer_->OnLoginSuccess() with an indication | 98 // request completes, either consumer_->OnLoginSuccess() with an indication |
99 // that no more requests are outstanding will be called, or | 99 // that no more requests are outstanding will be called, or |
100 // consumer_->OnLoginFailure() if appropriate. | 100 // consumer_->OnLoginFailure() if appropriate. |
101 // | 101 // |
102 // Upon failure to login (online fails, then offline fails; | 102 // Upon failure to login (online fails, then offline fails; |
103 // offline fails, then online fails) consumer_->OnLoginFailure() is called | 103 // offline fails, then online fails) consumer_->OnLoginFailure() is called |
104 // with an error message. | 104 // with an error message. |
105 // | 105 // |
106 // In the event that we see an online success and then an offline failure, | 106 // In the event that we see an online success and then an offline failure, |
107 // consumer_->OnPasswordChangeDetected() is called. | 107 // consumer_->OnPasswordChangeDetected() is called. |
108 // | 108 // |
109 // Uses |profile| when doing URL fetches. | 109 // Uses |profile| when doing URL fetches. |
110 // Optionally could pass CAPTCHA challenge token - |login_token| and | 110 // Optionally could pass CAPTCHA challenge token - |login_token| and |
111 // |login_captcha| string that user has entered. | 111 // |login_captcha| string that user has entered. |
112 // | 112 // |
113 // NOTE: We do not allow HOSTED accounts to log in. In the event that | 113 // NOTE: We do not allow HOSTED accounts to log in. In the event that |
114 // we are asked to authenticate valid HOSTED account creds, we will | 114 // we are asked to authenticate valid HOSTED account creds, we will |
115 // call OnLoginFailure() with HOSTED_NOT_ALLOWED. | 115 // call OnLoginFailure() with HOSTED_NOT_ALLOWED. |
116 // | 116 virtual void AuthenticateToLogin(Profile* profile, |
117 // Returns true if the attempt gets sent successfully and false if not. | |
118 virtual bool AuthenticateToLogin(Profile* profile, | |
119 const std::string& username, | 117 const std::string& username, |
120 const std::string& password, | 118 const std::string& password, |
121 const std::string& login_token, | 119 const std::string& login_token, |
122 const std::string& login_captcha) OVERRIDE; | 120 const std::string& login_captcha) OVERRIDE; |
123 | 121 |
124 // Given a |username| and |password|, this method attempts to | 122 // Given a |username| and |password|, this method attempts to |
125 // authenticate to the cached credentials. This will never contact | 123 // authenticate to the cached credentials. This will never contact |
126 // the server even if it's online. The auth result is sent to | 124 // the server even if it's online. The auth result is sent to |
127 // LoginStatusConsumer in a same way as AuthenticateToLogin does. | 125 // LoginStatusConsumer in a same way as AuthenticateToLogin does. |
128 virtual bool AuthenticateToUnlock(const std::string& username, | 126 virtual void AuthenticateToUnlock(const std::string& username, |
129 const std::string& password) OVERRIDE; | 127 const std::string& password) OVERRIDE; |
130 | 128 |
131 // Initiates incognito ("browse without signing in") login. | 129 // Initiates incognito ("browse without signing in") login. |
132 // Mounts tmpfs and notifies consumer on the success/failure. | 130 // Mounts tmpfs and notifies consumer on the success/failure. |
133 virtual void LoginOffTheRecord() OVERRIDE; | 131 virtual void LoginOffTheRecord() OVERRIDE; |
134 | 132 |
135 // These methods must be called on the UI thread, as they make DBus calls | 133 // These methods must be called on the UI thread, as they make DBus calls |
136 // and also call back to the login UI. | 134 // and also call back to the login UI. |
137 virtual void OnLoginSuccess( | 135 virtual void OnLoginSuccess( |
138 const GaiaAuthConsumer::ClientLoginResult& credentials, | 136 const GaiaAuthConsumer::ClientLoginResult& credentials, |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 FRIEND_TEST_ALL_PREFIXES(ParallelAuthenticatorTest, ReadLocalaccount); | 305 FRIEND_TEST_ALL_PREFIXES(ParallelAuthenticatorTest, ReadLocalaccount); |
308 FRIEND_TEST_ALL_PREFIXES(ParallelAuthenticatorTest, | 306 FRIEND_TEST_ALL_PREFIXES(ParallelAuthenticatorTest, |
309 ReadLocalaccountTrailingWS); | 307 ReadLocalaccountTrailingWS); |
310 FRIEND_TEST_ALL_PREFIXES(ParallelAuthenticatorTest, ReadNoLocalaccount); | 308 FRIEND_TEST_ALL_PREFIXES(ParallelAuthenticatorTest, ReadNoLocalaccount); |
311 DISALLOW_COPY_AND_ASSIGN(ParallelAuthenticator); | 309 DISALLOW_COPY_AND_ASSIGN(ParallelAuthenticator); |
312 }; | 310 }; |
313 | 311 |
314 } // namespace chromeos | 312 } // namespace chromeos |
315 | 313 |
316 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_PARALLEL_AUTHENTICATOR_H_ | 314 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_PARALLEL_AUTHENTICATOR_H_ |
OLD | NEW |