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::AddFingerprintObserver( | |
48 mojom::FingerprintObserverPtr observer) { | |
49 observer.set_connection_error_handler( | |
50 base::Bind(&FingerprintImplChromeOS::OnFingerprintObserverDisconnected, | |
51 base::Unretained(this), observer.get())); | |
52 observers_.push_back(std::move(observer)); | |
53 } | |
54 | |
55 void FingerprintImplChromeOS::BiodBiometricClientRestarted() { | |
56 current_enroll_path_.reset(); | |
57 current_auth_path_.reset(); | |
58 for (auto& observer : observers_) | |
59 observer->OnRestarted(); | |
60 } | |
61 | |
62 void FingerprintImplChromeOS::BiometricsScanEventReceived(uint32_t scan_result, | |
63 bool is_complete) { | |
64 if (is_complete) | |
65 current_enroll_path_.reset(); | |
66 | |
67 for (auto& observer : observers_) | |
68 observer->OnScanned(scan_result, is_complete); | |
69 } | |
70 | |
71 void FingerprintImplChromeOS::BiometricsAttemptEventReceived( | |
72 uint32_t scan_result, | |
73 const std::vector<std::string>& recognized_user_ids) { | |
74 for (auto& observer : observers_) | |
75 observer->OnAttempt(scan_result, recognized_user_ids); | |
76 } | |
77 | |
78 void FingerprintImplChromeOS::BiometricsFailureReceived() { | |
79 for (auto& observer : observers_) | |
80 observer->OnFailure(); | |
81 } | |
82 | |
83 void FingerprintImplChromeOS::OnFingerprintObserverDisconnected( | |
84 mojom::FingerprintObserver* observer) { | |
85 for (auto item = observers_.begin(); item != observers_.end(); ++item) { | |
86 if (item->get() == observer) { | |
87 observers_.erase(item); | |
88 break; | |
89 } | |
90 } | |
91 } | |
92 | |
93 void FingerprintImplChromeOS::OnStartEnroll( | |
94 const dbus::ObjectPath& enroll_path) { | |
95 DCHECK(!current_enroll_path_); | |
96 current_enroll_path_ = base::MakeUnique<dbus::ObjectPath>(enroll_path); | |
97 } | |
98 | |
99 void FingerprintImplChromeOS::OnStartAuthentication( | |
100 const dbus::ObjectPath& auth_path) { | |
101 DCHECK(!current_auth_path_); | |
102 current_auth_path_ = base::MakeUnique<dbus::ObjectPath>(auth_path); | |
103 } | |
104 | |
105 void FingerprintImplChromeOS::OnGetFingerprintsList( | |
106 const GetFingerprintsListCallback& callback, | |
107 const std::vector<dbus::ObjectPath>& enrollment_paths) {} | |
108 | |
109 void FingerprintImplChromeOS::OnGetLabel( | |
110 int32_t index, | |
111 const GetLabelCallback& callback, | |
112 const std::vector<dbus::ObjectPath>& enrollment_paths) { | |
113 DCHECK(index >= 0 && index < int{enrollment_paths.size()}); | |
114 } | |
115 | |
116 void FingerprintImplChromeOS::OnSetLabel( | |
117 const std::string& new_label, | |
118 int index, | |
119 const std::vector<dbus::ObjectPath>& enrollment_paths) { | |
120 DCHECK(index >= 0 && index < int{enrollment_paths.size()}); | |
121 } | |
122 | |
123 void FingerprintImplChromeOS::OnRemoveEnrollment( | |
124 int index, | |
125 const std::vector<dbus::ObjectPath>& enrollment_paths) { | |
126 DCHECK(index >= 0 && index < int{enrollment_paths.size()}); | |
127 } | |
128 | |
129 // static | |
130 void Fingerprint::Create(device::mojom::FingerprintRequest request) { | |
131 mojo::MakeStrongBinding(base::MakeUnique<FingerprintImplChromeOS>(), | |
132 std::move(request)); | |
133 } | |
134 | |
135 } // namespace device | |
OLD | NEW |