OLD | NEW |
---|---|
(Empty) | |
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 | |
5 #ifndef CONTENT_PUBLIC_BROWSER_BLUETOOTH_CHOOSER_H_ | |
6 #define CONTENT_PUBLIC_BROWSER_BLUETOOTH_CHOOSER_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "base/strings/string16.h" | |
12 #include "content/common/content_export.h" | |
13 | |
14 class GURL; | |
15 | |
16 namespace content { | |
17 | |
18 // Represents a way to ask the user to select a Bluetooth device from a list of | |
19 // options. | |
20 class CONTENT_EXPORT BluetoothChooser { | |
21 public: | |
22 class Observer { | |
23 public: | |
24 // The user cancelled the chooser instead of selecting a device. | |
25 virtual void DialogCancelled(int chooser_id) = 0; | |
26 // The user selected device |device_id|. | |
27 virtual void DeviceSelected(int chooser_id, | |
28 const std::string& device_id) = 0; | |
29 | |
30 // As the dialog implementations grow more user-visible buttons and knobs, | |
31 // those knobs will cause new functions to be called here. | |
32 | |
33 protected: | |
34 ~Observer() {} | |
35 }; | |
36 | |
37 // |observer| must outlive |this|. |chooser_id| is propagated to the Observer | |
38 // methods. | |
39 BluetoothChooser(Observer* observer, int chooser_id) | |
40 : observer_(observer), chooser_id_(chooser_id) {} | |
41 virtual ~BluetoothChooser(); | |
42 | |
43 // Lets the chooser tell the user the state of the Bluetooth adapter. | |
44 enum class AdapterPresence { ABSENT, POWERED_OFF, POWERED_ON }; | |
45 virtual void SetAdapterPresence(AdapterPresence presence) = 0; | |
46 | |
47 // Lets the chooser tell the user whether discovery is happening. | |
48 enum class DiscoveryState { FAILED_TO_START, DISCOVERING, IDLE }; | |
49 virtual void ShowDiscovering(DiscoveryState state) = 0; | |
ortuno
2015/08/17 21:12:59
Hmm not sure about the name of this function. What
Jeffrey Yasskin
2015/08/17 23:38:16
I'm not sure of it either, but I don't like your s
ortuno
2015/08/18 00:21:55
I like ShowDiscoveryState :)
| |
50 | |
51 // Shows a new device in the chooser. | |
52 virtual void AddDevice(const std::string& device_id, | |
53 const base::string16& device_name) = 0; | |
54 // Tells the chooser that a device is no longer available. The chooser should | |
55 // not call DeviceSelected() for a device that's been removed. | |
56 virtual void RemoveDevice(const std::string& device_id) = 0; | |
57 | |
58 protected: | |
59 // Subclasses call the observer methods through these wrappers, which add in | |
60 // the chooser ID. | |
61 void CallDialogCancelled() { observer_->DialogCancelled(chooser_id_); } | |
62 void CallDeviceSelected(const std::string& device_id) { | |
63 observer_->DeviceSelected(chooser_id_, device_id); | |
64 } | |
65 | |
66 private: | |
67 Observer* const observer_; | |
68 const int chooser_id_; | |
69 }; | |
70 | |
71 } // namespace content | |
72 | |
73 #endif // CONTENT_PUBLIC_BROWSER_BLUETOOTH_CHOOSER_H_ | |
OLD | NEW |