1 // Copyright 2019 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_PERMISSIONS_BLUETOOTH_SCANNING_PROMPT_DESKTOP_H_
6 #define COMPONENTS_PERMISSIONS_BLUETOOTH_SCANNING_PROMPT_DESKTOP_H_
10 #include "base/functional/callback_helpers.h"
11 #include "base/memory/weak_ptr.h"
12 #include "content/public/browser/bluetooth_scanning_prompt.h"
15 class RenderFrameHost;
16 } // namespace content
18 namespace permissions {
20 class BluetoothScanningPromptController;
21 class ChooserController;
23 // Represents a Bluetooth scanning prompt to ask the user permission to
24 // allow a site to receive Bluetooth advertisement packets from Bluetooth
25 // devices. This implementation is for desktop.
26 class BluetoothScanningPromptDesktop : public content::BluetoothScanningPrompt {
28 // The OnceClosure returned by |show_dialog_callback| can be invoked to close
29 // the dialog. It should be a no-op to invoke the closure if the dialog has
30 // already been closed by the user.
31 BluetoothScanningPromptDesktop(
32 content::RenderFrameHost* frame,
33 const content::BluetoothScanningPrompt::EventHandler& event_handler,
36 base::OnceClosure(std::unique_ptr<permissions::ChooserController>)>
37 show_dialog_callback);
39 BluetoothScanningPromptDesktop(const BluetoothScanningPromptDesktop&) =
41 BluetoothScanningPromptDesktop& operator=(
42 const BluetoothScanningPromptDesktop&) = delete;
44 ~BluetoothScanningPromptDesktop() override;
46 // content::BluetoothScanningPrompt:
47 void AddOrUpdateDevice(const std::string& device_id,
48 bool should_update_name,
49 const std::u16string& device_name) override;
52 // DeviceChooserContentView owns the controller.
53 base::WeakPtr<BluetoothScanningPromptController>
54 bluetooth_scanning_prompt_controller_;
56 // Closes the displayed UI, if there is one. This is used to ensure the UI
57 // closes if this controller is destroyed.
58 base::ScopedClosureRunner close_closure_runner_;
61 } // namespace permissions
63 #endif // COMPONENTS_PERMISSIONS_BLUETOOTH_SCANNING_PROMPT_DESKTOP_H_