bluetooth_chooser.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 "content/public/browser/bluetooth_chooser.h"
  10. #include "shell/browser/api/electron_api_web_contents.h"
  11. namespace electron {
  12. class BluetoothChooser : public content::BluetoothChooser {
  13. public:
  14. struct DeviceInfo {
  15. std::string device_id;
  16. std::u16string device_name;
  17. };
  18. explicit BluetoothChooser(api::WebContents* contents,
  19. const EventHandler& handler);
  20. ~BluetoothChooser() override;
  21. // disable copy
  22. BluetoothChooser(const BluetoothChooser&) = delete;
  23. BluetoothChooser& operator=(const BluetoothChooser&) = delete;
  24. // content::BluetoothChooser:
  25. void SetAdapterPresence(AdapterPresence presence) override;
  26. void ShowDiscoveryState(DiscoveryState state) override;
  27. void AddOrUpdateDevice(const std::string& device_id,
  28. bool should_update_name,
  29. const std::u16string& device_name,
  30. bool is_gatt_connected,
  31. bool is_paired,
  32. int signal_strength_level) override;
  33. std::vector<DeviceInfo> GetDeviceList();
  34. private:
  35. std::map<std::string, std::u16string> device_map_;
  36. api::WebContents* api_web_contents_;
  37. EventHandler event_handler_;
  38. bool refreshing_ = false;
  39. bool rescan_ = false;
  40. };
  41. } // namespace electron
  42. #endif // ELECTRON_SHELL_BROWSER_LIB_BLUETOOTH_CHOOSER_H_