Chromium Code Reviews| Index: chrome/browser/ui/bluetooth/bluetooth_chooser_controller.cc |
| diff --git a/chrome/browser/ui/bluetooth/bluetooth_chooser_controller.cc b/chrome/browser/ui/bluetooth/bluetooth_chooser_controller.cc |
| index f8c98f6166bd12c38b3cb99b6e5e16635b6893e8..116596fa790eb2e382b9f63285c1c6fd48e19861 100644 |
| --- a/chrome/browser/ui/bluetooth/bluetooth_chooser_controller.cc |
| +++ b/chrome/browser/ui/bluetooth/bluetooth_chooser_controller.cc |
| @@ -65,6 +65,8 @@ base::string16 BluetoothChooserController::GetOption(size_t index) const { |
| } |
| void BluetoothChooserController::RefreshOptions() { |
| + if (event_handler_.is_null()) |
| + return; |
| ClearAllDevices(); |
| event_handler_.Run(content::BluetoothChooser::Event::RESCAN, std::string()); |
| } |
| @@ -74,17 +76,23 @@ base::string16 BluetoothChooserController::GetStatus() const { |
| } |
| void BluetoothChooserController::Select(size_t index) { |
| + if (event_handler_.is_null()) |
|
Jeffrey Yasskin
2016/08/05 20:37:51
Would it make sense to record how often this happe
juncai
2016/08/05 22:51:58
Done.
|
| + return; |
| DCHECK_LT(index, device_names_and_ids_.size()); |
| event_handler_.Run(content::BluetoothChooser::Event::SELECTED, |
| device_names_and_ids_[index].second); |
| } |
| void BluetoothChooserController::Cancel() { |
| + if (event_handler_.is_null()) |
| + return; |
| event_handler_.Run(content::BluetoothChooser::Event::CANCELLED, |
| std::string()); |
| } |
| void BluetoothChooserController::Close() { |
| + if (event_handler_.is_null()) |
| + return; |
| event_handler_.Run(content::BluetoothChooser::Event::CANCELLED, |
| std::string()); |
| } |
| @@ -172,6 +180,10 @@ void BluetoothChooserController::RemoveDevice(const std::string& device_id) { |
| } |
| } |
| +void BluetoothChooserController::ResetEventHandler() { |
| + event_handler_.Reset(); |
| +} |
| + |
| void BluetoothChooserController::ClearAllDevices() { |
| device_names_and_ids_.clear(); |
| device_name_map_.clear(); |