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

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

Issue 2394473005: Move enum BluetoothDevice::DeviceType out of BluetoothDevice class. (Closed)
Patch Set: Created 4 years, 2 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
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 "extensions/browser/api/bluetooth/bluetooth_api_utils.h" 5 #include "extensions/browser/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 "device/bluetooth/bluetooth_adapter.h" 9 #include "device/bluetooth/bluetooth_adapter.h"
10 #include "device/bluetooth/bluetooth_device.h" 10 #include "device/bluetooth/bluetooth_device.h"
11 #include "extensions/common/api/bluetooth.h" 11 #include "extensions/common/api/bluetooth.h"
12 12
13 namespace bluetooth = extensions::api::bluetooth; 13 namespace bluetooth = extensions::api::bluetooth;
14 14
15 using device::BluetoothDevice; 15 using device::BluetoothDevice;
16 using device::BluetoothDeviceType;
16 using bluetooth::VendorIdSource; 17 using bluetooth::VendorIdSource;
17 18
18 namespace { 19 namespace {
19 20
20 bool ConvertVendorIDSourceToApi(const BluetoothDevice::VendorIDSource& input, 21 bool ConvertVendorIDSourceToApi(const BluetoothDevice::VendorIDSource& input,
21 bluetooth::VendorIdSource* output) { 22 bluetooth::VendorIdSource* output) {
22 switch (input) { 23 switch (input) {
23 case BluetoothDevice::VENDOR_ID_UNKNOWN: 24 case BluetoothDevice::VENDOR_ID_UNKNOWN:
24 *output = bluetooth::VENDOR_ID_SOURCE_NONE; 25 *output = bluetooth::VENDOR_ID_SOURCE_NONE;
25 return true; 26 return true;
26 case BluetoothDevice::VENDOR_ID_BLUETOOTH: 27 case BluetoothDevice::VENDOR_ID_BLUETOOTH:
27 *output = bluetooth::VENDOR_ID_SOURCE_BLUETOOTH; 28 *output = bluetooth::VENDOR_ID_SOURCE_BLUETOOTH;
28 return true; 29 return true;
29 case BluetoothDevice::VENDOR_ID_USB: 30 case BluetoothDevice::VENDOR_ID_USB:
30 *output = bluetooth::VENDOR_ID_SOURCE_USB; 31 *output = bluetooth::VENDOR_ID_SOURCE_USB;
31 return true; 32 return true;
32 default: 33 default:
33 NOTREACHED(); 34 NOTREACHED();
34 return false; 35 return false;
35 } 36 }
36 } 37 }
37 38
38 bool ConvertDeviceTypeToApi(const BluetoothDevice::DeviceType& input, 39 bool ConvertDeviceTypeToApi(const BluetoothDeviceType& input,
39 bluetooth::DeviceType* output) { 40 bluetooth::DeviceType* output) {
40 switch (input) { 41 switch (input) {
41 case BluetoothDevice::DEVICE_UNKNOWN: 42 case BluetoothDeviceType::UNKNOWN:
42 *output = bluetooth::DEVICE_TYPE_NONE; 43 *output = bluetooth::DEVICE_TYPE_NONE;
43 return true; 44 return true;
44 case BluetoothDevice::DEVICE_COMPUTER: 45 case BluetoothDeviceType::COMPUTER:
45 *output = bluetooth::DEVICE_TYPE_COMPUTER; 46 *output = bluetooth::DEVICE_TYPE_COMPUTER;
46 return true; 47 return true;
47 case BluetoothDevice::DEVICE_PHONE: 48 case BluetoothDeviceType::PHONE:
48 *output = bluetooth::DEVICE_TYPE_PHONE; 49 *output = bluetooth::DEVICE_TYPE_PHONE;
49 return true; 50 return true;
50 case BluetoothDevice::DEVICE_MODEM: 51 case BluetoothDeviceType::MODEM:
51 *output = bluetooth::DEVICE_TYPE_MODEM; 52 *output = bluetooth::DEVICE_TYPE_MODEM;
52 return true; 53 return true;
53 case BluetoothDevice::DEVICE_AUDIO: 54 case BluetoothDeviceType::AUDIO:
54 *output = bluetooth::DEVICE_TYPE_AUDIO; 55 *output = bluetooth::DEVICE_TYPE_AUDIO;
55 return true; 56 return true;
56 case BluetoothDevice::DEVICE_CAR_AUDIO: 57 case BluetoothDeviceType::CAR_AUDIO:
57 *output = bluetooth::DEVICE_TYPE_CARAUDIO; 58 *output = bluetooth::DEVICE_TYPE_CARAUDIO;
58 return true; 59 return true;
59 case BluetoothDevice::DEVICE_VIDEO: 60 case BluetoothDeviceType::VIDEO:
60 *output = bluetooth::DEVICE_TYPE_VIDEO; 61 *output = bluetooth::DEVICE_TYPE_VIDEO;
61 return true; 62 return true;
62 case BluetoothDevice::DEVICE_PERIPHERAL: 63 case BluetoothDeviceType::PERIPHERAL:
63 *output = bluetooth::DEVICE_TYPE_PERIPHERAL; 64 *output = bluetooth::DEVICE_TYPE_PERIPHERAL;
64 return true; 65 return true;
65 case BluetoothDevice::DEVICE_JOYSTICK: 66 case BluetoothDeviceType::JOYSTICK:
66 *output = bluetooth::DEVICE_TYPE_JOYSTICK; 67 *output = bluetooth::DEVICE_TYPE_JOYSTICK;
67 return true; 68 return true;
68 case BluetoothDevice::DEVICE_GAMEPAD: 69 case BluetoothDeviceType::GAMEPAD:
69 *output = bluetooth::DEVICE_TYPE_GAMEPAD; 70 *output = bluetooth::DEVICE_TYPE_GAMEPAD;
70 return true; 71 return true;
71 case BluetoothDevice::DEVICE_KEYBOARD: 72 case BluetoothDeviceType::KEYBOARD:
72 *output = bluetooth::DEVICE_TYPE_KEYBOARD; 73 *output = bluetooth::DEVICE_TYPE_KEYBOARD;
73 return true; 74 return true;
74 case BluetoothDevice::DEVICE_MOUSE: 75 case BluetoothDeviceType::MOUSE:
75 *output = bluetooth::DEVICE_TYPE_MOUSE; 76 *output = bluetooth::DEVICE_TYPE_MOUSE;
76 return true; 77 return true;
77 case BluetoothDevice::DEVICE_TABLET: 78 case BluetoothDeviceType::TABLET:
78 *output = bluetooth::DEVICE_TYPE_TABLET; 79 *output = bluetooth::DEVICE_TYPE_TABLET;
79 return true; 80 return true;
80 case BluetoothDevice::DEVICE_KEYBOARD_MOUSE_COMBO: 81 case BluetoothDeviceType::KEYBOARD_MOUSE_COMBO:
81 *output = bluetooth::DEVICE_TYPE_KEYBOARDMOUSECOMBO; 82 *output = bluetooth::DEVICE_TYPE_KEYBOARDMOUSECOMBO;
82 return true; 83 return true;
83 default: 84 default:
84 return false; 85 return false;
85 } 86 }
86 } 87 }
87 88
88 } // namespace 89 } // namespace
89 90
90 namespace extensions { 91 namespace extensions {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 out->discovering = adapter.IsDiscovering(); 139 out->discovering = adapter.IsDiscovering();
139 out->available = adapter.IsPresent(); 140 out->available = adapter.IsPresent();
140 out->powered = adapter.IsPowered(); 141 out->powered = adapter.IsPowered();
141 out->name = adapter.GetName(); 142 out->name = adapter.GetName();
142 out->address = adapter.GetAddress(); 143 out->address = adapter.GetAddress();
143 } 144 }
144 145
145 } // namespace bluetooth 146 } // namespace bluetooth
146 } // namespace api 147 } // namespace api
147 } // namespace extensions 148 } // namespace extensions
OLDNEW
« no previous file with comments | « device/bluetooth/test/mock_bluetooth_device.cc ('k') | extensions/browser/api/bluetooth/bluetooth_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698