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 29 matching lines...) Expand all Loading... | |
40 void OpenHelpCenterUrl() const override; | 40 void OpenHelpCenterUrl() const override; |
41 | 41 |
42 // Update the state of the Bluetooth adapter. | 42 // Update the state of the Bluetooth adapter. |
43 void OnAdapterPresenceChanged( | 43 void OnAdapterPresenceChanged( |
44 content::BluetoothChooser::AdapterPresence presence); | 44 content::BluetoothChooser::AdapterPresence presence); |
45 | 45 |
46 // Update the Bluetooth discovery state and let the user know whether | 46 // Update the Bluetooth discovery state and let the user know whether |
47 // discovery is happening. | 47 // discovery is happening. |
48 void OnDiscoveryStateChanged(content::BluetoothChooser::DiscoveryState state); | 48 void OnDiscoveryStateChanged(content::BluetoothChooser::DiscoveryState state); |
49 | 49 |
50 // Shows a new device in the chooser. | 50 // Shows a new device in the chooser. |
juncai
2016/08/04 21:52:25
nit: update the comments.
ortuno
2016/08/05 02:16:09
Done.
| |
51 void AddDevice(const std::string& device_id, | 51 void AddOrUpdateDevice(const std::string& device_id, |
52 const base::string16& device_name); | 52 const base::string16& device_name); |
53 | 53 |
54 // Tells the chooser that a device is no longer available. | 54 // Tells the chooser that a device is no longer available. |
55 void RemoveDevice(const std::string& device_id); | 55 void RemoveDevice(const std::string& device_id); |
56 | 56 |
57 private: | 57 private: |
58 // Clears |device_names_and_ids_| and |device_name_map_|. Called when | 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. | 59 // Bluetooth adapter is turned on or off, or when re-scan happens. |
60 void ClearAllDevices(); | 60 void ClearAllDevices(); |
61 | 61 |
62 // Each pair is a (device name, device id). | 62 std::vector<std::string> device_ids_; |
63 std::vector<std::pair<base::string16, std::string>> device_names_and_ids_; | 63 std::unordered_map<std::string, base::string16> device_id_to_name_map_; |
64 content::BluetoothChooser::EventHandler event_handler_; | |
65 // Maps from device name to number of devices. | 64 // Maps from device name to number of devices. |
66 std::unordered_map<base::string16, int> device_name_map_; | 65 std::unordered_map<base::string16, int> device_name_map_; |
66 | |
67 content::BluetoothChooser::EventHandler event_handler_; | |
67 base::string16 no_devices_text_; | 68 base::string16 no_devices_text_; |
68 base::string16 status_text_; | 69 base::string16 status_text_; |
69 | 70 |
70 DISALLOW_COPY_AND_ASSIGN(BluetoothChooserController); | 71 DISALLOW_COPY_AND_ASSIGN(BluetoothChooserController); |
71 }; | 72 }; |
72 | 73 |
73 #endif // CHROME_BROWSER_UI_BLUETOOTH_BLUETOOTH_CHOOSER_CONTROLLER_H_ | 74 #endif // CHROME_BROWSER_UI_BLUETOOTH_BLUETOOTH_CHOOSER_CONTROLLER_H_ |
OLD | NEW |