bluetooth_chooser.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 SHELL_BROWSER_LIB_BLUETOOTH_CHOOSER_H_
  5. #define 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. base::string16 device_name;
  17. };
  18. explicit BluetoothChooser(api::WebContents* contents,
  19. const EventHandler& handler);
  20. ~BluetoothChooser() override;
  21. // content::BluetoothChooser:
  22. void SetAdapterPresence(AdapterPresence presence) override;
  23. void ShowDiscoveryState(DiscoveryState state) override;
  24. void AddOrUpdateDevice(const std::string& device_id,
  25. bool should_update_name,
  26. const base::string16& device_name,
  27. bool is_gatt_connected,
  28. bool is_paired,
  29. int signal_strength_level) override;
  30. std::vector<DeviceInfo> GetDeviceList();
  31. private:
  32. std::map<std::string, base::string16> device_map_;
  33. api::WebContents* api_web_contents_;
  34. EventHandler event_handler_;
  35. int num_retries_ = 0;
  36. DISALLOW_COPY_AND_ASSIGN(BluetoothChooser);
  37. };
  38. } // namespace electron
  39. #endif // SHELL_BROWSER_LIB_BLUETOOTH_CHOOSER_H_