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