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 or updates its information. |
51 void AddDevice(const std::string& device_id, | 51 // TODO(ortuno): Update device's name if necessary. |
52 const base::string16& device_name); | 52 // https://crbug.com/634366 |
| 53 void AddOrUpdateDevice(const std::string& device_id, |
| 54 bool should_update_name, |
| 55 const base::string16& device_name, |
| 56 bool is_gatt_connected, |
| 57 bool is_paired, |
| 58 const int8_t* rssi); |
53 | 59 |
54 // Tells the chooser that a device is no longer available. | 60 // Tells the chooser that a device is no longer available. |
55 void RemoveDevice(const std::string& device_id); | 61 void RemoveDevice(const std::string& device_id); |
56 | 62 |
57 // Called when |event_handler_| is no longer valid and should not be used | 63 // Called when |event_handler_| is no longer valid and should not be used |
58 // any more. | 64 // any more. |
59 void ResetEventHandler(); | 65 void ResetEventHandler(); |
60 | 66 |
61 private: | 67 private: |
62 // Clears |device_names_and_ids_| and |device_name_map_|. Called when | 68 // Clears |device_names_and_ids_| and |device_name_map_|. Called when |
63 // Bluetooth adapter is turned on or off, or when re-scan happens. | 69 // Bluetooth adapter is turned on or off, or when re-scan happens. |
64 void ClearAllDevices(); | 70 void ClearAllDevices(); |
65 | 71 |
66 // Each pair is a (device name, device id). | 72 std::vector<std::string> device_ids_; |
67 std::vector<std::pair<base::string16, std::string>> device_names_and_ids_; | 73 std::unordered_map<std::string, base::string16> device_id_to_name_map_; |
68 content::BluetoothChooser::EventHandler event_handler_; | |
69 // Maps from device name to number of devices. | 74 // Maps from device name to number of devices. |
70 std::unordered_map<base::string16, int> device_name_map_; | 75 std::unordered_map<base::string16, int> device_name_map_; |
| 76 |
| 77 content::BluetoothChooser::EventHandler event_handler_; |
71 base::string16 no_devices_text_; | 78 base::string16 no_devices_text_; |
72 base::string16 status_text_; | 79 base::string16 status_text_; |
73 | 80 |
74 DISALLOW_COPY_AND_ASSIGN(BluetoothChooserController); | 81 DISALLOW_COPY_AND_ASSIGN(BluetoothChooserController); |
75 }; | 82 }; |
76 | 83 |
77 #endif // CHROME_BROWSER_UI_BLUETOOTH_BLUETOOTH_CHOOSER_CONTROLLER_H_ | 84 #endif // CHROME_BROWSER_UI_BLUETOOTH_BLUETOOTH_CHOOSER_CONTROLLER_H_ |
OLD | NEW |