Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: chromeos/dbus/biod_biometrics_manager_client.h

Issue 2567813002: cros: DBUS client to interact with fingerprint DBUS API. (Closed)
Patch Set: Fixed patch set 4 errors. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 #ifndef CHROMEOS_DBUS_BIOD_BIOMETRICS_MANAGER_CLIENT_H_
6 #define CHROMEOS_DBUS_BIOD_BIOMETRICS_MANAGER_CLIENT_H_
7
8 #include <stdint.h>
9
10 #include <unordered_map>
11 #include <vector>
12
13 #include "base/callback.h"
14 #include "base/macros.h"
15 #include "base/observer_list.h"
16 #include "chromeos/chromeos_export.h"
17 #include "chromeos/dbus/dbus_client.h"
18 #include "chromeos/dbus/dbus_client_implementation_type.h"
19 #include "chromeos/dbus/dbus_method_call_status.h"
20 #include "third_party/cros_system_api/dbus/service_constants.h"
21
22 namespace chromeos {
23
24 // Each time the sensor detects a scan, an object containing all the users, each
25 // with the labels of all the matched stored fingerprints is returned.
26 using AuthScanMatches =
27 std::unordered_map<std::string, std::vector<std::string>>;
28
29 // BiodBiometricsManagerClient is used to communicate with the biod dbus
30 // interface.
31 class CHROMEOS_EXPORT BiodBiometricsManagerClient : public DBusClient {
32 public:
33 // Interface for observing changes from the biometrics.
34 class Observer {
35 public:
36 // Called when biometrics manager powers up or is restarted.
37 virtual void ClientRestarted() {}
38
39 // Called whenever a user attempts a scan. |scan_result| tells whether the
40 // scan was succesful. |is_complete| tells whether enrollment is complete
41 // and now over.
42 virtual void EnrollScanDoneReceived(uint32_t scan_result,
stevenjb 2017/03/21 18:46:16 EnrollScanCompleteReceived ?
sammiequon 2017/03/21 20:50:19 These signals are based of the dbus signal names f
43 bool is_complete) {}
44
45 // Called to indicate a bad scan of any kind, or a succesful scan. If scan
46 // is successful, |matches| will equal all the enrollment IDs that match the
47 // scan, and the labels of the matched fingeprints.
48 virtual void AuthScanDoneReceived(uint32_t scan_result,
stevenjb 2017/03/21 18:46:16 Complete?
sammiequon 2017/03/21 20:50:18 See above.
49 const AuthScanMatches& matches) {}
50
51 // Called during either mode to indicate a failure. Any enrollment that was
52 // underway is thrown away and authentication will no longer be happening.
53 virtual void ScanFailedReceived() {}
54
55 protected:
56 virtual ~Observer() {}
57 };
58
59 ~BiodBiometricsManagerClient() override;
60
61 // Adds and removes the observer.
62 virtual void AddObserver(Observer* observer) = 0;
63 virtual void RemoveObserver(Observer* observer) = 0;
stevenjb 2017/03/21 18:46:16 nit: blank line here
sammiequon 2017/03/21 20:50:19 Done.
64 // Returns true if this object has the given observer.
65 virtual bool HasObserver(const Observer* observer) const = 0;
66
67 // ObjectPathArrayCallback is used for the GetRecordsForUser method. It
68 // receives one argument which contains a list of the stored records object
69 // paths for a given user.
stevenjb 2017/03/21 18:46:17 We should either name this type more specifically
sammiequon 2017/03/21 20:50:18 Done.
70 using ObjectPathArrayCallback =
71 base::Callback<void(const std::vector<dbus::ObjectPath>&)>;
72
73 // BiometricTypeCallback is used for the GetType method. It receives
74 // one argument which states the type of biometric.
75 using BiometricTypeCallback = base::Callback<void(biod::BiometricType)>;
76
77 // Starts the biometric enroll session.
stevenjb 2017/03/21 18:46:17 Describe what is passed to |callback|.
sammiequon 2017/03/21 20:50:19 Done.
78 virtual void StartEnrollSession(const std::string& user_id,
79 const std::string& label,
80 const ObjectPathCallback& callback) = 0;
81
82 // Gets all the records registered with this biometric.
stevenjb 2017/03/21 18:46:16 See above
sammiequon 2017/03/21 20:50:19 Done.
83 virtual void GetRecordsForUser(const std::string& user_id,
84 const ObjectPathArrayCallback& callback) = 0;
85
86 // Irreversibly destroys all records registered with this biometric.
87 virtual void DestroyAllRecords() = 0;
88
89 // Starts the biometric authentication session.
stevenjb 2017/03/21 18:46:16 What gets passed to |calback|?
sammiequon 2017/03/21 20:50:19 Done.
90 virtual void StartAuthSession(const ObjectPathCallback& callback) = 0;
91
92 // Gets the type of biometric.
stevenjb 2017/03/21 18:46:16 nit: s/gets/requests/
sammiequon 2017/03/21 20:50:19 Done.
93 virtual void GetType(const BiometricTypeCallback& callback) = 0;
94
95 // Same as above but is synchronous.
96 virtual biod::BiometricType GetTypeBlocking() = 0;
stevenjb 2017/03/21 18:46:16 We should avoid using blocking dbus calls like thi
sammiequon 2017/03/21 20:50:18 Done.
97
98 // Creates the instance.
99 static BiodBiometricsManagerClient* Create(DBusClientImplementationType type);
100
101 protected:
102 friend class BiodBiometricsManagerClientTest;
103
104 // Create() should be used instead.
105 BiodBiometricsManagerClient();
106
107 private:
108 DISALLOW_COPY_AND_ASSIGN(BiodBiometricsManagerClient);
109 };
110
111 } // namespace chromeos
112
113 #endif // CHROMEOS_DBUS_BIOD_BIOMETRICS_MANAGER_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698