| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/dbus/fake_cryptohome_client.h" | 5 #include "chromeos/dbus/fake_cryptohome_client.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/command_line.h" |
| 11 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 12 #include "base/location.h" | 13 #include "base/location.h" |
| 13 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 14 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
| 15 #include "base/threading/thread_restrictions.h" | 16 #include "base/threading/thread_restrictions.h" |
| 16 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
| 17 #include "chromeos/attestation/attestation.pb.h" | 18 #include "chromeos/attestation/attestation.pb.h" |
| 18 #include "chromeos/chromeos_paths.h" | 19 #include "chromeos/chromeos_paths.h" |
| 20 #include "chromeos/chromeos_switches.h" |
| 19 #include "chromeos/dbus/cryptohome/key.pb.h" | 21 #include "chromeos/dbus/cryptohome/key.pb.h" |
| 20 #include "chromeos/dbus/cryptohome/rpc.pb.h" | 22 #include "chromeos/dbus/cryptohome/rpc.pb.h" |
| 21 #include "third_party/cros_system_api/dbus/service_constants.h" | 23 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 22 #include "third_party/protobuf/src/google/protobuf/io/coded_stream.h" | 24 #include "third_party/protobuf/src/google/protobuf/io/coded_stream.h" |
| 23 #include "third_party/protobuf/src/google/protobuf/io/zero_copy_stream.h" | 25 #include "third_party/protobuf/src/google/protobuf/io/zero_copy_stream.h" |
| 24 #include "third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite
.h" | 26 #include "third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite
.h" |
| 25 | 27 |
| 26 namespace chromeos { | 28 namespace chromeos { |
| 27 | 29 |
| 28 namespace { | 30 namespace { |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 | 518 |
| 517 void FakeCryptohomeClient::MountEx( | 519 void FakeCryptohomeClient::MountEx( |
| 518 const cryptohome::Identification& cryptohome_id, | 520 const cryptohome::Identification& cryptohome_id, |
| 519 const cryptohome::AuthorizationRequest& auth, | 521 const cryptohome::AuthorizationRequest& auth, |
| 520 const cryptohome::MountRequest& request, | 522 const cryptohome::MountRequest& request, |
| 521 const ProtobufMethodCallback& callback) { | 523 const ProtobufMethodCallback& callback) { |
| 522 cryptohome::BaseReply reply; | 524 cryptohome::BaseReply reply; |
| 523 cryptohome::MountReply* mount = | 525 cryptohome::MountReply* mount = |
| 524 reply.MutableExtension(cryptohome::MountReply::reply); | 526 reply.MutableExtension(cryptohome::MountReply::reply); |
| 525 mount->set_sanitized_username(GetStubSanitizedUsername(cryptohome_id)); | 527 mount->set_sanitized_username(GetStubSanitizedUsername(cryptohome_id)); |
| 528 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 529 switches::kTestEncryptionMigrationUI)) { |
| 530 reply.set_error(cryptohome::CRYPTOHOME_ERROR_MOUNT_OLD_ENCRYPTION); |
| 531 } |
| 526 ReturnProtobufMethodCallback(reply, callback); | 532 ReturnProtobufMethodCallback(reply, callback); |
| 527 } | 533 } |
| 528 | 534 |
| 529 void FakeCryptohomeClient::AddKeyEx( | 535 void FakeCryptohomeClient::AddKeyEx( |
| 530 const cryptohome::Identification& cryptohome_id, | 536 const cryptohome::Identification& cryptohome_id, |
| 531 const cryptohome::AuthorizationRequest& auth, | 537 const cryptohome::AuthorizationRequest& auth, |
| 532 const cryptohome::AddKeyRequest& request, | 538 const cryptohome::AddKeyRequest& request, |
| 533 const ProtobufMethodCallback& callback) { | 539 const ProtobufMethodCallback& callback) { |
| 534 cryptohome::BaseReply reply; | 540 cryptohome::BaseReply reply; |
| 535 ReturnProtobufMethodCallback(reply, callback); | 541 ReturnProtobufMethodCallback(reply, callback); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 callback.Run(async_call_id_); | 649 callback.Run(async_call_id_); |
| 644 if (!async_call_status_data_handler_.is_null()) { | 650 if (!async_call_status_data_handler_.is_null()) { |
| 645 base::ThreadTaskRunnerHandle::Get()->PostTask( | 651 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 646 FROM_HERE, base::Bind(async_call_status_data_handler_, async_call_id_, | 652 FROM_HERE, base::Bind(async_call_status_data_handler_, async_call_id_, |
| 647 true, data)); | 653 true, data)); |
| 648 } | 654 } |
| 649 ++async_call_id_; | 655 ++async_call_id_; |
| 650 } | 656 } |
| 651 | 657 |
| 652 } // namespace chromeos | 658 } // namespace chromeos |
| OLD | NEW |