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

Side by Side Diff: chromeos/dbus/biod/biod_client.h

Issue 2567813002: cros: DBUS client to interact with fingerprint DBUS API. (Closed)
Patch Set: Fixed patch set 14 errors. Created 3 years, 8 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
« no previous file with comments | « chromeos/BUILD.gn ('k') | chromeos/dbus/biod/biod_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_BIOD_CLIENT_H_
6 #define CHROMEOS_DBUS_BIOD_BIOD_CLIENT_H_
7
8 #include <string>
9 #include <unordered_map>
10 #include <vector>
11
12 #include "base/callback.h"
13 #include "base/macros.h"
14 #include "base/observer_list.h"
15 #include "chromeos/chromeos_export.h"
16 #include "chromeos/dbus/dbus_client.h"
17 #include "chromeos/dbus/dbus_client_implementation_type.h"
18 #include "chromeos/dbus/dbus_method_call_status.h"
19 #include "third_party/cros_system_api/dbus/service_constants.h"
20
21 namespace chromeos {
22
23 // Each time the sensor detects a scan, an object containing all the users, each
24 // with the labels of all the matched stored biometrics is returned. The users
25 // are unique identifiers which are assigned by Chrome. The labels represent the
26 // names the user gave their biometric.
27 using AuthScanMatches =
28 std::unordered_map<std::string, std::vector<std::string>>;
29
30 // BiodClient is used to communicate with a biod D-Bus manager
31 // interface.
32 class CHROMEOS_EXPORT BiodClient : public DBusClient {
33 public:
34 // Interface for observing changes from the biometrics manager.
35 class Observer {
36 public:
37 // Called when biometrics manager powers up or is restarted.
38 virtual void BiodServiceRestarted() {}
39
40 // Called whenever a user attempts a scan during enrollment. |scan_result|
41 // tells whether the scan was succesful. |enroll_session_complete| tells
42 // whether enroll session is complete and is now over.
43 virtual void BiodEnrollScanDoneReceived(biod::ScanResult scan_result,
44 bool enroll_session_complete) {}
45
46 // Called when an authentication scan is performed. If the scan is
47 // successful, |matches| will equal all the enrollment IDs that match the
48 // scan, and the labels of the matched fingeprints.
49 virtual void BiodAuthScanDoneReceived(biod::ScanResult scan_result,
50 const AuthScanMatches& matches) {}
51
52 // Called during an enrollment or authentication session to indicate a
53 // failure. Any enrollment that was underway is thrown away and auth will
54 // no longer be happening.
55 virtual void BiodSessionFailedReceived() {}
56
57 protected:
58 virtual ~Observer() {}
59 };
60
61 ~BiodClient() override;
62
63 // Adds and removes the observer.
64 virtual void AddObserver(Observer* observer) = 0;
65 virtual void RemoveObserver(Observer* observer) = 0;
66
67 // Returns true if this object has the given observer.
68 virtual bool HasObserver(const Observer* observer) const = 0;
69
70 // UserRecordsCallback is used for the GetRecordsForUser method. It receives
71 // one argument which contains a list of the stored records' object paths for
72 // a given user.
73 using UserRecordsCallback =
74 base::Callback<void(const std::vector<dbus::ObjectPath>&)>;
75
76 // BiometricTypeCallback is used for the GetType method. It receives
77 // one argument which states the type of biometric.
78 using BiometricTypeCallback = base::Callback<void(biod::BiometricType)>;
79
80 // Starts the biometric enroll session. |callback| is called with the object
81 // path of the current enroll session after the method succeeds. |user_id|
82 // contains the unique identifier for the owner of the biometric. |label| is
83 // the the human readable label the user gave the biometric.
84 virtual void StartEnrollSession(const std::string& user_id,
85 const std::string& label,
86 const ObjectPathCallback& callback) = 0;
87
88 // Gets all the records registered with this biometric. |callback| is called
89 // with all the object paths of the records with |user_id| after this method
90 // succeeds. |user_id| contains the unique identifier for the owner of the
91 // biometric.
92 virtual void GetRecordsForUser(const std::string& user_id,
93 const UserRecordsCallback& callback) = 0;
94
95 // Irreversibly destroys all records registered.
96 virtual void DestroyAllRecords() = 0;
97
98 // Starts the biometric auth session. |callback| is called with the object
99 // path of the auth session after the method succeeds.
100 virtual void StartAuthSession(const ObjectPathCallback& callback) = 0;
101
102 // Requests the type of biometric. |callback| is called with the biometric
103 // type after the method succeeds.
104 virtual void RequestType(const BiometricTypeCallback& callback) = 0;
105
106 // Creates the instance.
107 static BiodClient* Create(DBusClientImplementationType type);
108
109 protected:
110 friend class BiodClientTest;
111
112 // Create() should be used instead.
113 BiodClient();
114
115 private:
116 DISALLOW_COPY_AND_ASSIGN(BiodClient);
117 };
118
119 } // namespace chromeos
120
121 #endif // CHROMEOS_DBUS_BIOD_BIOD_CLIENT_H_
OLDNEW
« no previous file with comments | « chromeos/BUILD.gn ('k') | chromeos/dbus/biod/biod_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698