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

Side by Side Diff: device/bluetooth/bluetooth_device.cc

Issue 2009753002: bluetooth: Make public BluetoothDevice::GetName method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: split out name/alias Created 4 years, 5 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
« no previous file with comments | « device/bluetooth/bluetooth_device.h ('k') | device/bluetooth/bluetooth_device_android.h » ('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 "device/bluetooth/bluetooth_device.h" 5 #include "device/bluetooth/bluetooth_device.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 29 matching lines...) Expand all
40 40
41 BluetoothDevice::ConnectionInfo::ConnectionInfo( 41 BluetoothDevice::ConnectionInfo::ConnectionInfo(
42 int rssi, int transmit_power, int max_transmit_power) 42 int rssi, int transmit_power, int max_transmit_power)
43 : rssi(rssi), 43 : rssi(rssi),
44 transmit_power(transmit_power), 44 transmit_power(transmit_power),
45 max_transmit_power(max_transmit_power) {} 45 max_transmit_power(max_transmit_power) {}
46 46
47 BluetoothDevice::ConnectionInfo::~ConnectionInfo() {} 47 BluetoothDevice::ConnectionInfo::~ConnectionInfo() {}
48 48
49 base::string16 BluetoothDevice::GetNameForDisplay() const { 49 base::string16 BluetoothDevice::GetNameForDisplay() const {
50 std::string name = GetDeviceName(); 50 base::Optional<std::string> name = GetName();
51 if (!name.empty()) { 51 if (name && !name.value().empty()) {
52 return base::UTF8ToUTF16(name); 52 return base::UTF8ToUTF16(name.value());
53 } else { 53 } else {
54 return GetAddressWithLocalizedDeviceTypeName(); 54 return GetAddressWithLocalizedDeviceTypeName();
55 } 55 }
56 } 56 }
57 57
58 base::string16 BluetoothDevice::GetAddressWithLocalizedDeviceTypeName() const { 58 base::string16 BluetoothDevice::GetAddressWithLocalizedDeviceTypeName() const {
59 base::string16 address_utf16 = base::UTF8ToUTF16(GetAddress()); 59 base::string16 address_utf16 = base::UTF8ToUTF16(GetAddress());
60 BluetoothDevice::DeviceType device_type = GetDeviceType(); 60 BluetoothDevice::DeviceType device_type = GetDeviceType();
61 switch (device_type) { 61 switch (device_type) {
62 case DEVICE_COMPUTER: 62 case DEVICE_COMPUTER:
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 return false; 230 return false;
231 231
232 // TODO: Move this database into a config file. 232 // TODO: Move this database into a config file.
233 233
234 return true; 234 return true;
235 } 235 }
236 236
237 bool BluetoothDevice::IsTrustable() const { 237 bool BluetoothDevice::IsTrustable() const {
238 // Sony PlayStation Dualshock3 238 // Sony PlayStation Dualshock3
239 if ((GetVendorID() == 0x054c && GetProductID() == 0x0268 && 239 if ((GetVendorID() == 0x054c && GetProductID() == 0x0268 &&
240 GetDeviceName() == "PLAYSTATION(R)3 Controller")) 240 GetName() == std::string("PLAYSTATION(R)3 Controller")))
241 return true; 241 return true;
242 242
243 return false; 243 return false;
244 } 244 }
245 245
246 void BluetoothDevice::CreateGattConnection( 246 void BluetoothDevice::CreateGattConnection(
247 const GattConnectionCallback& callback, 247 const GattConnectionCallback& callback,
248 const ConnectErrorCallback& error_callback) { 248 const ConnectErrorCallback& error_callback) {
249 create_gatt_connection_success_callbacks_.push_back(callback); 249 create_gatt_connection_success_callbacks_.push_back(callback);
250 create_gatt_connection_error_callbacks_.push_back(error_callback); 250 create_gatt_connection_error_callbacks_.push_back(error_callback);
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 const base::Closure& callback, 397 const base::Closure& callback,
398 const ConnectErrorCallback& error_callback) { 398 const ConnectErrorCallback& error_callback) {
399 NOTREACHED(); 399 NOTREACHED();
400 } 400 }
401 401
402 void BluetoothDevice::UpdateTimestamp() { 402 void BluetoothDevice::UpdateTimestamp() {
403 last_update_time_ = base::Time::NowFromSystemTime(); 403 last_update_time_ = base::Time::NowFromSystemTime();
404 } 404 }
405 405
406 } // namespace device 406 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_device.h ('k') | device/bluetooth/bluetooth_device_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698