Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(396)

Side by Side Diff: chrome/browser/extensions/api/bluetooth/bluetooth_api_utils.cc

Issue 246603008: Expose device RSSI and Tx power via the chrome.bluetooth API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Forward-declare more APIs introduced in Lion Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/extensions/api/bluetooth/bluetooth_apitest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api_utils.h" 5 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api_utils.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/common/extensions/api/bluetooth.h" 9 #include "chrome/common/extensions/api/bluetooth.h"
10 #include "device/bluetooth/bluetooth_adapter.h" 10 #include "device/bluetooth/bluetooth_adapter.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 out->vendor_id.reset(new int(device.GetVendorID())); 105 out->vendor_id.reset(new int(device.GetVendorID()));
106 out->product_id.reset(new int(device.GetProductID())); 106 out->product_id.reset(new int(device.GetProductID()));
107 out->device_id.reset(new int(device.GetDeviceID())); 107 out->device_id.reset(new int(device.GetDeviceID()));
108 } 108 }
109 109
110 ConvertDeviceTypeToApi(device.GetDeviceType(), &(out->type)); 110 ConvertDeviceTypeToApi(device.GetDeviceType(), &(out->type));
111 111
112 out->paired.reset(new bool(device.IsPaired())); 112 out->paired.reset(new bool(device.IsPaired()));
113 out->connected.reset(new bool(device.IsConnected())); 113 out->connected.reset(new bool(device.IsConnected()));
114 114
115 int rssi = device.GetRSSI();
116 if (rssi != BluetoothDevice::kUnknownPower)
117 out->rssi.reset(new int(rssi));
118
119 if (*out->connected) {
120 int current_transmit_power = device.GetCurrentHostTransmitPower();
121 if (current_transmit_power != BluetoothDevice::kUnknownPower)
122 out->current_host_transmit_power.reset(new int(current_transmit_power));
123 int maximum_transmit_power = device.GetMaximumHostTransmitPower();
124 if (maximum_transmit_power != BluetoothDevice::kUnknownPower)
125 out->maximum_host_transmit_power.reset(new int(maximum_transmit_power));
126 }
127
115 std::vector<std::string>* string_uuids = new std::vector<std::string>(); 128 std::vector<std::string>* string_uuids = new std::vector<std::string>();
116 const device::BluetoothDevice::UUIDList& uuids = device.GetUUIDs(); 129 const device::BluetoothDevice::UUIDList& uuids = device.GetUUIDs();
117 for (device::BluetoothDevice::UUIDList::const_iterator iter = uuids.begin(); 130 for (device::BluetoothDevice::UUIDList::const_iterator iter = uuids.begin();
118 iter != uuids.end(); ++iter) 131 iter != uuids.end(); ++iter)
119 string_uuids->push_back(iter->canonical_value()); 132 string_uuids->push_back(iter->canonical_value());
120 out->uuids.reset(string_uuids); 133 out->uuids.reset(string_uuids);
121 } 134 }
122 135
123 void PopulateAdapterState(const device::BluetoothAdapter& adapter, 136 void PopulateAdapterState(const device::BluetoothAdapter& adapter,
124 AdapterState* out) { 137 AdapterState* out) {
125 out->discovering = adapter.IsDiscovering(); 138 out->discovering = adapter.IsDiscovering();
126 out->available = adapter.IsPresent(); 139 out->available = adapter.IsPresent();
127 out->powered = adapter.IsPowered(); 140 out->powered = adapter.IsPowered();
128 out->name = adapter.GetName(); 141 out->name = adapter.GetName();
129 out->address = adapter.GetAddress(); 142 out->address = adapter.GetAddress();
130 } 143 }
131 144
132 } // namespace bluetooth 145 } // namespace bluetooth
133 } // namespace api 146 } // namespace api
134 } // namespace extensions 147 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/bluetooth/bluetooth_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698