OLD | NEW |
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 #ifndef CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "chrome/browser/extensions/api/api_function.h" | 10 #include "chrome/browser/extensions/api/api_function.h" |
11 #include "chrome/browser/extensions/extension_function.h" | 11 #include "chrome/browser/extensions/extension_function.h" |
12 | 12 |
13 #if defined(OS_CHROMEOS) | 13 #if defined(OS_CHROMEOS) |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "chrome/browser/chromeos/bluetooth/bluetooth_device.h" | 15 #include "device/bluetooth/bluetooth_device.h" |
16 #include "chrome/browser/chromeos/bluetooth/bluetooth_socket.h" | 16 #include "device/bluetooth/bluetooth_socket.h" |
17 | 17 |
18 namespace chromeos { | 18 namespace device_bluetooth { |
19 | 19 |
20 class BluetoothSocket; | 20 class BluetoothSocket; |
21 struct BluetoothOutOfBandPairingData; | 21 struct BluetoothOutOfBandPairingData; |
22 | 22 |
23 } // namespace chromeos | 23 } // namespace device_bluetooth |
24 #endif | 24 #endif |
25 | 25 |
26 namespace extensions { | 26 namespace extensions { |
27 namespace api { | 27 namespace api { |
28 | 28 |
29 class BluetoothIsAvailableFunction : public SyncExtensionFunction { | 29 class BluetoothIsAvailableFunction : public SyncExtensionFunction { |
30 public: | 30 public: |
31 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.isAvailable") | 31 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.isAvailable") |
32 | 32 |
33 protected: | 33 protected: |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 #endif | 79 #endif |
80 | 80 |
81 protected: | 81 protected: |
82 virtual ~BluetoothGetDevicesFunction() {} | 82 virtual ~BluetoothGetDevicesFunction() {} |
83 | 83 |
84 // ExtensionFunction: | 84 // ExtensionFunction: |
85 virtual bool RunImpl() OVERRIDE; | 85 virtual bool RunImpl() OVERRIDE; |
86 | 86 |
87 private: | 87 private: |
88 #if defined(OS_CHROMEOS) | 88 #if defined(OS_CHROMEOS) |
89 void DispatchDeviceSearchResult(const chromeos::BluetoothDevice& device); | 89 void DispatchDeviceSearchResult( |
90 void ProvidesServiceCallback(const chromeos::BluetoothDevice* device, | 90 const device_bluetooth::BluetoothDevice& device); |
| 91 void ProvidesServiceCallback(const device_bluetooth::BluetoothDevice* device, |
91 bool providesService); | 92 bool providesService); |
92 | 93 |
93 int callbacks_pending_; | 94 int callbacks_pending_; |
94 #endif | 95 #endif |
95 }; | 96 }; |
96 | 97 |
97 class BluetoothGetServicesFunction : public AsyncExtensionFunction { | 98 class BluetoothGetServicesFunction : public AsyncExtensionFunction { |
98 public: | 99 public: |
99 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.getServices") | 100 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.getServices") |
100 | 101 |
101 protected: | 102 protected: |
102 virtual ~BluetoothGetServicesFunction() {} | 103 virtual ~BluetoothGetServicesFunction() {} |
103 | 104 |
104 // ExtensionFunction: | 105 // ExtensionFunction: |
105 virtual bool RunImpl() OVERRIDE; | 106 virtual bool RunImpl() OVERRIDE; |
106 | 107 |
107 #if defined(OS_CHROMEOS) | 108 #if defined(OS_CHROMEOS) |
108 private: | 109 private: |
109 void GetServiceRecordsCallback( | 110 void GetServiceRecordsCallback( |
110 base::ListValue* services, | 111 base::ListValue* services, |
111 const chromeos::BluetoothDevice::ServiceRecordList& records); | 112 const device_bluetooth::BluetoothDevice::ServiceRecordList& records); |
112 void OnErrorCallback(); | 113 void OnErrorCallback(); |
113 #endif | 114 #endif |
114 }; | 115 }; |
115 | 116 |
116 class BluetoothConnectFunction : public AsyncExtensionFunction { | 117 class BluetoothConnectFunction : public AsyncExtensionFunction { |
117 public: | 118 public: |
118 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.connect") | 119 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.connect") |
119 | 120 |
120 protected: | 121 protected: |
121 virtual ~BluetoothConnectFunction() {} | 122 virtual ~BluetoothConnectFunction() {} |
122 | 123 |
123 virtual bool RunImpl() OVERRIDE; | 124 virtual bool RunImpl() OVERRIDE; |
124 | 125 |
125 private: | 126 private: |
126 #if defined(OS_CHROMEOS) | 127 #if defined(OS_CHROMEOS) |
127 void ConnectToServiceCallback( | 128 void ConnectToServiceCallback( |
128 const chromeos::BluetoothDevice* device, | 129 const device_bluetooth::BluetoothDevice* device, |
129 const std::string& service_uuid, | 130 const std::string& service_uuid, |
130 scoped_refptr<chromeos::BluetoothSocket> socket); | 131 scoped_refptr<device_bluetooth::BluetoothSocket> socket); |
131 #endif | 132 #endif |
132 }; | 133 }; |
133 | 134 |
134 class BluetoothDisconnectFunction : public SyncExtensionFunction { | 135 class BluetoothDisconnectFunction : public SyncExtensionFunction { |
135 public: | 136 public: |
136 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.disconnect") | 137 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.disconnect") |
137 | 138 |
138 protected: | 139 protected: |
139 virtual ~BluetoothDisconnectFunction() {} | 140 virtual ~BluetoothDisconnectFunction() {} |
140 | 141 |
(...skipping 10 matching lines...) Expand all Loading... |
151 virtual ~BluetoothReadFunction(); | 152 virtual ~BluetoothReadFunction(); |
152 | 153 |
153 // AsyncApiFunction: | 154 // AsyncApiFunction: |
154 virtual bool Prepare() OVERRIDE; | 155 virtual bool Prepare() OVERRIDE; |
155 virtual bool Respond() OVERRIDE; | 156 virtual bool Respond() OVERRIDE; |
156 virtual void Work() OVERRIDE; | 157 virtual void Work() OVERRIDE; |
157 | 158 |
158 private: | 159 private: |
159 #if defined(OS_CHROMEOS) | 160 #if defined(OS_CHROMEOS) |
160 bool success_; | 161 bool success_; |
161 scoped_refptr<chromeos::BluetoothSocket> socket_; | 162 scoped_refptr<device_bluetooth::BluetoothSocket> socket_; |
162 #endif | 163 #endif |
163 }; | 164 }; |
164 | 165 |
165 class BluetoothWriteFunction : public AsyncApiFunction { | 166 class BluetoothWriteFunction : public AsyncApiFunction { |
166 public: | 167 public: |
167 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.write") | 168 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.write") |
168 BluetoothWriteFunction(); | 169 BluetoothWriteFunction(); |
169 | 170 |
170 protected: | 171 protected: |
171 virtual ~BluetoothWriteFunction(); | 172 virtual ~BluetoothWriteFunction(); |
172 | 173 |
173 // AsyncApiFunction: | 174 // AsyncApiFunction: |
174 virtual bool Prepare() OVERRIDE; | 175 virtual bool Prepare() OVERRIDE; |
175 virtual bool Respond() OVERRIDE; | 176 virtual bool Respond() OVERRIDE; |
176 virtual void Work() OVERRIDE; | 177 virtual void Work() OVERRIDE; |
177 | 178 |
178 private: | 179 private: |
179 #if defined(OS_CHROMEOS) | 180 #if defined(OS_CHROMEOS) |
180 bool success_; | 181 bool success_; |
181 const base::BinaryValue* data_to_write_; // memory is owned by args_ | 182 const base::BinaryValue* data_to_write_; // memory is owned by args_ |
182 scoped_refptr<chromeos::BluetoothSocket> socket_; | 183 scoped_refptr<device_bluetooth::BluetoothSocket> socket_; |
183 #endif | 184 #endif |
184 }; | 185 }; |
185 | 186 |
186 class BluetoothSetOutOfBandPairingDataFunction | 187 class BluetoothSetOutOfBandPairingDataFunction |
187 : public AsyncExtensionFunction { | 188 : public AsyncExtensionFunction { |
188 public: | 189 public: |
189 DECLARE_EXTENSION_FUNCTION_NAME( | 190 DECLARE_EXTENSION_FUNCTION_NAME( |
190 "experimental.bluetooth.setOutOfBandPairingData") | 191 "experimental.bluetooth.setOutOfBandPairingData") |
191 | 192 |
192 protected: | 193 protected: |
(...skipping 11 matching lines...) Expand all Loading... |
204 class BluetoothGetLocalOutOfBandPairingDataFunction | 205 class BluetoothGetLocalOutOfBandPairingDataFunction |
205 : public AsyncExtensionFunction { | 206 : public AsyncExtensionFunction { |
206 public: | 207 public: |
207 DECLARE_EXTENSION_FUNCTION_NAME( | 208 DECLARE_EXTENSION_FUNCTION_NAME( |
208 "experimental.bluetooth.getLocalOutOfBandPairingData") | 209 "experimental.bluetooth.getLocalOutOfBandPairingData") |
209 | 210 |
210 protected: | 211 protected: |
211 virtual ~BluetoothGetLocalOutOfBandPairingDataFunction() {} | 212 virtual ~BluetoothGetLocalOutOfBandPairingDataFunction() {} |
212 | 213 |
213 #if defined(OS_CHROMEOS) | 214 #if defined(OS_CHROMEOS) |
214 void ReadCallback(const chromeos::BluetoothOutOfBandPairingData& data); | 215 void ReadCallback( |
| 216 const device_bluetooth::BluetoothOutOfBandPairingData& data); |
215 void ErrorCallback(); | 217 void ErrorCallback(); |
216 #endif | 218 #endif |
217 | 219 |
218 // ExtensionFunction: | 220 // ExtensionFunction: |
219 virtual bool RunImpl() OVERRIDE; | 221 virtual bool RunImpl() OVERRIDE; |
220 }; | 222 }; |
221 | 223 |
222 class BluetoothStartDiscoveryFunction : public AsyncExtensionFunction { | 224 class BluetoothStartDiscoveryFunction : public AsyncExtensionFunction { |
223 public: | 225 public: |
224 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.startDiscovery") | 226 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.startDiscovery") |
(...skipping 25 matching lines...) Expand all Loading... |
250 private: | 252 private: |
251 void OnSuccessCallback(); | 253 void OnSuccessCallback(); |
252 void OnErrorCallback(); | 254 void OnErrorCallback(); |
253 #endif | 255 #endif |
254 }; | 256 }; |
255 | 257 |
256 } // namespace api | 258 } // namespace api |
257 } // namespace extensions | 259 } // namespace extensions |
258 | 260 |
259 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_ | 261 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_ |
OLD | NEW |