| Index: chrome/browser/extensions/api/bluetooth/bluetooth_api.cc
|
| ===================================================================
|
| --- chrome/browser/extensions/api/bluetooth/bluetooth_api.cc (revision 157029)
|
| +++ chrome/browser/extensions/api/bluetooth/bluetooth_api.cc (working copy)
|
| @@ -11,7 +11,6 @@
|
| #include <string>
|
|
|
| #include "chrome/browser/extensions/api/bluetooth/bluetooth_api_utils.h"
|
| -#include "chrome/browser/extensions/event_names.h"
|
| #include "chrome/browser/extensions/extension_service.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/common/extensions/api/experimental_bluetooth.h"
|
| @@ -100,23 +99,14 @@
|
| BluetoothGetDevicesFunction::BluetoothGetDevicesFunction()
|
| : callbacks_pending_(0) {}
|
|
|
| -void BluetoothGetDevicesFunction::DispatchDeviceSearchResult(
|
| - const chromeos::BluetoothDevice& device) {
|
| - experimental_bluetooth::Device extension_device;
|
| - experimental_bluetooth::BluetoothDeviceToApiDevice(device, &extension_device);
|
| - GetEventRouter(profile())->DispatchDeviceEvent(
|
| - extensions::event_names::kBluetoothOnDeviceSearchResult,
|
| - extension_device);
|
| -}
|
| -
|
| -void BluetoothGetDevicesFunction::ProvidesServiceCallback(
|
| +void BluetoothGetDevicesFunction::AddDeviceIfTrueCallback(
|
| + ListValue* list,
|
| const chromeos::BluetoothDevice* device,
|
| - bool providesService) {
|
| + bool shouldAdd) {
|
| DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
|
|
| - CHECK(device);
|
| - if (providesService)
|
| - DispatchDeviceSearchResult(*device);
|
| + if (shouldAdd)
|
| + list->Append(experimental_bluetooth::BluetoothDeviceToValue(*device));
|
|
|
| callbacks_pending_--;
|
| if (callbacks_pending_ == -1)
|
| @@ -139,6 +129,9 @@
|
| }
|
| }
|
|
|
| + ListValue* matches = new ListValue;
|
| + SetResult(matches);
|
| +
|
| CHECK_EQ(0, callbacks_pending_);
|
|
|
| chromeos::BluetoothAdapter::DeviceList devices =
|
| @@ -146,21 +139,21 @@
|
| for (chromeos::BluetoothAdapter::DeviceList::iterator i = devices.begin();
|
| i != devices.end(); ++i) {
|
| chromeos::BluetoothDevice* device = *i;
|
| - CHECK(device);
|
|
|
| if (!uuid.empty() && !(device->ProvidesServiceWithUUID(uuid)))
|
| continue;
|
|
|
| if (options.name.get() == NULL) {
|
| - DispatchDeviceSearchResult(*device);
|
| + matches->Append(experimental_bluetooth::BluetoothDeviceToValue(*device));
|
| continue;
|
| }
|
|
|
| callbacks_pending_++;
|
| device->ProvidesServiceWithName(
|
| *(options.name),
|
| - base::Bind(&BluetoothGetDevicesFunction::ProvidesServiceCallback,
|
| + base::Bind(&BluetoothGetDevicesFunction::AddDeviceIfTrueCallback,
|
| this,
|
| + matches,
|
| device));
|
| }
|
| callbacks_pending_--;
|
|
|