#ifndef ASH_SYSTEM_BLUETOOTH_BLUETOOTH_NOTIFICATION_CONTROLLER_H_
#define ASH_SYSTEM_BLUETOOTH_BLUETOOTH_NOTIFICATION_CONTROLLER_H_
#include <stdint.h>
#include <set>
#include <string>
#include "ash/ash_export.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
#include "device/bluetooth/bluetooth_adapter.h"
#include "device/bluetooth/bluetooth_device.h"
namespace message_center {
class MessageCenter;
}
namespace ash {
class ASH_EXPORT BluetoothNotificationController
: public device::BluetoothAdapter::Observer,
public device::BluetoothDevice::PairingDelegate {
public:
explicit BluetoothNotificationController(
message_center::MessageCenter* message_center);
BluetoothNotificationController(const BluetoothNotificationController&) =
delete;
BluetoothNotificationController& operator=(
const BluetoothNotificationController&) = delete;
~BluetoothNotificationController() override;
void AdapterDiscoverableChanged(device::BluetoothAdapter* adapter,
bool discoverable) override;
void DeviceAdded(device::BluetoothAdapter* adapter,
device::BluetoothDevice* device) override;
void DeviceChanged(device::BluetoothAdapter* adapter,
device::BluetoothDevice* device) override;
void DeviceRemoved(device::BluetoothAdapter* adapter,
device::BluetoothDevice* device) override;
void RequestPinCode(device::BluetoothDevice* device) override;
void RequestPasskey(device::BluetoothDevice* device) override;
void DisplayPinCode(device::BluetoothDevice* device,
const std::string& pincode) override;
void DisplayPasskey(device::BluetoothDevice* device,
uint32_t passkey) override;
void KeysEntered(device::BluetoothDevice* device, uint32_t entered) override;
void ConfirmPasskey(device::BluetoothDevice* device,
uint32_t passkey) override;
void AuthorizePairing(device::BluetoothDevice* device) override;
private:
friend class BluetoothNotificationControllerTest;
static const char kBluetoothDeviceDiscoverableToastId[];
static const char kBluetoothDevicePairingNotificationId[];
void OnGetAdapter(scoped_refptr<device::BluetoothAdapter> adapter);
void NotifyAdapterDiscoverable();
void NotifyPairing(device::BluetoothDevice* device,
const std::u16string& message,
bool with_buttons);
void NotifyBondedDevice(device::BluetoothDevice* device);
const raw_ptr<message_center::MessageCenter, DanglingUntriaged>
message_center_;
scoped_refptr<device::BluetoothAdapter> adapter_;
std::set<std::string> bonded_devices_;
base::WeakPtrFactory<BluetoothNotificationController> weak_ptr_factory_{this};
};
}
#endif