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