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 "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api_socket.h" |
12 #include "chrome/browser/extensions/api/bluetooth/bluetooth_extension_function.h
" | 13 #include "chrome/browser/extensions/api/bluetooth/bluetooth_extension_function.h
" |
| 14 #include "chrome/common/extensions/api/bluetooth.h" |
13 #include "device/bluetooth/bluetooth_device.h" | 15 #include "device/bluetooth/bluetooth_device.h" |
14 #include "device/bluetooth/bluetooth_profile.h" | 16 #include "device/bluetooth/bluetooth_profile.h" |
| 17 #include "device/bluetooth/bluetooth_socket.h" |
| 18 #include "extensions/browser/api/api_resource_manager.h" |
15 #include "extensions/browser/api/async_api_function.h" | 19 #include "extensions/browser/api/async_api_function.h" |
16 #include "extensions/browser/browser_context_keyed_api_factory.h" | 20 #include "extensions/browser/browser_context_keyed_api_factory.h" |
17 #include "extensions/browser/event_router.h" | 21 #include "extensions/browser/event_router.h" |
18 #include "extensions/browser/extension_function.h" | 22 #include "extensions/browser/extension_function.h" |
19 | 23 |
20 namespace content { | 24 namespace content { |
21 class BrowserContext; | 25 class BrowserContext; |
22 } | 26 } |
23 | 27 |
24 namespace device { | 28 namespace device { |
| 29 class BluetoothAdapter; |
| 30 struct BluetoothOutOfBandPairingData; |
| 31 } |
25 | 32 |
26 class BluetoothAdapter; | 33 namespace net { |
27 class BluetoothDevice; | 34 class IOBuffer; |
28 class BluetoothSocket; | 35 } |
29 struct BluetoothOutOfBandPairingData; | |
30 | |
31 } // namespace device | |
32 | 36 |
33 namespace extensions { | 37 namespace extensions { |
34 | 38 |
35 class ExtensionBluetoothEventRouter; | 39 class ExtensionBluetoothEventRouter; |
36 | 40 |
37 // The profile-keyed service that manages the bluetooth extension API. | 41 // The profile-keyed service that manages the bluetooth extension API. |
| 42 // All methods of this class must be called on the UI thread. |
| 43 // TODO(rpaquay): Rename this and move to separate file. |
38 class BluetoothAPI : public BrowserContextKeyedAPI, | 44 class BluetoothAPI : public BrowserContextKeyedAPI, |
39 public EventRouter::Observer { | 45 public EventRouter::Observer { |
40 public: | 46 public: |
41 // Convenience method to get the BluetoothAPI for a profile. | 47 typedef ApiResourceManager<BluetoothApiSocket>::ApiResourceData SocketData; |
| 48 |
| 49 struct ConnectionParams { |
| 50 ConnectionParams(); |
| 51 ~ConnectionParams(); |
| 52 |
| 53 content::BrowserThread::ID thread_id; |
| 54 void* browser_context_id; |
| 55 std::string extension_id; |
| 56 std::string device_address; |
| 57 std::string uuid; |
| 58 scoped_refptr<device::BluetoothSocket> socket; |
| 59 scoped_refptr<SocketData> socket_data; |
| 60 }; |
| 61 |
| 62 // Convenience method to get the BluetoothAPI for a browser context. |
42 static BluetoothAPI* Get(content::BrowserContext* context); | 63 static BluetoothAPI* Get(content::BrowserContext* context); |
43 | 64 |
44 static BrowserContextKeyedAPIFactory<BluetoothAPI>* GetFactoryInstance(); | 65 static BrowserContextKeyedAPIFactory<BluetoothAPI>* GetFactoryInstance(); |
45 | 66 |
46 explicit BluetoothAPI(content::BrowserContext* context); | 67 explicit BluetoothAPI(content::BrowserContext* context); |
47 virtual ~BluetoothAPI(); | 68 virtual ~BluetoothAPI(); |
48 | 69 |
49 ExtensionBluetoothEventRouter* bluetooth_event_router(); | 70 ExtensionBluetoothEventRouter* event_router(); |
| 71 scoped_refptr<SocketData> socket_data(); |
| 72 scoped_refptr<api::BluetoothSocketEventDispatcher> socket_event_dispatcher(); |
50 | 73 |
51 // KeyedService implementation. | 74 // KeyedService implementation. |
52 virtual void Shutdown() OVERRIDE; | 75 virtual void Shutdown() OVERRIDE; |
53 | 76 |
54 // EventRouter::Observer implementation. | 77 // EventRouter::Observer implementation. |
55 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE; | 78 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE; |
56 virtual void OnListenerRemoved(const EventListenerInfo& details) OVERRIDE; | 79 virtual void OnListenerRemoved(const EventListenerInfo& details) OVERRIDE; |
57 | 80 |
| 81 // Dispatch an event that takes a connection socket as a parameter to the |
| 82 // extension that registered the profile that the socket has connected to. |
| 83 void DispatchConnectionEvent(const std::string& extension_id, |
| 84 const std::string& profile_uuid, |
| 85 const device::BluetoothDevice* device, |
| 86 scoped_refptr<device::BluetoothSocket> socket); |
| 87 |
58 private: | 88 private: |
59 friend class BrowserContextKeyedAPIFactory<BluetoothAPI>; | 89 static void RegisterSocket(const ConnectionParams& params); |
| 90 static void RegisterSocketUI(const ConnectionParams& params, int socket_id); |
| 91 static void RegisterSocketWithAdapterUI( |
| 92 const ConnectionParams& params, |
| 93 int socket_id, |
| 94 scoped_refptr<device::BluetoothAdapter> adapter); |
60 | 95 |
61 // BrowserContextKeyedAPI implementation. | 96 // BrowserContextKeyedAPI implementation. |
| 97 friend class BrowserContextKeyedAPIFactory<BluetoothAPI>; |
62 static const char* service_name() { return "BluetoothAPI"; } | 98 static const char* service_name() { return "BluetoothAPI"; } |
63 static const bool kServiceRedirectedInIncognito = true; | 99 static const bool kServiceRedirectedInIncognito = true; |
64 static const bool kServiceIsNULLWhileTesting = true; | 100 static const bool kServiceIsNULLWhileTesting = true; |
65 | 101 |
66 content::BrowserContext* browser_context_; | 102 content::BrowserContext* browser_context_; |
67 | 103 |
68 // Created lazily on first access. | 104 // Created lazily on first access. |
69 scoped_ptr<ExtensionBluetoothEventRouter> bluetooth_event_router_; | 105 scoped_ptr<ExtensionBluetoothEventRouter> event_router_; |
| 106 scoped_refptr<SocketData> socket_data_; |
| 107 scoped_refptr<api::BluetoothSocketEventDispatcher> socket_event_dispatcher_; |
70 }; | 108 }; |
71 | 109 |
72 namespace api { | 110 namespace api { |
73 | 111 |
| 112 class BluetoothSocketEventDispatcher; |
| 113 |
| 114 // Base class for methods dealing with BluetoothSocketApi and |
| 115 // ApiResourceManager<BluetoothSocketApi>. |
| 116 class BluetoothSocketApiFunction : public UIThreadExtensionFunction { |
| 117 public: |
| 118 BluetoothSocketApiFunction(); |
| 119 |
| 120 protected: |
| 121 virtual ~BluetoothSocketApiFunction(); |
| 122 |
| 123 // ExtensionFunction::RunImpl() |
| 124 virtual bool RunImpl() OVERRIDE; |
| 125 |
| 126 bool PrePrepare(); |
| 127 bool Respond(); |
| 128 void AsyncWorkCompleted(); |
| 129 |
| 130 virtual bool Prepare() = 0; |
| 131 virtual void Work(); |
| 132 virtual void AsyncWorkStart(); |
| 133 |
| 134 content::BrowserThread::ID work_thread_id() const { |
| 135 return BluetoothApiSocket::kThreadId; |
| 136 } |
| 137 |
| 138 scoped_refptr<BluetoothAPI::SocketData> socket_data_; |
| 139 scoped_refptr<api::BluetoothSocketEventDispatcher> socket_event_dispatcher_; |
| 140 }; |
| 141 |
| 142 class BluetoothGetAdapterStateFunction : public BluetoothExtensionFunction { |
| 143 public: |
| 144 DECLARE_EXTENSION_FUNCTION("bluetooth.getAdapterState", |
| 145 BLUETOOTH_GETADAPTERSTATE) |
| 146 |
| 147 protected: |
| 148 virtual ~BluetoothGetAdapterStateFunction(); |
| 149 |
| 150 // BluetoothExtensionFunction: |
| 151 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE; |
| 152 }; |
| 153 |
| 154 class BluetoothGetDevicesFunction : public BluetoothExtensionFunction { |
| 155 public: |
| 156 DECLARE_EXTENSION_FUNCTION("bluetooth.getDevices", BLUETOOTH_GETDEVICES) |
| 157 |
| 158 protected: |
| 159 virtual ~BluetoothGetDevicesFunction(); |
| 160 |
| 161 // BluetoothExtensionFunction: |
| 162 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE; |
| 163 }; |
| 164 |
| 165 class BluetoothGetDeviceFunction : public BluetoothExtensionFunction { |
| 166 public: |
| 167 DECLARE_EXTENSION_FUNCTION("bluetooth.getDevice", BLUETOOTH_GETDEVICE) |
| 168 |
| 169 // BluetoothExtensionFunction: |
| 170 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE; |
| 171 |
| 172 protected: |
| 173 virtual ~BluetoothGetDeviceFunction(); |
| 174 }; |
| 175 |
74 class BluetoothAddProfileFunction : public UIThreadExtensionFunction { | 176 class BluetoothAddProfileFunction : public UIThreadExtensionFunction { |
75 public: | 177 public: |
76 DECLARE_EXTENSION_FUNCTION("bluetooth.addProfile", BLUETOOTH_ADDPROFILE) | 178 DECLARE_EXTENSION_FUNCTION("bluetooth.addProfile", BLUETOOTH_ADDPROFILE) |
77 | 179 |
78 BluetoothAddProfileFunction(); | 180 BluetoothAddProfileFunction(); |
79 | 181 |
80 protected: | 182 protected: |
81 virtual ~BluetoothAddProfileFunction() {} | 183 virtual ~BluetoothAddProfileFunction(); |
82 virtual bool RunImpl() OVERRIDE; | 184 virtual bool RunImpl() OVERRIDE; |
83 | 185 |
84 virtual void RegisterProfile( | 186 virtual void RegisterProfile( |
85 const device::BluetoothProfile::Options& options, | 187 const device::BluetoothProfile::Options& options, |
86 const device::BluetoothProfile::ProfileCallback& callback); | 188 const device::BluetoothProfile::ProfileCallback& callback); |
87 | 189 |
88 private: | 190 private: |
89 void OnProfileRegistered(device::BluetoothProfile* bluetooth_profile); | 191 void OnProfileRegistered(device::BluetoothProfile* bluetooth_profile); |
90 | 192 |
91 std::string uuid_; | 193 std::string uuid_; |
92 }; | 194 }; |
93 | 195 |
94 class BluetoothRemoveProfileFunction : public SyncExtensionFunction { | 196 class BluetoothRemoveProfileFunction : public SyncExtensionFunction { |
95 public: | 197 public: |
96 DECLARE_EXTENSION_FUNCTION("bluetooth.removeProfile", | 198 DECLARE_EXTENSION_FUNCTION("bluetooth.removeProfile", |
97 BLUETOOTH_REMOVEPROFILE) | 199 BLUETOOTH_REMOVEPROFILE) |
98 | 200 |
99 protected: | 201 protected: |
100 virtual ~BluetoothRemoveProfileFunction() {} | 202 virtual ~BluetoothRemoveProfileFunction(); |
101 virtual bool RunImpl() OVERRIDE; | 203 virtual bool RunImpl() OVERRIDE; |
102 }; | 204 }; |
103 | 205 |
104 class BluetoothGetAdapterStateFunction : public BluetoothExtensionFunction { | 206 class BluetoothGetProfilesFunction : public BluetoothExtensionFunction { |
105 public: | 207 public: |
106 DECLARE_EXTENSION_FUNCTION("bluetooth.getAdapterState", | 208 DECLARE_EXTENSION_FUNCTION("bluetooth.getProfiles", BLUETOOTH_GETPROFILES) |
107 BLUETOOTH_GETADAPTERSTATE) | |
108 | 209 |
109 protected: | 210 protected: |
110 virtual ~BluetoothGetAdapterStateFunction() {} | 211 virtual ~BluetoothGetProfilesFunction() {} |
111 | |
112 // BluetoothExtensionFunction: | |
113 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE; | |
114 }; | |
115 | |
116 class BluetoothGetDevicesFunction : public BluetoothExtensionFunction { | |
117 public: | |
118 DECLARE_EXTENSION_FUNCTION("bluetooth.getDevices", BLUETOOTH_GETDEVICES) | |
119 | |
120 protected: | |
121 virtual ~BluetoothGetDevicesFunction() {} | |
122 | |
123 // BluetoothExtensionFunction: | |
124 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE; | |
125 }; | |
126 | |
127 class BluetoothGetDeviceFunction : public BluetoothExtensionFunction { | |
128 public: | |
129 DECLARE_EXTENSION_FUNCTION("bluetooth.getDevice", BLUETOOTH_GETDEVICE) | |
130 | |
131 protected: | |
132 virtual ~BluetoothGetDeviceFunction() {} | |
133 | 212 |
134 // BluetoothExtensionFunction: | 213 // BluetoothExtensionFunction: |
135 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE; | 214 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE; |
136 }; | 215 }; |
137 | 216 |
138 class BluetoothConnectFunction : public BluetoothExtensionFunction { | 217 class BluetoothConnectFunction : public BluetoothExtensionFunction { |
139 public: | 218 public: |
140 DECLARE_EXTENSION_FUNCTION("bluetooth.connect", BLUETOOTH_CONNECT) | 219 DECLARE_EXTENSION_FUNCTION("bluetooth.connect", BLUETOOTH_CONNECT) |
141 | 220 |
142 protected: | 221 protected: |
143 virtual ~BluetoothConnectFunction() {} | 222 virtual ~BluetoothConnectFunction(); |
144 | 223 |
145 // BluetoothExtensionFunction: | 224 // BluetoothExtensionFunction: |
146 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE; | 225 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE; |
147 | 226 |
148 private: | 227 private: |
149 void OnSuccessCallback(); | 228 void OnSuccessCallback(); |
150 void OnErrorCallback(); | 229 void OnErrorCallback(const std::string& error); |
151 }; | 230 }; |
152 | 231 |
153 class BluetoothDisconnectFunction : public SyncExtensionFunction { | 232 class BluetoothDisconnectFunction : public BluetoothSocketApiFunction { |
154 public: | 233 public: |
155 DECLARE_EXTENSION_FUNCTION("bluetooth.disconnect", BLUETOOTH_DISCONNECT) | 234 DECLARE_EXTENSION_FUNCTION("bluetooth.disconnect", BLUETOOTH_DISCONNECT) |
| 235 BluetoothDisconnectFunction(); |
156 | 236 |
157 protected: | 237 protected: |
158 virtual ~BluetoothDisconnectFunction() {} | 238 virtual ~BluetoothDisconnectFunction(); |
159 | |
160 // ExtensionFunction: | |
161 virtual bool RunImpl() OVERRIDE; | |
162 }; | |
163 | |
164 class BluetoothReadFunction : public AsyncApiFunction { | |
165 public: | |
166 DECLARE_EXTENSION_FUNCTION("bluetooth.read", BLUETOOTH_READ) | |
167 BluetoothReadFunction(); | |
168 | |
169 protected: | |
170 virtual ~BluetoothReadFunction(); | |
171 | 239 |
172 // AsyncApiFunction: | 240 // AsyncApiFunction: |
173 virtual bool Prepare() OVERRIDE; | 241 virtual bool Prepare() OVERRIDE; |
174 virtual bool Respond() OVERRIDE; | 242 virtual void AsyncWorkStart() OVERRIDE; |
| 243 |
| 244 private: |
| 245 void OnSuccess(); |
| 246 |
| 247 scoped_ptr<bluetooth::Disconnect::Params> params_; |
| 248 }; |
| 249 |
| 250 class BluetoothSendFunction : public BluetoothSocketApiFunction { |
| 251 public: |
| 252 DECLARE_EXTENSION_FUNCTION("bluetooth.send", BLUETOOTH_SEND) |
| 253 BluetoothSendFunction(); |
| 254 |
| 255 protected: |
| 256 virtual ~BluetoothSendFunction(); |
| 257 |
| 258 // AsyncApiFunction: |
| 259 virtual bool Prepare() OVERRIDE; |
| 260 virtual void AsyncWorkStart() OVERRIDE; |
| 261 |
| 262 private: |
| 263 void OnSendSuccess(int bytes_sent); |
| 264 void OnSendError(const std::string& message); |
| 265 |
| 266 scoped_ptr<bluetooth::Send::Params> params_; |
| 267 scoped_refptr<net::IOBuffer> io_buffer_; |
| 268 size_t io_buffer_size_; |
| 269 }; |
| 270 |
| 271 class BluetoothUpdateSocketFunction : public BluetoothSocketApiFunction { |
| 272 public: |
| 273 DECLARE_EXTENSION_FUNCTION("bluetooth.updateSocket", BLUETOOTH_UPDATE_SOCKET) |
| 274 BluetoothUpdateSocketFunction(); |
| 275 |
| 276 protected: |
| 277 virtual ~BluetoothUpdateSocketFunction(); |
| 278 |
| 279 // AsyncApiFunction: |
| 280 virtual bool Prepare() OVERRIDE; |
175 virtual void Work() OVERRIDE; | 281 virtual void Work() OVERRIDE; |
176 | 282 |
177 private: | 283 private: |
178 bool success_; | 284 scoped_ptr<bluetooth::UpdateSocket::Params> params_; |
179 scoped_refptr<device::BluetoothSocket> socket_; | |
180 }; | 285 }; |
181 | 286 |
182 class BluetoothWriteFunction : public AsyncApiFunction { | 287 class BluetoothSetSocketPausedFunction : public BluetoothSocketApiFunction { |
183 public: | 288 public: |
184 DECLARE_EXTENSION_FUNCTION("bluetooth.write", BLUETOOTH_WRITE) | 289 DECLARE_EXTENSION_FUNCTION("bluetooth.setSocketPaused", |
185 BluetoothWriteFunction(); | 290 BLUETOOTH_SET_SOCKET_PAUSED) |
| 291 BluetoothSetSocketPausedFunction(); |
186 | 292 |
187 protected: | 293 protected: |
188 virtual ~BluetoothWriteFunction(); | 294 virtual ~BluetoothSetSocketPausedFunction(); |
189 | 295 |
190 // AsyncApiFunction: | 296 // AsyncApiFunction: |
191 virtual bool Prepare() OVERRIDE; | 297 virtual bool Prepare() OVERRIDE; |
192 virtual bool Respond() OVERRIDE; | |
193 virtual void Work() OVERRIDE; | 298 virtual void Work() OVERRIDE; |
194 | 299 |
195 private: | 300 private: |
196 bool success_; | 301 scoped_ptr<bluetooth::SetSocketPaused::Params> params_; |
197 const base::BinaryValue* data_to_write_; // memory is owned by args_ | |
198 scoped_refptr<device::BluetoothSocket> socket_; | |
199 }; | 302 }; |
200 | 303 |
201 class BluetoothSetOutOfBandPairingDataFunction | 304 class BluetoothGetSocketFunction : public BluetoothSocketApiFunction { |
202 : public BluetoothExtensionFunction { | |
203 public: | 305 public: |
204 DECLARE_EXTENSION_FUNCTION("bluetooth.setOutOfBandPairingData", | 306 DECLARE_EXTENSION_FUNCTION("bluetooth.getSocket", BLUETOOTH_GET_SOCKET) |
205 BLUETOOTH_SETOUTOFBANDPAIRINGDATA) | 307 |
| 308 BluetoothGetSocketFunction(); |
206 | 309 |
207 protected: | 310 protected: |
208 virtual ~BluetoothSetOutOfBandPairingDataFunction() {} | 311 virtual ~BluetoothGetSocketFunction(); |
209 | 312 |
210 void OnSuccessCallback(); | 313 // AsyncApiFunction: |
211 void OnErrorCallback(); | 314 virtual bool Prepare() OVERRIDE; |
| 315 virtual void Work() OVERRIDE; |
212 | 316 |
213 // BluetoothExtensionFunction: | 317 private: |
214 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE; | 318 scoped_ptr<bluetooth::GetSocket::Params> params_; |
| 319 }; |
| 320 |
| 321 class BluetoothGetSocketsFunction : public BluetoothSocketApiFunction { |
| 322 public: |
| 323 DECLARE_EXTENSION_FUNCTION("bluetooth.getSockets", BLUETOOTH_GET_SOCKETS) |
| 324 |
| 325 BluetoothGetSocketsFunction(); |
| 326 |
| 327 protected: |
| 328 virtual ~BluetoothGetSocketsFunction(); |
| 329 |
| 330 // AsyncApiFunction: |
| 331 virtual bool Prepare() OVERRIDE; |
| 332 virtual void Work() OVERRIDE; |
215 }; | 333 }; |
216 | 334 |
217 class BluetoothGetLocalOutOfBandPairingDataFunction | 335 class BluetoothGetLocalOutOfBandPairingDataFunction |
218 : public BluetoothExtensionFunction { | 336 : public BluetoothExtensionFunction { |
219 public: | 337 public: |
220 DECLARE_EXTENSION_FUNCTION("bluetooth.getLocalOutOfBandPairingData", | 338 DECLARE_EXTENSION_FUNCTION("bluetooth.getLocalOutOfBandPairingData", |
221 BLUETOOTH_GETLOCALOUTOFBANDPAIRINGDATA) | 339 BLUETOOTH_GETLOCALOUTOFBANDPAIRINGDATA) |
222 | 340 |
223 protected: | 341 protected: |
224 virtual ~BluetoothGetLocalOutOfBandPairingDataFunction() {} | 342 virtual ~BluetoothGetLocalOutOfBandPairingDataFunction() {} |
225 | 343 |
226 void ReadCallback( | 344 void ReadCallback(const device::BluetoothOutOfBandPairingData& data); |
227 const device::BluetoothOutOfBandPairingData& data); | |
228 void ErrorCallback(); | 345 void ErrorCallback(); |
229 | 346 |
230 // BluetoothExtensionFunction: | 347 // BluetoothExtensionFunction: |
231 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE; | 348 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE; |
232 }; | 349 }; |
233 | 350 |
| 351 class BluetoothSetOutOfBandPairingDataFunction |
| 352 : public BluetoothExtensionFunction { |
| 353 public: |
| 354 DECLARE_EXTENSION_FUNCTION("bluetooth.setOutOfBandPairingData", |
| 355 BLUETOOTH_SETOUTOFBANDPAIRINGDATA) |
| 356 |
| 357 protected: |
| 358 virtual ~BluetoothSetOutOfBandPairingDataFunction() {} |
| 359 |
| 360 void OnSuccessCallback(); |
| 361 void OnErrorCallback(); |
| 362 |
| 363 // BluetoothExtensionFunction: |
| 364 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE; |
| 365 }; |
| 366 |
234 class BluetoothStartDiscoveryFunction : public BluetoothExtensionFunction { | 367 class BluetoothStartDiscoveryFunction : public BluetoothExtensionFunction { |
235 public: | 368 public: |
236 DECLARE_EXTENSION_FUNCTION("bluetooth.startDiscovery", | 369 DECLARE_EXTENSION_FUNCTION("bluetooth.startDiscovery", |
237 BLUETOOTH_STARTDISCOVERY) | 370 BLUETOOTH_STARTDISCOVERY) |
238 | 371 |
239 protected: | 372 protected: |
240 virtual ~BluetoothStartDiscoveryFunction() {} | 373 virtual ~BluetoothStartDiscoveryFunction() {} |
241 | 374 |
242 // BluetoothExtensionFunction: | 375 // BluetoothExtensionFunction: |
243 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE; | 376 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE; |
(...skipping 15 matching lines...) Expand all Loading... |
259 | 392 |
260 private: | 393 private: |
261 void OnSuccessCallback(); | 394 void OnSuccessCallback(); |
262 void OnErrorCallback(); | 395 void OnErrorCallback(); |
263 }; | 396 }; |
264 | 397 |
265 } // namespace api | 398 } // namespace api |
266 } // namespace extensions | 399 } // namespace extensions |
267 | 400 |
268 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_ | 401 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_ |
OLD | NEW |