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 173fc18848dd1fe1d4f904dd4b9abd51616ab0e2..3ba917bdd5198a24764b57dbc5dda4f6754f8f4b 100644 |
--- a/chrome/browser/ui/bluetooth/bluetooth_chooser_controller.cc |
+++ b/chrome/browser/ui/bluetooth/bluetooth_chooser_controller.cc |
@@ -57,6 +57,19 @@ base::string16 BluetoothChooserController::GetOption(size_t index) const { |
base::UTF8ToUTF16(device_names_and_ids_[index].second)); |
} |
+void BluetoothChooserController::RefreshOptions() { |
+ ClearAllDevices(); |
+ event_handler_.Run(content::BluetoothChooser::Event::RESCAN, std::string()); |
+} |
+ |
+bool BluetoothChooserController::NeedsThrobber() const { |
+ return true; |
+} |
+ |
+bool BluetoothChooserController::NeedsStatus() const { |
+ return true; |
+} |
+ |
void BluetoothChooserController::Select(size_t index) { |
DCHECK_LT(index, device_names_and_ids_.size()); |
event_handler_.Run(content::BluetoothChooser::Event::SELECTED, |
@@ -80,6 +93,38 @@ void BluetoothChooserController::OpenHelpCenterUrl() const { |
false /* is_renderer_initialized */)); |
} |
+void BluetoothChooserController::UpdateAdapterPresence( |
+ content::BluetoothChooser::AdapterPresence presence) { |
+ ClearAllDevices(); |
+ switch (presence) { |
+ case content::BluetoothChooser::AdapterPresence::ABSENT: |
+ break; |
+ case content::BluetoothChooser::AdapterPresence::POWERED_OFF: |
+ if (observer()) |
+ observer()->AdapterOff(); |
+ break; |
+ case content::BluetoothChooser::AdapterPresence::POWERED_ON: |
+ if (observer()) |
+ observer()->AdapterOn(); |
+ break; |
+ } |
+} |
+ |
+void BluetoothChooserController::UpdateDiscoveryState( |
+ content::BluetoothChooser::DiscoveryState state) { |
+ switch (state) { |
+ case content::BluetoothChooser::DiscoveryState::DISCOVERING: |
+ if (observer()) |
+ observer()->Refresh(); |
+ break; |
+ case content::BluetoothChooser::DiscoveryState::IDLE: |
+ case content::BluetoothChooser::DiscoveryState::FAILED_TO_START: |
+ if (observer()) |
+ observer()->Idle(); |
+ break; |
+ } |
+} |
+ |
void BluetoothChooserController::AddDevice(const std::string& device_id, |
const base::string16& device_name) { |
device_names_and_ids_.push_back(std::make_pair(device_name, device_id)); |
@@ -103,3 +148,8 @@ void BluetoothChooserController::RemoveDevice(const std::string& device_id) { |
} |
} |
} |
+ |
+void BluetoothChooserController::ClearAllDevices() { |
+ device_names_and_ids_.clear(); |
+ device_name_map_.clear(); |
+} |