bluetooth_chooser.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright (c) 2016 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef ELECTRON_SHELL_BROWSER_LIB_BLUETOOTH_CHOOSER_H_
  5. #define ELECTRON_SHELL_BROWSER_LIB_BLUETOOTH_CHOOSER_H_
  6. #include <map>
  7. #include <string>
  8. #include <vector>
  9. #include "base/memory/raw_ptr.h"
  10. #include "content/public/browser/bluetooth_chooser.h"
  11. #include "shell/browser/api/electron_api_web_contents.h"
  12. namespace electron {
  13. class BluetoothChooser : public content::BluetoothChooser {
  14. public:
  15. struct DeviceInfo {
  16. std::string device_id;
  17. std::u16string device_name;
  18. };
  19. explicit BluetoothChooser(api::WebContents* contents,
  20. const EventHandler& handler);
  21. ~BluetoothChooser() override;
  22. // disable copy
  23. BluetoothChooser(const BluetoothChooser&) = delete;
  24. BluetoothChooser& operator=(const BluetoothChooser&) = delete;
  25. // content::BluetoothChooser:
  26. void SetAdapterPresence(AdapterPresence presence) override;
  27. void ShowDiscoveryState(DiscoveryState state) override;
  28. void AddOrUpdateDevice(const std::string& device_id,
  29. bool should_update_name,
  30. const std::u16string& device_name,
  31. bool is_gatt_connected,
  32. bool is_paired,
  33. int signal_strength_level) override;
  34. std::vector<DeviceInfo> GetDeviceList();
  35. private:
  36. std::map<std::string, std::u16string> device_map_;
  37. raw_ptr<api::WebContents> api_web_contents_;
  38. EventHandler event_handler_;
  39. bool refreshing_ = false;
  40. bool rescan_ = false;
  41. };
  42. } // namespace electron
  43. #endif // ELECTRON_SHELL_BROWSER_LIB_BLUETOOTH_CHOOSER_H_