bluetooth_scanning_prompt_desktop.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright 2019 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_SCANNING_PROMPT_DESKTOP_H_
  5. #define COMPONENTS_PERMISSIONS_BLUETOOTH_SCANNING_PROMPT_DESKTOP_H_
  6. #include <string>
  7. #include "base/callback_helpers.h"
  8. #include "base/memory/weak_ptr.h"
  9. #include "content/public/browser/bluetooth_scanning_prompt.h"
  10. namespace content {
  11. class RenderFrameHost;
  12. } // namespace content
  13. namespace permissions {
  14. class BluetoothScanningPromptController;
  15. class ChooserController;
  16. // Represents a Bluetooth scanning prompt to ask the user permission to
  17. // allow a site to receive Bluetooth advertisement packets from Bluetooth
  18. // devices. This implementation is for desktop.
  19. class BluetoothScanningPromptDesktop : public content::BluetoothScanningPrompt {
  20. public:
  21. // The OnceClosure returned by |show_dialog_callback| can be invoked to close
  22. // the dialog. It should be a no-op to invoke the closure if the dialog has
  23. // already been closed by the user.
  24. BluetoothScanningPromptDesktop(
  25. content::RenderFrameHost* frame,
  26. const content::BluetoothScanningPrompt::EventHandler& event_handler,
  27. std::u16string title,
  28. base::OnceCallback<
  29. base::OnceClosure(std::unique_ptr<permissions::ChooserController>)>
  30. show_dialog_callback);
  31. BluetoothScanningPromptDesktop(const BluetoothScanningPromptDesktop&) =
  32. delete;
  33. BluetoothScanningPromptDesktop& operator=(
  34. const BluetoothScanningPromptDesktop&) = delete;
  35. ~BluetoothScanningPromptDesktop() override;
  36. // content::BluetoothScanningPrompt:
  37. void AddOrUpdateDevice(const std::string& device_id,
  38. bool should_update_name,
  39. const std::u16string& device_name) override;
  40. private:
  41. // DeviceChooserContentView owns the controller.
  42. base::WeakPtr<BluetoothScanningPromptController>
  43. bluetooth_scanning_prompt_controller_;
  44. // Closes the displayed UI, if there is one. This is used to ensure the UI
  45. // closes if this controller is destroyed.
  46. base::ScopedClosureRunner close_closure_runner_;
  47. };
  48. } // namespace permissions
  49. #endif // COMPONENTS_PERMISSIONS_BLUETOOTH_SCANNING_PROMPT_DESKTOP_H_