OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_BLUETOOTH_BLUETOOTH_CHOOSER_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_BLUETOOTH_BLUETOOTH_CHOOSER_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_BLUETOOTH_BLUETOOTH_CHOOSER_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_BLUETOOTH_BLUETOOTH_CHOOSER_CONTROLLER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 10 matching lines...) Expand all Loading... |
21 // It can be used by WebBluetooth API to get the user's permission to | 21 // It can be used by WebBluetooth API to get the user's permission to |
22 // access a Bluetooth device. It is owned by ChooserBubbleDelegate. | 22 // access a Bluetooth device. It is owned by ChooserBubbleDelegate. |
23 class BluetoothChooserController : public ChooserController { | 23 class BluetoothChooserController : public ChooserController { |
24 public: | 24 public: |
25 explicit BluetoothChooserController( | 25 explicit BluetoothChooserController( |
26 content::RenderFrameHost* owner, | 26 content::RenderFrameHost* owner, |
27 const content::BluetoothChooser::EventHandler& event_handler); | 27 const content::BluetoothChooser::EventHandler& event_handler); |
28 ~BluetoothChooserController() override; | 28 ~BluetoothChooserController() override; |
29 | 29 |
30 // ChooserController: | 30 // ChooserController: |
| 31 base::string16 GetNoOptionsText() const override; |
31 base::string16 GetOkButtonLabel() const override; | 32 base::string16 GetOkButtonLabel() const override; |
32 size_t NumOptions() const override; | 33 size_t NumOptions() const override; |
33 base::string16 GetOption(size_t index) const override; | 34 base::string16 GetOption(size_t index) const override; |
| 35 void RefreshOptions() override; |
| 36 base::string16 GetStatus() const override; |
34 void Select(size_t index) override; | 37 void Select(size_t index) override; |
35 void Cancel() override; | 38 void Cancel() override; |
36 void Close() override; | 39 void Close() override; |
37 void OpenHelpCenterUrl() const override; | 40 void OpenHelpCenterUrl() const override; |
38 | 41 |
| 42 // Update the state of the Bluetooth adapter. |
| 43 void OnAdapterPresenceChanged( |
| 44 content::BluetoothChooser::AdapterPresence presence); |
| 45 |
| 46 // Update the Bluetooth discovery state and let the user know whether |
| 47 // discovery is happening. |
| 48 void OnDiscoveryStateChanged(content::BluetoothChooser::DiscoveryState state); |
| 49 |
39 // Shows a new device in the chooser. | 50 // Shows a new device in the chooser. |
40 void AddDevice(const std::string& device_id, | 51 void AddDevice(const std::string& device_id, |
41 const base::string16& device_name); | 52 const base::string16& device_name); |
42 | 53 |
43 // Tells the chooser that a device is no longer available. | 54 // Tells the chooser that a device is no longer available. |
44 void RemoveDevice(const std::string& device_id); | 55 void RemoveDevice(const std::string& device_id); |
45 | 56 |
46 private: | 57 private: |
| 58 // Clears |device_names_and_ids_| and |device_name_map_|. Called when |
| 59 // Bluetooth adapter is turned on or off, or when re-scan happens. |
| 60 void ClearAllDevices(); |
| 61 |
47 // Each pair is a (device name, device id). | 62 // Each pair is a (device name, device id). |
48 std::vector<std::pair<base::string16, std::string>> device_names_and_ids_; | 63 std::vector<std::pair<base::string16, std::string>> device_names_and_ids_; |
49 content::BluetoothChooser::EventHandler event_handler_; | 64 content::BluetoothChooser::EventHandler event_handler_; |
50 // Maps from device name to number of devices. | 65 // Maps from device name to number of devices. |
51 std::unordered_map<base::string16, int> device_name_map_; | 66 std::unordered_map<base::string16, int> device_name_map_; |
| 67 base::string16 no_devices_text_; |
| 68 base::string16 status_text_; |
52 | 69 |
53 DISALLOW_COPY_AND_ASSIGN(BluetoothChooserController); | 70 DISALLOW_COPY_AND_ASSIGN(BluetoothChooserController); |
54 }; | 71 }; |
55 | 72 |
56 #endif // CHROME_BROWSER_UI_BLUETOOTH_BLUETOOTH_CHOOSER_CONTROLLER_H_ | 73 #endif // CHROME_BROWSER_UI_BLUETOOTH_BLUETOOTH_CHOOSER_CONTROLLER_H_ |
OLD | NEW |