forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fido_ble_pairing_delegate.h
58 lines (45 loc) · 2.08 KB
/
fido_ble_pairing_delegate.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef DEVICE_FIDO_BLE_FIDO_BLE_PAIRING_DELEGATE_H_
#define DEVICE_FIDO_BLE_FIDO_BLE_PAIRING_DELEGATE_H_
#include <stdint.h>
#include <string>
#include "base/component_export.h"
#include "base/containers/flat_map.h"
#include "base/macros.h"
#include "device/bluetooth/bluetooth_device.h"
namespace device {
// Handles incoming Bluetooth pairing events. Namely,
// a) Caching BLE Pin code when user inputs the pin code.
// b) Handling logic of BluetoothDevice::RequestPinCode() and
// BluetoothDevice::RequestPasskey().
// All other events are either silenced or BluetoothDevice::CancelPairing() is
// invoked.
class COMPONENT_EXPORT(DEVICE_FIDO) FidoBlePairingDelegate
: public BluetoothDevice::PairingDelegate {
public:
FidoBlePairingDelegate();
~FidoBlePairingDelegate() override;
// BluetoothDevice::PairingDelegate:
void RequestPinCode(BluetoothDevice* device) override;
void RequestPasskey(BluetoothDevice* device) override;
void DisplayPinCode(BluetoothDevice* device,
const std::string& pincode) override;
void DisplayPasskey(BluetoothDevice* device, uint32_t passkey) override;
void KeysEntered(BluetoothDevice* device, uint32_t entered) override;
void ConfirmPasskey(BluetoothDevice* device, uint32_t passkey) override;
void AuthorizePairing(BluetoothDevice* device) override;
void StoreBlePinCodeForDevice(std::string device_address,
std::string pin_code);
void ChangeStoredDeviceAddress(const std::string& old_address,
std::string new_address);
void CancelPairingOnAllKnownDevices(BluetoothAdapter* adapter);
private:
friend class FidoBlePairingDelegateTest;
friend class FidoBleAdapterManagerTest;
base::flat_map<std::string, std::string> bluetooth_device_pincode_map_;
DISALLOW_COPY_AND_ASSIGN(FidoBlePairingDelegate);
};
} // namespace device
#endif // DEVICE_FIDO_BLE_FIDO_BLE_PAIRING_DELEGATE_H_