1 // Copyright 2014 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.
5 #ifndef COMPONENTS_PROXIMITY_AUTH_CRYPTAUTH_CLIENT_H
6 #define COMPONENTS_PROXIMITY_AUTH_CRYPTAUTH_CLIENT_H
10 #include "base/callback_forward.h"
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
15 class DeviceClassifier
;
16 class GetMyDevicesRequest
;
17 class GetMyDevicesResponse
;
18 class FindEligibleUnlockDevicesRequest
;
19 class FindEligibleUnlockDevicesResponse
;
20 class SendDeviceSyncTickleRequest
;
21 class SendDeviceSyncTickleResponse
;
22 class ToggleEasyUnlockRequest
;
23 class ToggleEasyUnlockResponse
;
24 class SetupEnrollmentRequest
;
25 class SetupEnrollmentResponse
;
26 class FinishEnrollmentRequest
;
27 class FinishEnrollmentResponse
;
31 class URLRequestContextGetter
;
34 namespace proximity_auth
{
36 class CryptAuthAccessTokenFetcher
;
37 class CryptAuthApiCallFlow
;
39 // Interface for making API requests to the CryptAuth service, which
40 // manages cryptographic credentials (ie. public keys) for a user's devices.
41 // Implmentations shall only processes a single request, so create a new
42 // instance for each request you make. DO NOT REUSE.
43 // For documentation on each API call, see
44 // components/proximity_auth/cryptauth/proto/cryptauth_api.proto
45 class CryptAuthClient
{
47 typedef base::Callback
<void(const std::string
&)> ErrorCallback
;
49 virtual ~CryptAuthClient() {}
52 typedef base::Callback
<void(const cryptauth::GetMyDevicesResponse
&)>
54 virtual void GetMyDevices(const cryptauth::GetMyDevicesRequest
& request
,
55 const GetMyDevicesCallback
& callback
,
56 const ErrorCallback
& error_callback
) = 0;
58 // FindEligibleUnlockDevices
59 typedef base::Callback
<void(
60 const cryptauth::FindEligibleUnlockDevicesResponse
&)>
61 FindEligibleUnlockDevicesCallback
;
62 virtual void FindEligibleUnlockDevices(
63 const cryptauth::FindEligibleUnlockDevicesRequest
& request
,
64 const FindEligibleUnlockDevicesCallback
& callback
,
65 const ErrorCallback
& error_callback
) = 0;
67 // SendDeviceSyncTickle
68 typedef base::Callback
<void(const cryptauth::SendDeviceSyncTickleResponse
&)>
69 SendDeviceSyncTickleCallback
;
70 virtual void SendDeviceSyncTickle(
71 const cryptauth::SendDeviceSyncTickleRequest
& request
,
72 const SendDeviceSyncTickleCallback
& callback
,
73 const ErrorCallback
& error_callback
) = 0;
76 typedef base::Callback
<void(const cryptauth::ToggleEasyUnlockResponse
&)>
77 ToggleEasyUnlockCallback
;
78 virtual void ToggleEasyUnlock(
79 const cryptauth::ToggleEasyUnlockRequest
& request
,
80 const ToggleEasyUnlockCallback
& callback
,
81 const ErrorCallback
& error_callback
) = 0;
84 typedef base::Callback
<void(const cryptauth::SetupEnrollmentResponse
&)>
85 SetupEnrollmentCallback
;
86 virtual void SetupEnrollment(const cryptauth::SetupEnrollmentRequest
& request
,
87 const SetupEnrollmentCallback
& callback
,
88 const ErrorCallback
& error_callback
) = 0;
91 typedef base::Callback
<void(const cryptauth::FinishEnrollmentResponse
&)>
92 FinishEnrollmentCallback
;
93 virtual void FinishEnrollment(
94 const cryptauth::FinishEnrollmentRequest
& request
,
95 const FinishEnrollmentCallback
& callback
,
96 const ErrorCallback
& error_callback
) = 0;
98 // Returns the access token used to make the request. If no request has been
99 // made yet, this function will return an empty string.
100 virtual std::string
GetAccessTokenUsed() = 0;
103 // Interface for creating CryptAuthClient instances. Because each
104 // CryptAuthClient instance can only be used for one API call, a factory makes
105 // it easier to make multiple requests in sequence or in parallel.
106 class CryptAuthClientFactory
{
108 virtual ~CryptAuthClientFactory() {}
110 virtual scoped_ptr
<CryptAuthClient
> CreateInstance() = 0;
113 } // namespace proximity_auth
115 #endif // COMPONENTS_PROXIMITY_AUTH_CRYPTAUTH_CLIENT_H