Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 /** | |
| 6 * Javascript for Mojo interface helpers, served from | |
| 7 * chrome://bluetooth-internals/. | |
| 8 */ | |
| 9 | |
| 10 cr.define('interfaces', function() { | |
| 11 /** | |
| 12 * Initializes Mojo proxies for page and Bluetooth services. | |
|
ortuno
2016/11/03 22:14:15
Also mention that the interfaces are added to the
mbrunson
2016/11/03 23:59:40
Done.
| |
| 13 * @return {!Promise<interfaces.BluetoothAdapter.Adapter>} resolves with | |
| 14 * Adapter if acquired, rejects if Bluetooth is not supported. | |
| 15 */ | |
| 16 function initializeProxies() { | |
| 17 return importModules([ | |
| 18 'content/public/renderer/frame_interfaces', | |
| 19 'device/bluetooth/public/interfaces/adapter.mojom', | |
| 20 'device/bluetooth/public/interfaces/device.mojom', | |
| 21 'mojo/public/js/connection', | |
| 22 ]).then(function([frameInterfaces, bluetoothAdapter, bluetoothDevice, | |
| 23 connection]) { | |
| 24 Object.assign(interfaces, { | |
| 25 BluetoothAdapter: bluetoothAdapter, | |
| 26 BluetoothDevice: bluetoothDevice, | |
| 27 Connection: connection, | |
| 28 }); | |
| 29 | |
| 30 var adapterFactory = connection.bindHandleToProxy( | |
|
ortuno
2016/11/03 22:14:15
Could you move the adapter code to the broker?
mbrunson
2016/11/03 23:59:40
Done.
| |
| 31 frameInterfaces.getInterface(bluetoothAdapter.AdapterFactory.name), | |
| 32 bluetoothAdapter.AdapterFactory); | |
| 33 | |
| 34 // Get an Adapter service. | |
| 35 return adapterFactory.getAdapter(); | |
| 36 }).then(function(response) { | |
| 37 if (!response.adapter) { | |
| 38 throw new Error('Bluetooth Not Supported on this platform.'); | |
| 39 } | |
| 40 | |
| 41 return interfaces.Connection.bindHandleToProxy( | |
| 42 response.adapter, | |
| 43 interfaces.BluetoothAdapter.Adapter); | |
| 44 }); | |
| 45 } | |
| 46 | |
| 47 return { | |
| 48 initialize: initializeProxies, | |
| 49 }; | |
| 50 }); | |
| OLD | NEW |