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
8 #include "base/callback_forward.h"
9 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "components/proximity_auth/cryptauth/proto/cryptauth_api.pb.h"
14 class URLRequestContextGetter
;
17 namespace proximity_auth
{
19 class CryptAuthAccessTokenFetcher
;
20 class CryptAuthApiCallFlow
;
22 // Interface for making API requests to the CryptAuth service, which
23 // manages cryptographic credentials (ie. public keys) for a user's devices.
24 // Implmentations shall only processes a single request, so create a new
25 // instance for each request you make. DO NOT REUSE.
26 // For documentation on each API call, see
27 // components/proximity_auth/cryptauth/proto/cryptauth_api.proto
28 class CryptAuthClient
{
30 typedef base::Callback
<void(const std::string
&)> ErrorCallback
;
32 virtual ~CryptAuthClient() {}
35 typedef base::Callback
<void(const cryptauth::GetMyDevicesResponse
&)>
37 virtual void GetMyDevices(const cryptauth::GetMyDevicesRequest
& request
,
38 const GetMyDevicesCallback
& callback
,
39 const ErrorCallback
& error_callback
) = 0;
41 // FindEligibleUnlockDevices
42 typedef base::Callback
<void(
43 const cryptauth::FindEligibleUnlockDevicesResponse
&)>
44 FindEligibleUnlockDevicesCallback
;
45 virtual void FindEligibleUnlockDevices(
46 const cryptauth::FindEligibleUnlockDevicesRequest
& request
,
47 const FindEligibleUnlockDevicesCallback
& callback
,
48 const ErrorCallback
& error_callback
) = 0;
50 // SendDeviceSyncTickle
51 typedef base::Callback
<void(const cryptauth::SendDeviceSyncTickleResponse
&)>
52 SendDeviceSyncTickleCallback
;
53 virtual void SendDeviceSyncTickle(
54 const cryptauth::SendDeviceSyncTickleRequest
& request
,
55 const SendDeviceSyncTickleCallback
& callback
,
56 const ErrorCallback
& error_callback
) = 0;
59 typedef base::Callback
<void(const cryptauth::ToggleEasyUnlockResponse
&)>
60 ToggleEasyUnlockCallback
;
61 virtual void ToggleEasyUnlock(
62 const cryptauth::ToggleEasyUnlockRequest
& request
,
63 const ToggleEasyUnlockCallback
& callback
,
64 const ErrorCallback
& error_callback
) = 0;
67 typedef base::Callback
<void(const cryptauth::SetupEnrollmentResponse
&)>
68 SetupEnrollmentCallback
;
69 virtual void SetupEnrollment(const cryptauth::SetupEnrollmentRequest
& request
,
70 const SetupEnrollmentCallback
& callback
,
71 const ErrorCallback
& error_callback
) = 0;
74 typedef base::Callback
<void(const cryptauth::FinishEnrollmentResponse
&)>
75 FinishEnrollmentCallback
;
76 virtual void FinishEnrollment(
77 const cryptauth::FinishEnrollmentRequest
& request
,
78 const FinishEnrollmentCallback
& callback
,
79 const ErrorCallback
& error_callback
) = 0;
82 // Interface for creating CryptAuthClient instances. Because each
83 // CryptAuthClient instance can only be used for one API call, a factory makes
84 // it easier to make multiple requests in sequence or in parallel.
85 class CryptAuthClientFactory
{
87 virtual ~CryptAuthClientFactory() {}
89 virtual scoped_ptr
<CryptAuthClient
> CreateInstance() = 0;
92 } // namespace proximity_auth
94 #endif // COMPONENTS_PROXIMITY_AUTH_CRYPTAUTH_CLIENT_H