| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Custom bindings for the Bluetooth API. |
| 6 |
| 7 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); |
| 8 var sendRequest = require('sendRequest').sendRequest; |
| 9 |
| 10 chromeHidden.registerCustomHook('experimental.bluetooth', function(api) { |
| 11 var apiFunctions = api.apiFunctions; |
| 12 |
| 13 chromeHidden.bluetooth = { handler: null }; |
| 14 |
| 15 function deviceDiscoveredListener(device) { |
| 16 if (chromeHidden.experimental.bluetooth.handler) |
| 17 chromeHidden.experimental.bluetooth.handler(device); |
| 18 } |
| 19 |
| 20 chrome.experimental.bluetooth._onDeviceDiscovered.addListener( |
| 21 deviceDiscoveredListener); |
| 22 |
| 23 apiFunctions.setHandleRequest('startDiscovery', function() { |
| 24 var args = arguments; |
| 25 if (args.length > 0 && args[0] && args[0].device_callback) { |
| 26 chromeHidden.bluetooth.handler = args[0].device_callback; |
| 27 } |
| 28 sendRequest(this.name, args, this.definition.parameters); |
| 29 }); |
| 30 apiFunctions.setHandleRequest('stopDiscovery', function() { |
| 31 chromeHidden.bluetooth.handler = null; |
| 32 sendRequest(this.name, args, this.definition.parameters); |
| 33 }); |
| 34 }); |
| OLD | NEW |