| 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" | |
| 13 #include "chrome/browser/extensions/api/bluetooth/bluetooth_extension_function.h
" | 12 #include "chrome/browser/extensions/api/bluetooth/bluetooth_extension_function.h
" |
| 14 #include "chrome/common/extensions/api/bluetooth.h" | |
| 15 #include "device/bluetooth/bluetooth_device.h" | 13 #include "device/bluetooth/bluetooth_device.h" |
| 16 #include "device/bluetooth/bluetooth_profile.h" | 14 #include "device/bluetooth/bluetooth_profile.h" |
| 17 #include "device/bluetooth/bluetooth_socket.h" | |
| 18 #include "device/bluetooth/bluetooth_uuid.h" | 15 #include "device/bluetooth/bluetooth_uuid.h" |
| 19 #include "extensions/browser/api/api_resource_manager.h" | |
| 20 #include "extensions/browser/api/async_api_function.h" | 16 #include "extensions/browser/api/async_api_function.h" |
| 21 #include "extensions/browser/browser_context_keyed_api_factory.h" | 17 #include "extensions/browser/browser_context_keyed_api_factory.h" |
| 22 #include "extensions/browser/event_router.h" | 18 #include "extensions/browser/event_router.h" |
| 23 #include "extensions/browser/extension_function.h" | 19 #include "extensions/browser/extension_function.h" |
| 24 | 20 |
| 25 namespace content { | 21 namespace content { |
| 26 class BrowserContext; | 22 class BrowserContext; |
| 27 } | 23 } |
| 28 | 24 |
| 29 namespace device { | 25 namespace device { |
| 26 |
| 30 class BluetoothAdapter; | 27 class BluetoothAdapter; |
| 28 class BluetoothDevice; |
| 29 class BluetoothSocket; |
| 31 struct BluetoothOutOfBandPairingData; | 30 struct BluetoothOutOfBandPairingData; |
| 32 } | |
| 33 | 31 |
| 34 namespace net { | 32 } // namespace device |
| 35 class IOBuffer; | |
| 36 } | |
| 37 | 33 |
| 38 namespace extensions { | 34 namespace extensions { |
| 39 | 35 |
| 40 class BluetoothEventRouter; | 36 class BluetoothEventRouter; |
| 41 | 37 |
| 42 // The profile-keyed service that manages the bluetooth extension API. | 38 // 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. | |
| 45 class BluetoothAPI : public BrowserContextKeyedAPI, | 39 class BluetoothAPI : public BrowserContextKeyedAPI, |
| 46 public EventRouter::Observer { | 40 public EventRouter::Observer { |
| 47 public: | 41 public: |
| 48 typedef ApiResourceManager<BluetoothApiSocket>::ApiResourceData SocketData; | 42 // Convenience method to get the BluetoothAPI for a profile. |
| 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. | |
| 64 static BluetoothAPI* Get(content::BrowserContext* context); | 43 static BluetoothAPI* Get(content::BrowserContext* context); |
| 65 | 44 |
| 66 static BrowserContextKeyedAPIFactory<BluetoothAPI>* GetFactoryInstance(); | 45 static BrowserContextKeyedAPIFactory<BluetoothAPI>* GetFactoryInstance(); |
| 67 | 46 |
| 68 explicit BluetoothAPI(content::BrowserContext* context); | 47 explicit BluetoothAPI(content::BrowserContext* context); |
| 69 virtual ~BluetoothAPI(); | 48 virtual ~BluetoothAPI(); |
| 70 | 49 |
| 71 BluetoothEventRouter* event_router(); | 50 BluetoothEventRouter* bluetooth_event_router(); |
| 72 scoped_refptr<SocketData> socket_data(); | |
| 73 scoped_refptr<api::BluetoothSocketEventDispatcher> socket_event_dispatcher(); | |
| 74 | 51 |
| 75 // KeyedService implementation. | 52 // KeyedService implementation. |
| 76 virtual void Shutdown() OVERRIDE; | 53 virtual void Shutdown() OVERRIDE; |
| 77 | 54 |
| 78 // EventRouter::Observer implementation. | 55 // EventRouter::Observer implementation. |
| 79 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE; | 56 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE; |
| 80 virtual void OnListenerRemoved(const EventListenerInfo& details) OVERRIDE; | 57 virtual void OnListenerRemoved(const EventListenerInfo& details) OVERRIDE; |
| 81 | 58 |
| 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 | |
| 89 private: | 59 private: |
| 90 static void RegisterSocket(const ConnectionParams& params); | 60 friend class BrowserContextKeyedAPIFactory<BluetoothAPI>; |
| 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); | |
| 96 | 61 |
| 97 // BrowserContextKeyedAPI implementation. | 62 // BrowserContextKeyedAPI implementation. |
| 98 friend class BrowserContextKeyedAPIFactory<BluetoothAPI>; | |
| 99 static const char* service_name() { return "BluetoothAPI"; } | 63 static const char* service_name() { return "BluetoothAPI"; } |
| 100 static const bool kServiceRedirectedInIncognito = true; | 64 static const bool kServiceRedirectedInIncognito = true; |
| 101 static const bool kServiceIsNULLWhileTesting = true; | 65 static const bool kServiceIsNULLWhileTesting = true; |
| 102 | 66 |
| 103 content::BrowserContext* browser_context_; | 67 content::BrowserContext* browser_context_; |
| 104 | 68 |
| 105 // Created lazily on first access. | 69 // Created lazily on first access. |
| 106 scoped_ptr<BluetoothEventRouter> event_router_; | 70 scoped_ptr<BluetoothEventRouter> bluetooth_event_router_; |
| 107 scoped_refptr<SocketData> socket_data_; | |
| 108 scoped_refptr<api::BluetoothSocketEventDispatcher> socket_event_dispatcher_; | |
| 109 }; | 71 }; |
| 110 | 72 |
| 111 namespace api { | 73 namespace api { |
| 112 | 74 |
| 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 | |
| 177 class BluetoothAddProfileFunction : public UIThreadExtensionFunction { | 75 class BluetoothAddProfileFunction : public UIThreadExtensionFunction { |
| 178 public: | 76 public: |
| 179 DECLARE_EXTENSION_FUNCTION("bluetooth.addProfile", BLUETOOTH_ADDPROFILE) | 77 DECLARE_EXTENSION_FUNCTION("bluetooth.addProfile", BLUETOOTH_ADDPROFILE) |
| 180 | 78 |
| 181 BluetoothAddProfileFunction(); | 79 BluetoothAddProfileFunction(); |
| 182 | 80 |
| 183 protected: | 81 protected: |
| 184 virtual ~BluetoothAddProfileFunction(); | 82 virtual ~BluetoothAddProfileFunction() {} |
| 185 virtual bool RunImpl() OVERRIDE; | 83 virtual bool RunImpl() OVERRIDE; |
| 186 | 84 |
| 187 virtual void RegisterProfile( | 85 virtual void RegisterProfile( |
| 188 const device::BluetoothProfile::Options& options, | 86 const device::BluetoothProfile::Options& options, |
| 189 const device::BluetoothProfile::ProfileCallback& callback); | 87 const device::BluetoothProfile::ProfileCallback& callback); |
| 190 | 88 |
| 191 private: | 89 private: |
| 192 void OnProfileRegistered(device::BluetoothProfile* bluetooth_profile); | 90 void OnProfileRegistered(device::BluetoothProfile* bluetooth_profile); |
| 193 | 91 |
| 194 device::BluetoothUUID uuid_; | 92 device::BluetoothUUID uuid_; |
| 195 }; | 93 }; |
| 196 | 94 |
| 197 class BluetoothRemoveProfileFunction : public SyncExtensionFunction { | 95 class BluetoothRemoveProfileFunction : public SyncExtensionFunction { |
| 198 public: | 96 public: |
| 199 DECLARE_EXTENSION_FUNCTION("bluetooth.removeProfile", | 97 DECLARE_EXTENSION_FUNCTION("bluetooth.removeProfile", |
| 200 BLUETOOTH_REMOVEPROFILE) | 98 BLUETOOTH_REMOVEPROFILE) |
| 201 | 99 |
| 202 protected: | 100 protected: |
| 203 virtual ~BluetoothRemoveProfileFunction(); | 101 virtual ~BluetoothRemoveProfileFunction() {} |
| 204 virtual bool RunImpl() OVERRIDE; | 102 virtual bool RunImpl() OVERRIDE; |
| 205 }; | 103 }; |
| 206 | 104 |
| 207 class BluetoothGetProfilesFunction : public BluetoothExtensionFunction { | 105 class BluetoothGetAdapterStateFunction : public BluetoothExtensionFunction { |
| 208 public: | 106 public: |
| 209 DECLARE_EXTENSION_FUNCTION("bluetooth.getProfiles", BLUETOOTH_GETPROFILES) | 107 DECLARE_EXTENSION_FUNCTION("bluetooth.getAdapterState", |
| 108 BLUETOOTH_GETADAPTERSTATE) |
| 210 | 109 |
| 211 protected: | 110 protected: |
| 212 virtual ~BluetoothGetProfilesFunction() {} | 111 virtual ~BluetoothGetAdapterStateFunction() {} |
| 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() {} |
| 213 | 134 |
| 214 // BluetoothExtensionFunction: | 135 // BluetoothExtensionFunction: |
| 215 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE; | 136 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE; |
| 216 }; | 137 }; |
| 217 | 138 |
| 218 class BluetoothConnectFunction : public BluetoothExtensionFunction { | 139 class BluetoothConnectFunction : public BluetoothExtensionFunction { |
| 219 public: | 140 public: |
| 220 DECLARE_EXTENSION_FUNCTION("bluetooth.connect", BLUETOOTH_CONNECT) | 141 DECLARE_EXTENSION_FUNCTION("bluetooth.connect", BLUETOOTH_CONNECT) |
| 221 | 142 |
| 222 protected: | 143 protected: |
| 223 virtual ~BluetoothConnectFunction(); | 144 virtual ~BluetoothConnectFunction() {} |
| 224 | 145 |
| 225 // BluetoothExtensionFunction: | 146 // BluetoothExtensionFunction: |
| 226 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE; | 147 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE; |
| 227 | 148 |
| 228 private: | 149 private: |
| 229 void OnSuccessCallback(); | 150 void OnSuccessCallback(); |
| 230 void OnErrorCallback(const std::string& error); | 151 void OnErrorCallback(); |
| 231 }; | 152 }; |
| 232 | 153 |
| 233 class BluetoothDisconnectFunction : public BluetoothSocketApiFunction { | 154 class BluetoothDisconnectFunction : public SyncExtensionFunction { |
| 234 public: | 155 public: |
| 235 DECLARE_EXTENSION_FUNCTION("bluetooth.disconnect", BLUETOOTH_DISCONNECT) | 156 DECLARE_EXTENSION_FUNCTION("bluetooth.disconnect", BLUETOOTH_DISCONNECT) |
| 236 BluetoothDisconnectFunction(); | |
| 237 | 157 |
| 238 protected: | 158 protected: |
| 239 virtual ~BluetoothDisconnectFunction(); | 159 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(); |
| 240 | 172 |
| 241 // AsyncApiFunction: | 173 // AsyncApiFunction: |
| 242 virtual bool Prepare() OVERRIDE; | 174 virtual bool Prepare() OVERRIDE; |
| 243 virtual void AsyncWorkStart() OVERRIDE; | 175 virtual bool Respond() OVERRIDE; |
| 176 virtual void Work() OVERRIDE; |
| 244 | 177 |
| 245 private: | 178 private: |
| 246 void OnSuccess(); | 179 bool success_; |
| 247 | 180 scoped_refptr<device::BluetoothSocket> socket_; |
| 248 scoped_ptr<bluetooth::Disconnect::Params> params_; | |
| 249 }; | 181 }; |
| 250 | 182 |
| 251 class BluetoothSendFunction : public BluetoothSocketApiFunction { | 183 class BluetoothWriteFunction : public AsyncApiFunction { |
| 252 public: | 184 public: |
| 253 DECLARE_EXTENSION_FUNCTION("bluetooth.send", BLUETOOTH_WRITE) | 185 DECLARE_EXTENSION_FUNCTION("bluetooth.write", BLUETOOTH_WRITE) |
| 254 BluetoothSendFunction(); | 186 BluetoothWriteFunction(); |
| 255 | 187 |
| 256 protected: | 188 protected: |
| 257 virtual ~BluetoothSendFunction(); | 189 virtual ~BluetoothWriteFunction(); |
| 258 | 190 |
| 259 // AsyncApiFunction: | 191 // AsyncApiFunction: |
| 260 virtual bool Prepare() OVERRIDE; | 192 virtual bool Prepare() OVERRIDE; |
| 261 virtual void AsyncWorkStart() OVERRIDE; | 193 virtual bool Respond() 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; | |
| 282 virtual void Work() OVERRIDE; | 194 virtual void Work() OVERRIDE; |
| 283 | 195 |
| 284 private: | 196 private: |
| 285 scoped_ptr<bluetooth::UpdateSocket::Params> params_; | 197 bool success_; |
| 198 const base::BinaryValue* data_to_write_; // memory is owned by args_ |
| 199 scoped_refptr<device::BluetoothSocket> socket_; |
| 286 }; | 200 }; |
| 287 | 201 |
| 288 class BluetoothSetSocketPausedFunction : public BluetoothSocketApiFunction { | 202 class BluetoothSetOutOfBandPairingDataFunction |
| 203 : public BluetoothExtensionFunction { |
| 289 public: | 204 public: |
| 290 DECLARE_EXTENSION_FUNCTION("bluetooth.setSocketPaused", | 205 DECLARE_EXTENSION_FUNCTION("bluetooth.setOutOfBandPairingData", |
| 291 BLUETOOTH_SET_SOCKET_PAUSED) | 206 BLUETOOTH_SETOUTOFBANDPAIRINGDATA) |
| 292 BluetoothSetSocketPausedFunction(); | |
| 293 | 207 |
| 294 protected: | 208 protected: |
| 295 virtual ~BluetoothSetSocketPausedFunction(); | 209 virtual ~BluetoothSetOutOfBandPairingDataFunction() {} |
| 296 | 210 |
| 297 // AsyncApiFunction: | 211 void OnSuccessCallback(); |
| 298 virtual bool Prepare() OVERRIDE; | 212 void OnErrorCallback(); |
| 299 virtual void Work() OVERRIDE; | |
| 300 | 213 |
| 301 private: | 214 // BluetoothExtensionFunction: |
| 302 scoped_ptr<bluetooth::SetSocketPaused::Params> params_; | 215 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE; |
| 303 }; | |
| 304 | |
| 305 class BluetoothGetSocketFunction : public BluetoothSocketApiFunction { | |
| 306 public: | |
| 307 DECLARE_EXTENSION_FUNCTION("bluetooth.getSocket", BLUETOOTH_GET_SOCKET) | |
| 308 | |
| 309 BluetoothGetSocketFunction(); | |
| 310 | |
| 311 protected: | |
| 312 virtual ~BluetoothGetSocketFunction(); | |
| 313 | |
| 314 // AsyncApiFunction: | |
| 315 virtual bool Prepare() OVERRIDE; | |
| 316 virtual void Work() OVERRIDE; | |
| 317 | |
| 318 private: | |
| 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; | |
| 334 }; | 216 }; |
| 335 | 217 |
| 336 class BluetoothGetLocalOutOfBandPairingDataFunction | 218 class BluetoothGetLocalOutOfBandPairingDataFunction |
| 337 : public BluetoothExtensionFunction { | 219 : public BluetoothExtensionFunction { |
| 338 public: | 220 public: |
| 339 DECLARE_EXTENSION_FUNCTION("bluetooth.getLocalOutOfBandPairingData", | 221 DECLARE_EXTENSION_FUNCTION("bluetooth.getLocalOutOfBandPairingData", |
| 340 BLUETOOTH_GETLOCALOUTOFBANDPAIRINGDATA) | 222 BLUETOOTH_GETLOCALOUTOFBANDPAIRINGDATA) |
| 341 | 223 |
| 342 protected: | 224 protected: |
| 343 virtual ~BluetoothGetLocalOutOfBandPairingDataFunction() {} | 225 virtual ~BluetoothGetLocalOutOfBandPairingDataFunction() {} |
| 344 | 226 |
| 345 void ReadCallback(const device::BluetoothOutOfBandPairingData& data); | 227 void ReadCallback( |
| 228 const device::BluetoothOutOfBandPairingData& data); |
| 346 void ErrorCallback(); | 229 void ErrorCallback(); |
| 347 | 230 |
| 348 // BluetoothExtensionFunction: | 231 // BluetoothExtensionFunction: |
| 349 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE; | 232 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE; |
| 350 }; | 233 }; |
| 351 | 234 |
| 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 | |
| 368 class BluetoothStartDiscoveryFunction : public BluetoothExtensionFunction { | 235 class BluetoothStartDiscoveryFunction : public BluetoothExtensionFunction { |
| 369 public: | 236 public: |
| 370 DECLARE_EXTENSION_FUNCTION("bluetooth.startDiscovery", | 237 DECLARE_EXTENSION_FUNCTION("bluetooth.startDiscovery", |
| 371 BLUETOOTH_STARTDISCOVERY) | 238 BLUETOOTH_STARTDISCOVERY) |
| 372 | 239 |
| 373 protected: | 240 protected: |
| 374 virtual ~BluetoothStartDiscoveryFunction() {} | 241 virtual ~BluetoothStartDiscoveryFunction() {} |
| 375 | 242 |
| 376 // BluetoothExtensionFunction: | 243 // BluetoothExtensionFunction: |
| 377 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE; | 244 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 393 | 260 |
| 394 private: | 261 private: |
| 395 void OnSuccessCallback(); | 262 void OnSuccessCallback(); |
| 396 void OnErrorCallback(); | 263 void OnErrorCallback(); |
| 397 }; | 264 }; |
| 398 | 265 |
| 399 } // namespace api | 266 } // namespace api |
| 400 } // namespace extensions | 267 } // namespace extensions |
| 401 | 268 |
| 402 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_ | 269 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_ |
| OLD | NEW |