#ifndef CHROMECAST_BROWSER_BLUETOOTH_CAST_BLUETOOTH_CHOOSER_H_
#define CHROMECAST_BROWSER_BLUETOOTH_CAST_BLUETOOTH_CHOOSER_H_
#include <string>
#include <unordered_set>
#include "chromecast/browser/bluetooth/public/mojom/web_bluetooth.mojom.h"
#include "content/public/browser/bluetooth_chooser.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
namespace chromecast {
class CastBluetoothChooser : public content::BluetoothChooser,
public mojom::BluetoothDeviceAccessProviderClient {
public:
CastBluetoothChooser(content::BluetoothChooser::EventHandler event_handler,
mojo::PendingRemote<mojom::BluetoothDeviceAccessProvider>
pending_provider);
CastBluetoothChooser(const CastBluetoothChooser&) = delete;
CastBluetoothChooser& operator=(const CastBluetoothChooser&) = delete;
~CastBluetoothChooser() override;
private:
void GrantAccess(const std::string& address) override;
void GrantAccessToAllDevices() override;
void AddOrUpdateDevice(const std::string& device_id,
bool should_update_name,
const std::u16string& device_name,
bool is_gatt_connected,
bool is_paired,
int signal_strength_level) override;
void RunEventHandlerAndResetReceiver(content::BluetoothChooserEvent event,
std::string address);
void OnClientConnectionError();
content::BluetoothChooser::EventHandler event_handler_;
mojo::Receiver<mojom::BluetoothDeviceAccessProviderClient> receiver_{this};
std::unordered_set<std::string> available_devices_;
std::unordered_set<std::string> approved_devices_;
bool all_devices_approved_ = false;
};
}
#endif