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