Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(564)

Unified Diff: chrome/browser/ui/bluetooth/bluetooth_chooser_controller.cc

Issue 2203103003: Reset Bluetooth EventHandler when it is invalid (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reset Bluetooth EventHandler when it is not valid Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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();

Powered by Google App Engine
This is Rietveld 408576698