Index: chrome/browser/extensions/api/bluetooth/bluetooth_api.cc |
diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc |
index ac0b7745cfa4f54887bc908e17617d894e9276ae..053a332a758863ff5cf595c249ee0ba1778c9aeb 100644 |
--- a/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc |
+++ b/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc |
@@ -635,24 +635,18 @@ void BluetoothStartDiscoveryFunction::OnSuccessCallback() { |
void BluetoothStartDiscoveryFunction::OnErrorCallback() { |
SetError(kStartDiscoveryFailed); |
- GetEventRouter(browser_context())->SetResponsibleForDiscovery(false); |
SendResponse(false); |
GetEventRouter(browser_context())->OnListenerRemoved(); |
} |
bool BluetoothStartDiscoveryFunction::DoWork( |
scoped_refptr<BluetoothAdapter> adapter) { |
- GetEventRouter(browser_context())->SetSendDiscoveryEvents(true); |
- |
- // If this profile is already discovering devices, there should be nothing |
- // else to do. |
- if (!GetEventRouter(browser_context())->IsResponsibleForDiscovery()) { |
- GetEventRouter(browser_context())->SetResponsibleForDiscovery(true); |
- GetEventRouter(browser_context())->OnListenerAdded(); |
- adapter->StartDiscovering( |
- base::Bind(&BluetoothStartDiscoveryFunction::OnSuccessCallback, this), |
- base::Bind(&BluetoothStartDiscoveryFunction::OnErrorCallback, this)); |
- } |
+ GetEventRouter(browser_context())->OnListenerAdded(); |
+ GetEventRouter(browser_context())->StartDiscoverySession( |
+ adapter, |
+ extension_id(), |
+ base::Bind(&BluetoothStartDiscoveryFunction::OnSuccessCallback, this), |
+ base::Bind(&BluetoothStartDiscoveryFunction::OnErrorCallback, this)); |
return true; |
} |
@@ -664,19 +658,17 @@ void BluetoothStopDiscoveryFunction::OnSuccessCallback() { |
void BluetoothStopDiscoveryFunction::OnErrorCallback() { |
SetError(kStopDiscoveryFailed); |
- GetEventRouter(browser_context())->SetResponsibleForDiscovery(true); |
SendResponse(false); |
GetEventRouter(browser_context())->OnListenerRemoved(); |
} |
bool BluetoothStopDiscoveryFunction::DoWork( |
scoped_refptr<BluetoothAdapter> adapter) { |
- GetEventRouter(browser_context())->SetSendDiscoveryEvents(false); |
- if (GetEventRouter(browser_context())->IsResponsibleForDiscovery()) { |
- adapter->StopDiscovering( |
- base::Bind(&BluetoothStopDiscoveryFunction::OnSuccessCallback, this), |
- base::Bind(&BluetoothStopDiscoveryFunction::OnErrorCallback, this)); |
- } |
+ GetEventRouter(browser_context())->StopDiscoverySession( |
+ adapter, |
+ extension_id(), |
+ base::Bind(&BluetoothStopDiscoveryFunction::OnSuccessCallback, this), |
+ base::Bind(&BluetoothStopDiscoveryFunction::OnErrorCallback, this)); |
return true; |
} |