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

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: added CONTENT_EXPORT 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..0b096bcb932d486ab574effcb06e4dfa164c2d6d 100644
--- a/chrome/browser/ui/bluetooth/bluetooth_chooser_controller.cc
+++ b/chrome/browser/ui/bluetooth/bluetooth_chooser_controller.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
+#include "content/browser/bluetooth/bluetooth_metrics.h"
#include "ui/base/l10n/l10n_util.h"
#include "url/gurl.h"
@@ -65,6 +66,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 +77,27 @@ base::string16 BluetoothChooserController::GetStatus() const {
}
void BluetoothChooserController::Select(size_t index) {
+ if (event_handler_.is_null()) {
+ content::RecordRequestDeviceOutcome(
+ content::UMARequestDeviceOutcome::
+ BLUETOOTH_CHOOSER_EVENT_HANDLER_INVALID);
+ 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 +185,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();
« no previous file with comments | « chrome/browser/ui/bluetooth/bluetooth_chooser_controller.h ('k') | chrome/browser/ui/bluetooth/bluetooth_chooser_desktop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698