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