bluetooth_chooser_desktop.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright 2015 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_PERMISSIONS_BLUETOOTH_CHOOSER_DESKTOP_H_
  5. #define COMPONENTS_PERMISSIONS_BLUETOOTH_CHOOSER_DESKTOP_H_
  6. #include "base/callback_helpers.h"
  7. #include "base/memory/weak_ptr.h"
  8. #include "content/public/browser/bluetooth_chooser.h"
  9. namespace permissions {
  10. class BluetoothChooserController;
  11. class ChooserController;
  12. // Represents a Bluetooth chooser to ask the user to select a Bluetooth
  13. // device from a list of options. This implementation is for desktop.
  14. // BluetoothChooserAndroid implements the mobile part.
  15. class BluetoothChooserDesktop : public content::BluetoothChooser {
  16. public:
  17. // The OnceClosure returned by |show_dialog_callback| can be invoked to close
  18. // the dialog. It should be a no-op to invoke the closure if the dialog has
  19. // already been closed by the user.
  20. BluetoothChooserDesktop(
  21. std::unique_ptr<permissions::BluetoothChooserController> controller,
  22. base::OnceCallback<
  23. base::OnceClosure(std::unique_ptr<permissions::ChooserController>)>
  24. show_dialog_callback);
  25. BluetoothChooserDesktop(const BluetoothChooserDesktop&) = delete;
  26. BluetoothChooserDesktop& operator=(const BluetoothChooserDesktop&) = delete;
  27. ~BluetoothChooserDesktop() override;
  28. // BluetoothChooser:
  29. void SetAdapterPresence(AdapterPresence presence) override;
  30. void ShowDiscoveryState(DiscoveryState state) override;
  31. void AddOrUpdateDevice(const std::string& device_id,
  32. bool should_update_name,
  33. const std::u16string& device_name,
  34. bool is_gatt_connected,
  35. bool is_paired,
  36. int signal_strength_level) override;
  37. private:
  38. // DeviceChooserContentView owns the controller.
  39. base::WeakPtr<BluetoothChooserController> bluetooth_chooser_controller_;
  40. // Closes the displayed UI if it is still open. Used to ensure the bubble
  41. // closes if this controller is torn down.
  42. base::ScopedClosureRunner close_closure_runner_;
  43. };
  44. } // namespace permissions
  45. #endif // COMPONENTS_PERMISSIONS_BLUETOOTH_CHOOSER_DESKTOP_H_