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 #include "chrome/browser/chromeos/login/auth/mock_authenticator.h" | 5 #include "chrome/browser/chromeos/login/auth/mock_authenticator.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "chrome/browser/chromeos/login/users/user.h" | 8 #include "chrome/browser/chromeos/login/users/user.h" |
9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 OnLoginSuccess(); | 34 OnLoginSuccess(); |
35 } | 35 } |
36 | 36 |
37 void MockAuthenticator::AuthenticateToUnlock( | 37 void MockAuthenticator::AuthenticateToUnlock( |
38 const UserContext& user_context) { | 38 const UserContext& user_context) { |
39 AuthenticateToLogin(NULL /* not used */, user_context); | 39 AuthenticateToLogin(NULL /* not used */, user_context); |
40 } | 40 } |
41 | 41 |
42 void MockAuthenticator::LoginAsLocallyManagedUser( | 42 void MockAuthenticator::LoginAsLocallyManagedUser( |
43 const UserContext& user_context) { | 43 const UserContext& user_context) { |
44 consumer_->OnLoginSuccess(UserContext(expected_username_, | 44 UserContext new_user_context = user_context; |
45 std::string(), | 45 new_user_context.SetUserIDHash(user_context.GetUserID()); |
46 std::string(), | 46 consumer_->OnLoginSuccess(new_user_context); |
47 user_context.GetUserID())); // hash | |
48 } | 47 } |
49 | 48 |
50 void MockAuthenticator::LoginRetailMode() { | 49 void MockAuthenticator::LoginRetailMode() { |
51 consumer_->OnRetailModeLoginSuccess(UserContext("demo-mode", | 50 UserContext user_context("demo-mode"); |
52 std::string(), | 51 user_context.SetUserIDHash("demo-mode"); |
53 std::string(), | 52 consumer_->OnRetailModeLoginSuccess(user_context); |
54 "demo-mode")); | |
55 } | 53 } |
56 | 54 |
57 void MockAuthenticator::LoginAsPublicAccount(const std::string& username) { | 55 void MockAuthenticator::LoginAsPublicAccount(const std::string& username) { |
58 consumer_->OnLoginSuccess(UserContext(expected_username_, | 56 UserContext user_context(expected_username_); |
59 std::string(), | 57 user_context.SetUserIDHash(expected_username_); |
60 std::string(), | 58 consumer_->OnLoginSuccess(user_context); |
61 expected_username_)); | |
62 } | 59 } |
63 | 60 |
64 void MockAuthenticator::LoginAsKioskAccount(const std::string& app_user_id, | 61 void MockAuthenticator::LoginAsKioskAccount(const std::string& app_user_id, |
65 bool use_guest_mount) { | 62 bool use_guest_mount) { |
66 consumer_->OnLoginSuccess(UserContext(expected_username_, | 63 UserContext user_context(expected_username_); |
67 std::string(), | 64 user_context.SetUserIDHash(expected_username_); |
68 std::string(), | 65 consumer_->OnLoginSuccess(user_context); |
69 expected_username_)); | |
70 } | 66 } |
71 | 67 |
72 void MockAuthenticator::LoginOffTheRecord() { | 68 void MockAuthenticator::LoginOffTheRecord() { |
73 consumer_->OnOffTheRecordLoginSuccess(); | 69 consumer_->OnOffTheRecordLoginSuccess(); |
74 } | 70 } |
75 | 71 |
76 void MockAuthenticator::OnRetailModeLoginSuccess() { | 72 void MockAuthenticator::OnRetailModeLoginSuccess() { |
77 consumer_->OnRetailModeLoginSuccess(UserContext(expected_username_, | 73 UserContext user_context(expected_username_); |
78 std::string(), | 74 user_context.SetUserIDHash(expected_username_); |
79 std::string(), | 75 consumer_->OnRetailModeLoginSuccess(user_context); |
80 expected_username_)); | |
81 } | 76 } |
82 | 77 |
83 void MockAuthenticator::OnLoginSuccess() { | 78 void MockAuthenticator::OnLoginSuccess() { |
84 // If we want to be more like the real thing, we could save username | 79 // If we want to be more like the real thing, we could save username |
85 // in AuthenticateToLogin, but there's not much of a point. | 80 // in AuthenticateToLogin, but there's not much of a point. |
86 consumer_->OnLoginSuccess(UserContext(expected_username_, | 81 UserContext user_context(expected_username_); |
87 expected_password_, | 82 user_context.SetPassword(expected_password_); |
88 std::string(), | 83 user_context.SetUserIDHash(expected_username_); |
89 expected_username_)); | 84 consumer_->OnLoginSuccess(user_context); |
90 } | 85 } |
91 | 86 |
92 void MockAuthenticator::OnLoginFailure(const LoginFailure& failure) { | 87 void MockAuthenticator::OnLoginFailure(const LoginFailure& failure) { |
93 consumer_->OnLoginFailure(failure); | 88 consumer_->OnLoginFailure(failure); |
94 } | 89 } |
95 | 90 |
96 void MockAuthenticator::SetExpectedCredentials( | 91 void MockAuthenticator::SetExpectedCredentials( |
97 const std::string& expected_username, | 92 const std::string& expected_username, |
98 const std::string& expected_password) { | 93 const std::string& expected_password) { |
99 expected_username_ = expected_username; | 94 expected_username_ = expected_username; |
100 expected_password_ = expected_password; | 95 expected_password_ = expected_password; |
101 } | 96 } |
102 | 97 |
103 } // namespace chromeos | 98 } // namespace chromeos |
OLD | NEW |