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