2016-05-30 12:38:09 +00: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.
|
|
|
|
|
2019-06-19 20:56:58 +00:00
|
|
|
#ifndef SHELL_BROWSER_LIB_BLUETOOTH_CHOOSER_H_
|
|
|
|
#define SHELL_BROWSER_LIB_BLUETOOTH_CHOOSER_H_
|
2016-05-30 12:38:09 +00:00
|
|
|
|
2018-11-28 16:36:00 +00:00
|
|
|
#include <map>
|
2016-05-30 12:38:09 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "content/public/browser/bluetooth_chooser.h"
|
2020-02-04 20:19:40 +00:00
|
|
|
#include "shell/browser/api/electron_api_web_contents.h"
|
2016-05-30 12:38:09 +00:00
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
namespace electron {
|
2016-05-30 12:38:09 +00:00
|
|
|
|
|
|
|
class BluetoothChooser : public content::BluetoothChooser {
|
|
|
|
public:
|
|
|
|
struct DeviceInfo {
|
|
|
|
std::string device_id;
|
|
|
|
base::string16 device_name;
|
|
|
|
};
|
|
|
|
|
|
|
|
explicit BluetoothChooser(api::WebContents* contents,
|
|
|
|
const EventHandler& handler);
|
|
|
|
~BluetoothChooser() override;
|
|
|
|
|
|
|
|
// content::BluetoothChooser:
|
|
|
|
void SetAdapterPresence(AdapterPresence presence) override;
|
|
|
|
void ShowDiscoveryState(DiscoveryState state) override;
|
2016-11-30 07:30:03 +00:00
|
|
|
void AddOrUpdateDevice(const std::string& device_id,
|
|
|
|
bool should_update_name,
|
|
|
|
const base::string16& device_name,
|
|
|
|
bool is_gatt_connected,
|
|
|
|
bool is_paired,
|
|
|
|
int signal_strength_level) override;
|
2018-11-28 16:36:00 +00:00
|
|
|
std::vector<DeviceInfo> GetDeviceList();
|
2016-05-30 12:38:09 +00:00
|
|
|
|
|
|
|
private:
|
2018-11-28 16:36:00 +00:00
|
|
|
std::map<std::string, base::string16> device_map_;
|
2016-05-30 12:38:09 +00:00
|
|
|
api::WebContents* api_web_contents_;
|
|
|
|
EventHandler event_handler_;
|
2018-05-21 22:18:38 +00:00
|
|
|
int num_retries_ = 0;
|
2021-02-26 19:10:27 +00:00
|
|
|
bool refreshing_ = false;
|
2016-05-30 12:38:09 +00:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(BluetoothChooser);
|
|
|
|
};
|
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
} // namespace electron
|
2016-05-30 12:38:09 +00:00
|
|
|
|
2019-06-19 20:56:58 +00:00
|
|
|
#endif // SHELL_BROWSER_LIB_BLUETOOTH_CHOOSER_H_
|