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 "chromeos/login/auth/fake_extended_authenticator.h" | 5 #include "chromeos/login/auth/fake_extended_authenticator.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chromeos/login/auth/auth_status_consumer.h" | 8 #include "chromeos/login/auth/auth_status_consumer.h" |
9 #include "components/signin/core/account_id/account_id.h" | |
10 | 9 |
11 namespace chromeos { | 10 namespace chromeos { |
12 | 11 |
13 FakeExtendedAuthenticator::FakeExtendedAuthenticator( | 12 FakeExtendedAuthenticator::FakeExtendedAuthenticator( |
14 NewAuthStatusConsumer* consumer, | 13 NewAuthStatusConsumer* consumer, |
15 const UserContext& expected_user_context) | 14 const UserContext& expected_user_context) |
16 : consumer_(consumer), | 15 : consumer_(consumer), |
17 old_consumer_(NULL), | 16 old_consumer_(NULL), |
18 expected_user_context_(expected_user_context) { | 17 expected_user_context_(expected_user_context) { |
19 } | 18 } |
(...skipping 11 matching lines...) Expand all Loading... |
31 | 30 |
32 void FakeExtendedAuthenticator::SetConsumer(AuthStatusConsumer* consumer) { | 31 void FakeExtendedAuthenticator::SetConsumer(AuthStatusConsumer* consumer) { |
33 old_consumer_ = consumer; | 32 old_consumer_ = consumer; |
34 } | 33 } |
35 | 34 |
36 void FakeExtendedAuthenticator::AuthenticateToMount( | 35 void FakeExtendedAuthenticator::AuthenticateToMount( |
37 const UserContext& context, | 36 const UserContext& context, |
38 const ResultCallback& success_callback) { | 37 const ResultCallback& success_callback) { |
39 if (expected_user_context_ == context) { | 38 if (expected_user_context_ == context) { |
40 UserContext reported_user_context(context); | 39 UserContext reported_user_context(context); |
41 const std::string mount_hash = | 40 const std::string mount_hash = reported_user_context.GetUserID() + "-hash"; |
42 reported_user_context.GetAccountId().GetUserEmail() + "-hash"; | |
43 reported_user_context.SetUserIDHash(mount_hash); | 41 reported_user_context.SetUserIDHash(mount_hash); |
44 if (!success_callback.is_null()) | 42 if (!success_callback.is_null()) |
45 success_callback.Run(mount_hash); | 43 success_callback.Run(mount_hash); |
46 OnAuthSuccess(reported_user_context); | 44 OnAuthSuccess(reported_user_context); |
47 return; | 45 return; |
48 } | 46 } |
49 | 47 |
50 OnAuthFailure(FAILED_MOUNT, | 48 OnAuthFailure(FAILED_MOUNT, |
51 AuthFailure(AuthFailure::COULD_NOT_MOUNT_CRYPTOHOME)); | 49 AuthFailure(AuthFailure::COULD_NOT_MOUNT_CRYPTOHOME)); |
52 } | 50 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 104 |
107 void FakeExtendedAuthenticator::OnAuthFailure(AuthState state, | 105 void FakeExtendedAuthenticator::OnAuthFailure(AuthState state, |
108 const AuthFailure& error) { | 106 const AuthFailure& error) { |
109 if (consumer_) | 107 if (consumer_) |
110 consumer_->OnAuthenticationFailure(state); | 108 consumer_->OnAuthenticationFailure(state); |
111 if (old_consumer_) | 109 if (old_consumer_) |
112 old_consumer_->OnAuthFailure(error); | 110 old_consumer_->OnAuthFailure(error); |
113 } | 111 } |
114 | 112 |
115 } // namespace chromeos | 113 } // namespace chromeos |
OLD | NEW |