OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 /** | 5 /** |
6 * Javascript for bluetooth_internals.html, served from | 6 * Javascript for bluetooth_internals.html, served from |
7 * chrome://bluetooth-internals/. | 7 * chrome://bluetooth-internals/. |
8 */ | 8 */ |
9 | 9 |
10 /** | 10 /** |
(...skipping 18 matching lines...) Expand all Loading... |
29 deviceRemoved: function(device) { | 29 deviceRemoved: function(device) { |
30 console.log('Device removed'); | 30 console.log('Device removed'); |
31 console.log(device); | 31 console.log(device); |
32 } | 32 } |
33 }; | 33 }; |
34 | 34 |
35 (function() { | 35 (function() { |
36 var adapter, adapterClient; | 36 var adapter, adapterClient; |
37 | 37 |
38 /** | 38 /** |
39 * TODO: Move to shared location. See crbug.com/652361. | 39 * TODO: Move to shared location. See http://crbug.com/652361. |
40 * Helper to convert callback-based define() API to a promise-based API. | 40 * Helper to convert callback-based define() API to a promise-based API. |
41 * @param {!Array<string>} moduleNames | 41 * @param {!Array<string>} moduleNames |
42 * @return {!Promise} | 42 * @return {!Promise} |
43 */ | 43 */ |
44 function importModules(moduleNames) { | 44 function importModules(moduleNames) { |
45 return new Promise(function(resolve, reject) { | 45 return new Promise(function(resolve, reject) { |
46 define(moduleNames, function(var_args) { | 46 define(moduleNames, function(var_args) { |
47 resolve(Array.prototype.slice.call(arguments, 0)); | 47 resolve(Array.prototype.slice.call(arguments, 0)); |
48 }); | 48 }); |
49 }); | 49 }); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 // Create a message pipe and bind one end to client | 82 // Create a message pipe and bind one end to client |
83 // implementation and the other to the Adapter service. | 83 // implementation and the other to the Adapter service. |
84 adapterClient = new AdapterClient(); | 84 adapterClient = new AdapterClient(); |
85 adapter.setClient(connection.bindStubDerivedImpl(adapterClient)); | 85 adapter.setClient(connection.bindStubDerivedImpl(adapterClient)); |
86 }); | 86 }); |
87 }); | 87 }); |
88 } | 88 } |
89 | 89 |
90 document.addEventListener('DOMContentLoaded', function() { | 90 document.addEventListener('DOMContentLoaded', function() { |
91 initializeProxies() | 91 initializeProxies() |
| 92 .then(function() {return adapter.getInfo(); }) |
| 93 .then(function(response) { console.log('info', response.info); }) |
92 .then(function() { return adapter.getDevices(); }) | 94 .then(function() { return adapter.getDevices(); }) |
93 .then(function(response) { console.log(response.devices); }) | 95 .then(function(response) { console.log('devices', response.devices); }) |
94 .catch(function(error) { console.error(error); }); | 96 .catch(function(error) { console.error(error); }); |
95 }); | 97 }); |
96 })(); | 98 })(); |
OLD | NEW |