| 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 // Custom binding for the Bluetooth API. | 5 // Custom bindings for the Bluetooth API. |
| 6 | |
| 7 var binding = require('binding').Binding.create('bluetooth'); | |
| 8 | 6 |
| 9 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); | 7 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); |
| 10 var chrome = requireNative('chrome').GetChrome(); | |
| 11 var sendRequest = require('sendRequest').sendRequest; | 8 var sendRequest = require('sendRequest').sendRequest; |
| 12 var lastError = require('lastError'); | 9 var lastError = require('lastError'); |
| 13 | 10 |
| 14 // Use custom binding to create an undocumented event listener that will | 11 // Use custom bindings to create an undocumented event listener that will |
| 15 // receive events about device discovery and call the event listener that was | 12 // receive events about device discovery and call the event listener that was |
| 16 // provided with the request to begin discovery. | 13 // provided with the request to begin discovery. |
| 17 binding.registerCustomHook(function(api) { | 14 chromeHidden.registerCustomHook('bluetooth', function(api) { |
| 18 var apiFunctions = api.apiFunctions; | 15 var apiFunctions = api.apiFunctions; |
| 19 | 16 |
| 20 chromeHidden.bluetooth = {}; | 17 chromeHidden.bluetooth = {}; |
| 21 | 18 |
| 22 function callCallbackIfPresent(args) { | 19 function callCallbackIfPresent(args) { |
| 23 if (typeof(args[args.length-1]) == "function") { | 20 if (typeof(args[args.length-1]) == "function") { |
| 24 args[args.length-1](); | 21 args[args.length-1](); |
| 25 } | 22 } |
| 26 } | 23 } |
| 27 | 24 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 throw new Error("getDevices must be passed options with a " + | 147 throw new Error("getDevices must be passed options with a " + |
| 151 "deviceCallback."); | 148 "deviceCallback."); |
| 152 } | 149 } |
| 153 | 150 |
| 154 chromeHidden.bluetooth.getDevicesState = state; | 151 chromeHidden.bluetooth.getDevicesState = state; |
| 155 addDeviceSearchListeners(); | 152 addDeviceSearchListeners(); |
| 156 | 153 |
| 157 return args; | 154 return args; |
| 158 }); | 155 }); |
| 159 }); | 156 }); |
| 160 | |
| 161 exports.binding = binding.generate(); | |
| OLD | NEW |