1 // Copyright 2015 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_CHOOSER_DESKTOP_H_
6 #define COMPONENTS_PERMISSIONS_BLUETOOTH_CHOOSER_DESKTOP_H_
8 #include "base/functional/callback_helpers.h"
9 #include "base/memory/weak_ptr.h"
10 #include "content/public/browser/bluetooth_chooser.h"
12 namespace permissions {
14 class BluetoothChooserController;
15 class ChooserController;
17 // Represents a Bluetooth chooser to ask the user to select a Bluetooth
18 // device from a list of options. This implementation is for desktop.
19 // BluetoothChooserAndroid implements the mobile part.
20 class BluetoothChooserDesktop : public content::BluetoothChooser {
22 // The OnceClosure returned by |show_dialog_callback| can be invoked to close
23 // the dialog. It should be a no-op to invoke the closure if the dialog has
24 // already been closed by the user.
25 BluetoothChooserDesktop(
26 std::unique_ptr<permissions::BluetoothChooserController> controller,
28 base::OnceClosure(std::unique_ptr<permissions::ChooserController>)>
29 show_dialog_callback);
31 BluetoothChooserDesktop(const BluetoothChooserDesktop&) = delete;
32 BluetoothChooserDesktop& operator=(const BluetoothChooserDesktop&) = delete;
34 ~BluetoothChooserDesktop() override;
37 void SetAdapterPresence(AdapterPresence presence) override;
38 void ShowDiscoveryState(DiscoveryState state) override;
39 void AddOrUpdateDevice(const std::string& device_id,
40 bool should_update_name,
41 const std::u16string& device_name,
42 bool is_gatt_connected,
44 int signal_strength_level) override;
47 // DeviceChooserContentView owns the controller.
48 base::WeakPtr<BluetoothChooserController> bluetooth_chooser_controller_;
50 // Closes the displayed UI if it is still open. Used to ensure the bubble
51 // closes if this controller is torn down.
52 base::ScopedClosureRunner close_closure_runner_;
55 } // namespace permissions
57 #endif // COMPONENTS_PERMISSIONS_BLUETOOTH_CHOOSER_DESKTOP_H_