| 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/mock_authenticator.h" | 5 #include "chromeos/login/auth/mock_authenticator.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 | 10 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 void MockAuthenticator::AuthenticateToUnlock(const UserContext& user_context) { | 43 void MockAuthenticator::AuthenticateToUnlock(const UserContext& user_context) { |
| 44 AuthenticateToLogin(NULL /* not used */, user_context); | 44 AuthenticateToLogin(NULL /* not used */, user_context); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void MockAuthenticator::LoginAsSupervisedUser(const UserContext& user_context) { | 47 void MockAuthenticator::LoginAsSupervisedUser(const UserContext& user_context) { |
| 48 UserContext new_user_context = user_context; | 48 UserContext new_user_context = user_context; |
| 49 new_user_context.SetUserIDHash(user_context.GetUserID()); | 49 new_user_context.SetUserIDHash(user_context.GetUserID()); |
| 50 consumer_->OnAuthSuccess(new_user_context); | 50 consumer_->OnAuthSuccess(new_user_context); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void MockAuthenticator::LoginRetailMode() { | |
| 54 UserContext user_context("demo-mode"); | |
| 55 user_context.SetUserIDHash("demo-mode"); | |
| 56 consumer_->OnRetailModeAuthSuccess(user_context); | |
| 57 } | |
| 58 | |
| 59 void MockAuthenticator::LoginOffTheRecord() { | 53 void MockAuthenticator::LoginOffTheRecord() { |
| 60 consumer_->OnOffTheRecordAuthSuccess(); | 54 consumer_->OnOffTheRecordAuthSuccess(); |
| 61 } | 55 } |
| 62 | 56 |
| 63 void MockAuthenticator::LoginAsPublicSession(const UserContext& user_context) { | 57 void MockAuthenticator::LoginAsPublicSession(const UserContext& user_context) { |
| 64 UserContext logged_in_user_context = user_context; | 58 UserContext logged_in_user_context = user_context; |
| 65 logged_in_user_context.SetUserIDHash(logged_in_user_context.GetUserID()); | 59 logged_in_user_context.SetUserIDHash(logged_in_user_context.GetUserID()); |
| 66 consumer_->OnAuthSuccess(logged_in_user_context); | 60 consumer_->OnAuthSuccess(logged_in_user_context); |
| 67 } | 61 } |
| 68 | 62 |
| 69 void MockAuthenticator::LoginAsKioskAccount(const std::string& app_user_id, | 63 void MockAuthenticator::LoginAsKioskAccount(const std::string& app_user_id, |
| 70 bool use_guest_mount) { | 64 bool use_guest_mount) { |
| 71 UserContext user_context(expected_user_context_.GetUserID()); | 65 UserContext user_context(expected_user_context_.GetUserID()); |
| 72 user_context.SetUserIDHash(expected_user_context_.GetUserID()); | 66 user_context.SetUserIDHash(expected_user_context_.GetUserID()); |
| 73 consumer_->OnAuthSuccess(user_context); | 67 consumer_->OnAuthSuccess(user_context); |
| 74 } | 68 } |
| 75 | 69 |
| 76 void MockAuthenticator::OnRetailModeAuthSuccess() { | |
| 77 UserContext user_context(expected_user_context_.GetUserID()); | |
| 78 user_context.SetUserIDHash(expected_user_context_.GetUserID()); | |
| 79 consumer_->OnRetailModeAuthSuccess(user_context); | |
| 80 } | |
| 81 | |
| 82 void MockAuthenticator::OnAuthSuccess() { | 70 void MockAuthenticator::OnAuthSuccess() { |
| 83 // If we want to be more like the real thing, we could save the user ID | 71 // If we want to be more like the real thing, we could save the user ID |
| 84 // in AuthenticateToLogin, but there's not much of a point. | 72 // in AuthenticateToLogin, but there's not much of a point. |
| 85 UserContext user_context(expected_user_context_); | 73 UserContext user_context(expected_user_context_); |
| 86 user_context.SetUserIDHash(expected_user_context_.GetUserID()); | 74 user_context.SetUserIDHash(expected_user_context_.GetUserID()); |
| 87 consumer_->OnAuthSuccess(user_context); | 75 consumer_->OnAuthSuccess(user_context); |
| 88 } | 76 } |
| 89 | 77 |
| 90 void MockAuthenticator::OnAuthFailure(const AuthFailure& failure) { | 78 void MockAuthenticator::OnAuthFailure(const AuthFailure& failure) { |
| 91 consumer_->OnAuthFailure(failure); | 79 consumer_->OnAuthFailure(failure); |
| 92 } | 80 } |
| 93 | 81 |
| 94 void MockAuthenticator::RecoverEncryptedData(const std::string& old_password) { | 82 void MockAuthenticator::RecoverEncryptedData(const std::string& old_password) { |
| 95 } | 83 } |
| 96 | 84 |
| 97 void MockAuthenticator::ResyncEncryptedData() { | 85 void MockAuthenticator::ResyncEncryptedData() { |
| 98 } | 86 } |
| 99 | 87 |
| 100 void MockAuthenticator::SetExpectedCredentials( | 88 void MockAuthenticator::SetExpectedCredentials( |
| 101 const UserContext& user_context) { | 89 const UserContext& user_context) { |
| 102 expected_user_context_ = user_context; | 90 expected_user_context_ = user_context; |
| 103 } | 91 } |
| 104 | 92 |
| 105 MockAuthenticator::~MockAuthenticator() { | 93 MockAuthenticator::~MockAuthenticator() { |
| 106 } | 94 } |
| 107 | 95 |
| 108 } // namespace chromeos | 96 } // namespace chromeos |
| OLD | NEW |