OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_MOCK_AUTHENTICATOR_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_AUTHENTICATOR_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_AUTHENTICATOR_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_AUTHENTICATOR_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "chrome/browser/chromeos/login/authenticator.h" | 10 #include "chrome/browser/chromeos/login/authenticator.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 const std::string& expected_password) | 24 const std::string& expected_password) |
25 : Authenticator(consumer), | 25 : Authenticator(consumer), |
26 expected_username_(expected_username), | 26 expected_username_(expected_username), |
27 expected_password_(expected_password) { | 27 expected_password_(expected_password) { |
28 } | 28 } |
29 | 29 |
30 // Returns true after posting task to UI thread to call OnLoginSuccess(). | 30 // Returns true after posting task to UI thread to call OnLoginSuccess(). |
31 // This is called on the FILE thread now, so we need to do this. | 31 // This is called on the FILE thread now, so we need to do this. |
32 virtual bool AuthenticateToLogin(Profile* profile, | 32 virtual bool AuthenticateToLogin(Profile* profile, |
33 const std::string& username, | 33 const std::string& username, |
34 const std::string& password) { | 34 const std::string& password, |
| 35 const std::string& login_token, |
| 36 const std::string& login_captcha) { |
35 if (expected_username_ == username && | 37 if (expected_username_ == username && |
36 expected_password_ == password) { | 38 expected_password_ == password) { |
37 ChromeThread::PostTask( | 39 ChromeThread::PostTask( |
38 ChromeThread::UI, FROM_HERE, | 40 ChromeThread::UI, FROM_HERE, |
39 NewRunnableMethod(this, | 41 NewRunnableMethod(this, |
40 &MockAuthenticator::OnLoginSuccess, | 42 &MockAuthenticator::OnLoginSuccess, |
41 username)); | 43 username)); |
42 return true; | 44 return true; |
43 } else { | 45 } else { |
44 ChromeThread::PostTask( | 46 ChromeThread::PostTask( |
45 ChromeThread::UI, FROM_HERE, | 47 ChromeThread::UI, FROM_HERE, |
46 NewRunnableMethod(this, | 48 NewRunnableMethod(this, |
47 &MockAuthenticator::OnLoginFailure, | 49 &MockAuthenticator::OnLoginFailure, |
48 std::string("Login failed"))); | 50 std::string("Login failed"))); |
49 return false; | 51 return false; |
50 } | 52 } |
51 } | 53 } |
52 | 54 |
53 virtual bool AuthenticateToUnlock(const std::string& username, | 55 virtual bool AuthenticateToUnlock(const std::string& username, |
54 const std::string& password) { | 56 const std::string& password) { |
55 return AuthenticateToLogin(NULL /* not used */, username, password); | 57 return AuthenticateToLogin(NULL /* not used */, username, password, |
| 58 std::string(), std::string()); |
56 } | 59 } |
57 | 60 |
58 virtual void LoginOffTheRecord() { | 61 virtual void LoginOffTheRecord() { |
59 consumer_->OnOffTheRecordLoginSuccess(); | 62 consumer_->OnOffTheRecordLoginSuccess(); |
60 } | 63 } |
61 | 64 |
62 void OnLoginSuccess(const std::string& username) { | 65 void OnLoginSuccess(const std::string& username) { |
63 consumer_->OnLoginSuccess(username, std::string()); | 66 consumer_->OnLoginSuccess(username, std::string()); |
64 } | 67 } |
65 | 68 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 std::string expected_username_; | 120 std::string expected_username_; |
118 std::string expected_password_; | 121 std::string expected_password_; |
119 std::string auth_token_; | 122 std::string auth_token_; |
120 | 123 |
121 DISALLOW_COPY_AND_ASSIGN(MockLoginUtils); | 124 DISALLOW_COPY_AND_ASSIGN(MockLoginUtils); |
122 }; | 125 }; |
123 | 126 |
124 } // namespace chromeos | 127 } // namespace chromeos |
125 | 128 |
126 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_AUTHENTICATOR_H_ | 129 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_AUTHENTICATOR_H_ |
OLD | NEW |