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 f36470b30bb7c05585aaacf61f4a6e68530c48cb..b59692d73c307cb731f9f27bbab5cf7950262ed4 100644 |
--- a/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc |
+++ b/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc |
@@ -20,14 +20,16 @@ |
#if defined(OS_CHROMEOS) |
#include "base/memory/ref_counted.h" |
#include "base/safe_strerror_posix.h" |
-#include "chrome/browser/chromeos/bluetooth/bluetooth_adapter.h" |
-#include "chrome/browser/chromeos/bluetooth/bluetooth_device.h" |
-#include "chrome/browser/chromeos/bluetooth/bluetooth_service_record.h" |
-#include "chrome/browser/chromeos/bluetooth/bluetooth_socket.h" |
-#include "chrome/browser/chromeos/bluetooth/bluetooth_utils.h" |
#include "chrome/browser/chromeos/extensions/bluetooth_event_router.h" |
#include "chromeos/dbus/bluetooth_out_of_band_client.h" |
-#include "chromeos/dbus/bluetooth_out_of_band_pairing_data.h" |
+#include "device/bluetooth/bluetooth_adapter.h" |
+#include "device/bluetooth/bluetooth_device.h" |
+#include "device/bluetooth/bluetooth_out_of_band_pairing_data.h" |
+#include "device/bluetooth/bluetooth_service_record.h" |
+#include "device/bluetooth/bluetooth_socket.h" |
+#include "device/bluetooth/bluetooth_utils.h" |
+ |
+using device_bluetooth::BluetoothAdapter; |
namespace { |
@@ -35,12 +37,12 @@ chromeos::ExtensionBluetoothEventRouter* GetEventRouter(Profile* profile) { |
return profile->GetExtensionService()->bluetooth_event_router(); |
} |
-const chromeos::BluetoothAdapter& GetAdapter(Profile* profile) { |
+const device_bluetooth::BluetoothAdapter& GetAdapter(Profile* profile) { |
return GetEventRouter(profile)->adapter(); |
} |
-chromeos::BluetoothAdapter* GetMutableAdapter(Profile* profile) { |
- chromeos::BluetoothAdapter* adapter = |
+device_bluetooth::BluetoothAdapter* GetMutableAdapter(Profile* profile) { |
+ device_bluetooth::BluetoothAdapter* adapter = |
GetEventRouter(profile)->GetMutableAdapter(); |
CHECK(adapter); |
return adapter; |
@@ -103,7 +105,7 @@ BluetoothGetDevicesFunction::BluetoothGetDevicesFunction() |
: callbacks_pending_(0) {} |
void BluetoothGetDevicesFunction::DispatchDeviceSearchResult( |
- const chromeos::BluetoothDevice& device) { |
+ const device_bluetooth::BluetoothDevice& device) { |
experimental_bluetooth::Device extension_device; |
experimental_bluetooth::BluetoothDeviceToApiDevice(device, &extension_device); |
GetEventRouter(profile())->DispatchDeviceEvent( |
@@ -112,7 +114,7 @@ void BluetoothGetDevicesFunction::DispatchDeviceSearchResult( |
} |
void BluetoothGetDevicesFunction::ProvidesServiceCallback( |
- const chromeos::BluetoothDevice* device, |
+ const device_bluetooth::BluetoothDevice* device, |
bool providesService) { |
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
@@ -134,7 +136,8 @@ bool BluetoothGetDevicesFunction::RunImpl() { |
std::string uuid; |
if (options.uuid.get() != NULL) { |
- uuid = chromeos::bluetooth_utils::CanonicalUuid(*options.uuid.get()); |
+ uuid = device_bluetooth::bluetooth_utils::CanonicalUuid( |
+ *options.uuid.get()); |
if (uuid.empty()) { |
SetError(kInvalidUuid); |
return false; |
@@ -143,11 +146,11 @@ bool BluetoothGetDevicesFunction::RunImpl() { |
CHECK_EQ(0, callbacks_pending_); |
- chromeos::BluetoothAdapter::DeviceList devices = |
+ BluetoothAdapter::DeviceList devices = |
GetMutableAdapter(profile())->GetDevices(); |
- for (chromeos::BluetoothAdapter::DeviceList::iterator i = devices.begin(); |
+ for (BluetoothAdapter::DeviceList::iterator i = devices.begin(); |
i != devices.end(); ++i) { |
- chromeos::BluetoothDevice* device = *i; |
+ device_bluetooth::BluetoothDevice* device = *i; |
CHECK(device); |
if (!uuid.empty() && !(device->ProvidesServiceWithUUID(uuid))) |
@@ -178,10 +181,10 @@ bool BluetoothGetDevicesFunction::RunImpl() { |
void BluetoothGetServicesFunction::GetServiceRecordsCallback( |
base::ListValue* services, |
- const chromeos::BluetoothDevice::ServiceRecordList& records) { |
- for (chromeos::BluetoothDevice::ServiceRecordList::const_iterator i = |
+ const device_bluetooth::BluetoothDevice::ServiceRecordList& records) { |
+ for (device_bluetooth::BluetoothDevice::ServiceRecordList::const_iterator i = |
records.begin(); i != records.end(); ++i) { |
- const chromeos::BluetoothServiceRecord& record = **i; |
+ const device_bluetooth::BluetoothServiceRecord& record = **i; |
experimental_bluetooth::ServiceRecord api_record; |
api_record.name = record.name(); |
if (!record.uuid().empty()) |
@@ -202,7 +205,7 @@ bool BluetoothGetServicesFunction::RunImpl() { |
EXTENSION_FUNCTION_VALIDATE(params.get() != NULL); |
const experimental_bluetooth::GetServicesOptions& options = params->options; |
- chromeos::BluetoothDevice* device = |
+ device_bluetooth::BluetoothDevice* device = |
GetMutableAdapter(profile())->GetDevice(options.device_address); |
if (!device) { |
SetError(kInvalidDevice); |
@@ -223,9 +226,9 @@ bool BluetoothGetServicesFunction::RunImpl() { |
} |
void BluetoothConnectFunction::ConnectToServiceCallback( |
- const chromeos::BluetoothDevice* device, |
+ const device_bluetooth::BluetoothDevice* device, |
const std::string& service_uuid, |
- scoped_refptr<chromeos::BluetoothSocket> socket) { |
+ scoped_refptr<device_bluetooth::BluetoothSocket> socket) { |
if (socket.get()) { |
int socket_id = GetEventRouter(profile())->RegisterSocket(socket); |
@@ -247,14 +250,14 @@ bool BluetoothConnectFunction::RunImpl() { |
EXTENSION_FUNCTION_VALIDATE(params.get() != NULL); |
const experimental_bluetooth::ConnectOptions& options = params->options; |
- std::string uuid = chromeos::bluetooth_utils::CanonicalUuid( |
+ std::string uuid = device_bluetooth::bluetooth_utils::CanonicalUuid( |
options.service_uuid); |
if (uuid.empty()) { |
SetError(kInvalidUuid); |
return false; |
} |
- chromeos::BluetoothDevice* device = |
+ device_bluetooth::BluetoothDevice* device = |
GetMutableAdapter(profile())->GetDevice(options.device_address); |
if (!device) { |
SetError(kInvalidDevice); |
@@ -395,7 +398,7 @@ bool BluetoothSetOutOfBandPairingDataFunction::RunImpl() { |
std::string address; |
EXTENSION_FUNCTION_VALIDATE(options->GetString("deviceAddress", &address)); |
- chromeos::BluetoothDevice* device = |
+ device_bluetooth::BluetoothDevice* device = |
GetMutableAdapter(profile())->GetDevice(address); |
if (!device) { |
SetError(kInvalidDevice); |
@@ -406,22 +409,24 @@ bool BluetoothSetOutOfBandPairingDataFunction::RunImpl() { |
DictionaryValue* data_in; |
EXTENSION_FUNCTION_VALIDATE(options->GetDictionary("data", &data_in)); |
- chromeos::BluetoothOutOfBandPairingData data_out; |
+ device_bluetooth::BluetoothOutOfBandPairingData data_out; |
base::BinaryValue* tmp_data; |
EXTENSION_FUNCTION_VALIDATE(data_in->GetBinary("hash", &tmp_data)); |
EXTENSION_FUNCTION_VALIDATE( |
- tmp_data->GetSize() == chromeos::kBluetoothOutOfBandPairingDataSize); |
+ tmp_data->GetSize() == |
+ device_bluetooth::kBluetoothOutOfBandPairingDataSize); |
memcpy(data_out.hash, |
reinterpret_cast<uint8_t*>(tmp_data->GetBuffer()), |
- chromeos::kBluetoothOutOfBandPairingDataSize); |
+ device_bluetooth::kBluetoothOutOfBandPairingDataSize); |
EXTENSION_FUNCTION_VALIDATE(data_in->GetBinary("randomizer", &tmp_data)); |
EXTENSION_FUNCTION_VALIDATE( |
- tmp_data->GetSize() == chromeos::kBluetoothOutOfBandPairingDataSize); |
+ tmp_data->GetSize() == |
+ device_bluetooth::kBluetoothOutOfBandPairingDataSize); |
memcpy(data_out.randomizer, |
reinterpret_cast<uint8_t*>(tmp_data->GetBuffer()), |
- chromeos::kBluetoothOutOfBandPairingDataSize); |
+ device_bluetooth::kBluetoothOutOfBandPairingDataSize); |
device->SetOutOfBandPairingData( |
data_out, |
@@ -441,13 +446,13 @@ bool BluetoothSetOutOfBandPairingDataFunction::RunImpl() { |
} |
void BluetoothGetLocalOutOfBandPairingDataFunction::ReadCallback( |
- const chromeos::BluetoothOutOfBandPairingData& data) { |
+ const device_bluetooth::BluetoothOutOfBandPairingData& data) { |
base::BinaryValue* hash = base::BinaryValue::CreateWithCopiedBuffer( |
reinterpret_cast<const char*>(data.hash), |
- chromeos::kBluetoothOutOfBandPairingDataSize); |
+ device_bluetooth::kBluetoothOutOfBandPairingDataSize); |
base::BinaryValue* randomizer = base::BinaryValue::CreateWithCopiedBuffer( |
reinterpret_cast<const char*>(data.randomizer), |
- chromeos::kBluetoothOutOfBandPairingDataSize); |
+ device_bluetooth::kBluetoothOutOfBandPairingDataSize); |
// TODO(bryeung): convert to experimental_bluetooth::OutOfBandPairingData |
// when ArrayBuffer support within objects is completed. |