| Index: chrome/browser/extensions/api/bluetooth/bluetooth_api_utils.cc
|
| diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_api_utils.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_api_utils.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..5503434f1d9b3b1b1e09a80a1d44f19e0e1b201d
|
| --- /dev/null
|
| +++ b/chrome/browser/extensions/api/bluetooth/bluetooth_api_utils.cc
|
| @@ -0,0 +1,40 @@
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/extensions/api/bluetooth/bluetooth_api_utils.h"
|
| +
|
| +#if defined(OS_CHROMEOS)
|
| +
|
| +#include "base/utf_string_conversions.h"
|
| +#include "base/values.h"
|
| +#include "chrome/browser/chromeos/bluetooth/bluetooth_device.h"
|
| +#include "chrome/common/extensions/api/experimental_bluetooth.h"
|
| +
|
| +namespace extensions {
|
| +namespace api {
|
| +namespace experimental_bluetooth {
|
| +
|
| +// Fill in a Device object from a chromeos::BluetoothDevice.
|
| +void BluetoothDeviceToApiDevice(
|
| + const chromeos::BluetoothDevice& device,
|
| + Device* out) {
|
| + out->name = UTF16ToUTF8(device.GetName());
|
| + out->address = device.address();
|
| + out->paired = device.IsPaired();
|
| + out->bonded = device.IsBonded();
|
| + out->connected = device.IsConnected();
|
| +}
|
| +
|
| +// The caller takes ownership of the returned pointer.
|
| +base::Value* BluetoothDeviceToValue(const chromeos::BluetoothDevice& device) {
|
| + extensions::api::experimental_bluetooth::Device api_device;
|
| + BluetoothDeviceToApiDevice(device, &api_device);
|
| + return api_device.ToValue().release();
|
| +}
|
| +
|
| +} // namespace experimental_bluetooth
|
| +} // namespace api
|
| +} // namespace extensions
|
| +
|
| +#endif
|
|
|