OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "services/device/fingerprint/fingerprint_impl_chromeos.h" |
| 6 |
| 7 #include <string.h> |
| 8 |
| 9 #include "dbus/object_path.h" |
| 10 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 11 #include "services/device/fingerprint/fingerprint.h" |
| 12 |
| 13 namespace device { |
| 14 |
| 15 FingerprintImplChromeOS::FingerprintImplChromeOS() : weak_ptr_factory_(this) {} |
| 16 |
| 17 FingerprintImplChromeOS::~FingerprintImplChromeOS() {} |
| 18 |
| 19 void FingerprintImplChromeOS::GetFingerprintsList( |
| 20 const GetFingerprintsListCallback& callback) {} |
| 21 |
| 22 void FingerprintImplChromeOS::StartEnroll(const std::string& user_id, |
| 23 const std::string& label) {} |
| 24 |
| 25 void FingerprintImplChromeOS::CancelCurrentEnroll() { |
| 26 // Call Dbus to canel current enroll and reset the current_enroll_path. |
| 27 current_enroll_path_.reset(); |
| 28 } |
| 29 |
| 30 void FingerprintImplChromeOS::GetLabel(int32_t index, |
| 31 const GetLabelCallback& callback) {} |
| 32 |
| 33 void FingerprintImplChromeOS::SetLabel(const std::string& label, |
| 34 int32_t index) {} |
| 35 |
| 36 void FingerprintImplChromeOS::RemoveEnrollment(int32_t index) {} |
| 37 |
| 38 void FingerprintImplChromeOS::StartAuthentication() {} |
| 39 |
| 40 void FingerprintImplChromeOS::EndCurrentAuthentication() { |
| 41 // Call Dbus to canel current authentication and reset the current_auth_path. |
| 42 current_auth_path_.reset(); |
| 43 } |
| 44 |
| 45 void FingerprintImplChromeOS::DestroyAllEnrollments() {} |
| 46 |
| 47 void FingerprintImplChromeOS::AddBiodObserver(mojom::BiodObserverPtr observer) { |
| 48 observer.set_connection_error_handler( |
| 49 base::Bind(&FingerprintImplChromeOS::OnBiodObserverDisconnected, |
| 50 base::Unretained(this), observer.get())); |
| 51 observers_.push_back(std::move(observer)); |
| 52 } |
| 53 |
| 54 void FingerprintImplChromeOS::BiodBiometricClientRestarted() { |
| 55 current_enroll_path_.reset(); |
| 56 current_auth_path_.reset(); |
| 57 for (auto& observer : observers_) |
| 58 observer->OnRestarted(); |
| 59 } |
| 60 |
| 61 void FingerprintImplChromeOS::BiometricsScanEventReceived(uint32_t scan_result, |
| 62 bool is_complete) { |
| 63 if (is_complete) |
| 64 current_enroll_path_.reset(); |
| 65 |
| 66 for (auto& observer : observers_) |
| 67 observer->OnScanned(scan_result, is_complete); |
| 68 } |
| 69 |
| 70 void FingerprintImplChromeOS::BiometricsAttemptEventReceived( |
| 71 uint32_t scan_result, |
| 72 const std::vector<std::string>& recognized_user_ids) { |
| 73 for (auto& observer : observers_) |
| 74 observer->OnAttempt(scan_result, recognized_user_ids); |
| 75 } |
| 76 |
| 77 void FingerprintImplChromeOS::BiometricsFailureReceived() { |
| 78 for (auto& observer : observers_) |
| 79 observer->OnFailure(); |
| 80 } |
| 81 |
| 82 void FingerprintImplChromeOS::OnBiodObserverDisconnected( |
| 83 mojom::BiodObserver* observer) { |
| 84 for (auto item = observers_.begin(); item != observers_.end(); ++item) { |
| 85 if (item->get() == observer) { |
| 86 observers_.erase(item); |
| 87 break; |
| 88 } |
| 89 } |
| 90 } |
| 91 |
| 92 void FingerprintImplChromeOS::OnStartEnroll( |
| 93 const dbus::ObjectPath& enroll_path) { |
| 94 DCHECK(!current_enroll_path_); |
| 95 current_enroll_path_ = base::MakeUnique<dbus::ObjectPath>(enroll_path); |
| 96 } |
| 97 |
| 98 void FingerprintImplChromeOS::OnStartAuthentication( |
| 99 const dbus::ObjectPath& auth_path) { |
| 100 DCHECK(!current_auth_path_); |
| 101 current_auth_path_ = base::MakeUnique<dbus::ObjectPath>(auth_path); |
| 102 } |
| 103 |
| 104 void FingerprintImplChromeOS::OnGetFingerprintsList( |
| 105 const GetFingerprintsListCallback& callback, |
| 106 const std::vector<dbus::ObjectPath>& enrollment_paths) {} |
| 107 |
| 108 void FingerprintImplChromeOS::OnGetLabel( |
| 109 int32_t index, |
| 110 const GetLabelCallback& callback, |
| 111 const std::vector<dbus::ObjectPath>& enrollment_paths) { |
| 112 DCHECK(index >= 0 && index < int{enrollment_paths.size()}); |
| 113 } |
| 114 |
| 115 void FingerprintImplChromeOS::OnSetLabel( |
| 116 const std::string& new_label, |
| 117 int index, |
| 118 const std::vector<dbus::ObjectPath>& enrollment_paths) { |
| 119 DCHECK(index >= 0 && index < int{enrollment_paths.size()}); |
| 120 } |
| 121 |
| 122 void FingerprintImplChromeOS::OnRemoveEnrollment( |
| 123 int index, |
| 124 const std::vector<dbus::ObjectPath>& enrollment_paths) { |
| 125 DCHECK(index >= 0 && index < int{enrollment_paths.size()}); |
| 126 } |
| 127 |
| 128 // static |
| 129 void Fingerprint::Create(device::mojom::FingerprintRequest request) { |
| 130 mojo::MakeStrongBinding(base::MakeUnique<FingerprintImplChromeOS>(), |
| 131 std::move(request)); |
| 132 } |
| 133 |
| 134 } // namespace device |
OLD | NEW |