| 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 Mojo interface helpers, served from | 6 * Javascript for Mojo interface helpers, served from |
| 7 * chrome://bluetooth-internals/. | 7 * chrome://bluetooth-internals/. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 cr.define('interfaces', function() { | 10 cr.define('interfaces', function() { |
| 11 /** | 11 /** |
| 12 * Overriden by tests to give them a chance to setup a fake Mojo browser proxy |
| 13 * before any other code executes. |
| 14 * @return {!Promise} A promise firing once necessary setup has been completed. |
| 15 */ |
| 16 var setupFn = window.setupFn || function() { return Promise.resolve(); }; |
| 17 |
| 18 /** |
| 12 * Sets up Mojo interfaces and adds them to window.interfaces. | 19 * Sets up Mojo interfaces and adds them to window.interfaces. |
| 13 * @return {Promise} | 20 * @return {Promise} |
| 14 */ | 21 */ |
| 15 function setupInterfaces() { | 22 function setupInterfaces() { |
| 16 return importModules([ | 23 return setupFn().then(function() { |
| 17 'content/public/renderer/frame_interfaces', | 24 return importModules([ |
| 18 'device/bluetooth/public/interfaces/adapter.mojom', | 25 'content/public/renderer/frame_interfaces', |
| 19 'device/bluetooth/public/interfaces/device.mojom', | 26 'device/bluetooth/public/interfaces/adapter.mojom', |
| 20 'mojo/public/js/connection', | 27 'device/bluetooth/public/interfaces/device.mojom', |
| 21 ]).then(function([frameInterfaces, bluetoothAdapter, bluetoothDevice, | 28 'mojo/public/js/connection', |
| 22 connection]) { | 29 ]).then(function([frameInterfaces, bluetoothAdapter, bluetoothDevice, |
| 23 interfaces.BluetoothAdapter = bluetoothAdapter; | 30 connection]) { |
| 24 interfaces.BluetoothDevice = bluetoothDevice; | 31 interfaces.BluetoothAdapter = bluetoothAdapter; |
| 25 interfaces.Connection = connection; | 32 interfaces.BluetoothDevice = bluetoothDevice; |
| 26 interfaces.FrameInterfaces = frameInterfaces; | 33 interfaces.Connection = connection; |
| 34 interfaces.FrameInterfaces = frameInterfaces; |
| 35 }); |
| 27 }); | 36 }); |
| 28 } | 37 } |
| 29 | 38 |
| 30 return { | 39 return { |
| 31 setupInterfaces: setupInterfaces, | 40 setupInterfaces: setupInterfaces, |
| 32 }; | 41 }; |
| 33 }); | 42 }); |
| OLD | NEW |