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.
5 #ifndef CONTENT_PUBLIC_BROWSER_BLUETOOTH_CHOOSER_H_
6 #define CONTENT_PUBLIC_BROWSER_BLUETOOTH_CHOOSER_H_
10 #include "base/callback.h"
11 #include "base/strings/string16.h"
12 #include "content/common/content_export.h"
16 // Represents a way to ask the user to select a Bluetooth device from a list of
18 class CONTENT_EXPORT BluetoothChooser
{
21 // The user cancelled the chooser instead of selecting a device.
23 // The user selected device |opt_device_id|.
25 // The user asked for a new Bluetooth discovery session to start.
27 // Show overview page for Bluetooth.
29 // Show help page explaining what Bluetooth pairing means.
31 // Show help page explaining why scanning failed because Bluetooth is off.
32 SHOW_ADAPTER_OFF_HELP
,
34 // As the dialog implementations grow more user-visible buttons and knobs,
35 // we'll add enumerators here to support them.
38 // Chooser implementations are constructed with an |EventHandler| and report
39 // user interaction with the chooser through it. |opt_device_id| is an empty
40 // string except for Event::SELECTED.
42 // The EventHandler won't be called after the chooser object is destroyed.
44 // After the EventHandler is called with Event::CANCELLED or Event::SELECTED,
45 // it won't be called again, and users must not call any more BluetoothChooser
47 typedef base::Callback
<void(Event
, const std::string
& opt_device_id
)>
51 virtual ~BluetoothChooser();
53 // Lets the chooser tell the user the state of the Bluetooth adapter. This
54 // defaults to POWERED_ON.
55 enum class AdapterPresence
{ ABSENT
, POWERED_OFF
, POWERED_ON
};
56 virtual void SetAdapterPresence(AdapterPresence presence
) {}
58 // Lets the chooser tell the user whether discovery is happening. This
59 // defaults to DISCOVERING.
60 enum class DiscoveryState
{ FAILED_TO_START
, DISCOVERING
, IDLE
};
61 virtual void ShowDiscoveryState(DiscoveryState state
) {}
63 // Shows a new device in the chooser.
64 virtual void AddDevice(const std::string
& device_id
,
65 const base::string16
& device_name
) {}
67 // Tells the chooser that a device is no longer available. The chooser should
68 // not call DeviceSelected() for a device that's been removed.
69 virtual void RemoveDevice(const std::string
& device_id
) {}
72 } // namespace content
74 #endif // CONTENT_PUBLIC_BROWSER_BLUETOOTH_CHOOSER_H_