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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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. |
51 void AddDevice(const std::string& device_id, | 51 void AddDevice(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 // Called when |event_handler_| is no longer valid and should not be used |
| 58 // any more. |
| 59 void ResetEventHandler(); |
| 60 |
57 private: | 61 private: |
58 // Clears |device_names_and_ids_| and |device_name_map_|. Called when | 62 // Clears |device_names_and_ids_| and |device_name_map_|. Called when |
59 // Bluetooth adapter is turned on or off, or when re-scan happens. | 63 // Bluetooth adapter is turned on or off, or when re-scan happens. |
60 void ClearAllDevices(); | 64 void ClearAllDevices(); |
61 | 65 |
62 // Each pair is a (device name, device id). | 66 // Each pair is a (device name, device id). |
63 std::vector<std::pair<base::string16, std::string>> device_names_and_ids_; | 67 std::vector<std::pair<base::string16, std::string>> device_names_and_ids_; |
64 content::BluetoothChooser::EventHandler event_handler_; | 68 content::BluetoothChooser::EventHandler event_handler_; |
65 // Maps from device name to number of devices. | 69 // Maps from device name to number of devices. |
66 std::unordered_map<base::string16, int> device_name_map_; | 70 std::unordered_map<base::string16, int> device_name_map_; |
67 base::string16 no_devices_text_; | 71 base::string16 no_devices_text_; |
68 base::string16 status_text_; | 72 base::string16 status_text_; |
69 | 73 |
70 DISALLOW_COPY_AND_ASSIGN(BluetoothChooserController); | 74 DISALLOW_COPY_AND_ASSIGN(BluetoothChooserController); |
71 }; | 75 }; |
72 | 76 |
73 #endif // CHROME_BROWSER_UI_BLUETOOTH_BLUETOOTH_CHOOSER_CONTROLLER_H_ | 77 #endif // CHROME_BROWSER_UI_BLUETOOTH_BLUETOOTH_CHOOSER_CONTROLLER_H_ |
OLD | NEW |