2016-05-30 06:38:09 -06:00
|
|
|
// Copyright (c) 2016 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2021-11-22 00:34:31 -07:00
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_LIB_BLUETOOTH_CHOOSER_H_
|
|
|
|
#define ELECTRON_SHELL_BROWSER_LIB_BLUETOOTH_CHOOSER_H_
|
2016-05-30 06:38:09 -06:00
|
|
|
|
2018-11-28 09:36:00 -07:00
|
|
|
#include <map>
|
2016-05-30 06:38:09 -06:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2023-05-11 14:07:39 -06:00
|
|
|
#include "base/memory/raw_ptr.h"
|
2016-05-30 06:38:09 -06:00
|
|
|
#include "content/public/browser/bluetooth_chooser.h"
|
2020-02-04 13:19:40 -07:00
|
|
|
#include "shell/browser/api/electron_api_web_contents.h"
|
2016-05-30 06:38:09 -06:00
|
|
|
|
2019-06-19 15:23:04 -06:00
|
|
|
namespace electron {
|
2016-05-30 06:38:09 -06:00
|
|
|
|
|
|
|
class BluetoothChooser : public content::BluetoothChooser {
|
|
|
|
public:
|
|
|
|
struct DeviceInfo {
|
|
|
|
std::string device_id;
|
2021-03-16 10:18:45 -06:00
|
|
|
std::u16string device_name;
|
2016-05-30 06:38:09 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
explicit BluetoothChooser(api::WebContents* contents,
|
|
|
|
const EventHandler& handler);
|
|
|
|
~BluetoothChooser() override;
|
|
|
|
|
2021-11-03 05:41:45 -06:00
|
|
|
// disable copy
|
|
|
|
BluetoothChooser(const BluetoothChooser&) = delete;
|
|
|
|
BluetoothChooser& operator=(const BluetoothChooser&) = delete;
|
|
|
|
|
2016-05-30 06:38:09 -06:00
|
|
|
// content::BluetoothChooser:
|
|
|
|
void SetAdapterPresence(AdapterPresence presence) override;
|
|
|
|
void ShowDiscoveryState(DiscoveryState state) override;
|
2016-11-30 00:30:03 -07:00
|
|
|
void AddOrUpdateDevice(const std::string& device_id,
|
|
|
|
bool should_update_name,
|
2021-03-16 10:18:45 -06:00
|
|
|
const std::u16string& device_name,
|
2016-11-30 00:30:03 -07:00
|
|
|
bool is_gatt_connected,
|
|
|
|
bool is_paired,
|
|
|
|
int signal_strength_level) override;
|
2018-11-28 09:36:00 -07:00
|
|
|
std::vector<DeviceInfo> GetDeviceList();
|
2016-05-30 06:38:09 -06:00
|
|
|
|
|
|
|
private:
|
2021-03-16 10:18:45 -06:00
|
|
|
std::map<std::string, std::u16string> device_map_;
|
2023-05-11 14:07:39 -06:00
|
|
|
raw_ptr<api::WebContents> api_web_contents_;
|
2016-05-30 06:38:09 -06:00
|
|
|
EventHandler event_handler_;
|
2021-02-26 12:10:27 -07:00
|
|
|
bool refreshing_ = false;
|
2021-06-09 08:48:18 -06:00
|
|
|
bool rescan_ = false;
|
2016-05-30 06:38:09 -06:00
|
|
|
};
|
|
|
|
|
2019-06-19 15:23:04 -06:00
|
|
|
} // namespace electron
|
2016-05-30 06:38:09 -06:00
|
|
|
|
2021-11-22 00:34:31 -07:00
|
|
|
#endif // ELECTRON_SHELL_BROWSER_LIB_BLUETOOTH_CHOOSER_H_
|