Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: chrome/browser/resources/bluetooth_internals/bluetooth_internals.js

Issue 2470063003: Move importModules function to util.js (Closed)
Patch Set: Add suppress Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/omnibox/omnibox.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 (function() { 10 (function() {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 deviceRow.querySelector('.device-address').textContent = 75 deviceRow.querySelector('.device-address').textContent =
76 deviceInfo.address; 76 deviceInfo.address;
77 77
78 var rssi = (deviceInfo.rssi && deviceInfo.rssi.value) || 78 var rssi = (deviceInfo.rssi && deviceInfo.rssi.value) ||
79 deviceRow.querySelector('.device-rssi').textContent; 79 deviceRow.querySelector('.device-rssi').textContent;
80 deviceRow.querySelector('.device-rssi').textContent = rssi; 80 deviceRow.querySelector('.device-rssi').textContent = rssi;
81 } 81 }
82 }; 82 };
83 83
84 /** 84 /**
85 * TODO(crbug.com/652361): Move to shared location.
86 * Helper to convert callback-based define() API to a promise-based API.
87 * @param {!Array<string>} moduleNames
88 * @return {!Promise}
89 */
90 function importModules(moduleNames) {
91 return new Promise(function(resolve, reject) {
92 define(moduleNames, function(var_args) {
93 resolve(Array.prototype.slice.call(arguments, 0));
94 });
95 });
96 }
97
98 /**
99 * Initializes Mojo proxies for page and Bluetooth services. 85 * Initializes Mojo proxies for page and Bluetooth services.
100 * @return {!Promise} resolves if adapter is acquired, rejects if Bluetooth 86 * @return {!Promise} resolves if adapter is acquired, rejects if Bluetooth
101 * is not supported. 87 * is not supported.
102 */ 88 */
103 function initializeProxies() { 89 function initializeProxies() {
104 return importModules([ 90 return importModules([
105 'content/public/renderer/frame_interfaces', 91 'content/public/renderer/frame_interfaces',
106 'device/bluetooth/public/interfaces/adapter.mojom', 92 'device/bluetooth/public/interfaces/adapter.mojom',
107 'device/bluetooth/public/interfaces/device.mojom', 93 'device/bluetooth/public/interfaces/device.mojom',
108 'mojo/public/js/connection', 94 'mojo/public/js/connection',
(...skipping 30 matching lines...) Expand all
139 initializeProxies() 125 initializeProxies()
140 .then(function() { return adapter.getInfo(); }) 126 .then(function() { return adapter.getInfo(); })
141 .then(function(response) { console.log('adapter', response.info); }) 127 .then(function(response) { console.log('adapter', response.info); })
142 .then(function() { return adapter.getDevices(); }) 128 .then(function() { return adapter.getDevices(); })
143 .then(function(response) { 129 .then(function(response) {
144 response.devices.forEach(adapterClient.deviceAdded, adapterClient); 130 response.devices.forEach(adapterClient.deviceAdded, adapterClient);
145 }) 131 })
146 .catch(function(error) { console.error(error); }); 132 .catch(function(error) { console.error(error); });
147 }); 133 });
148 })(); 134 })();
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/omnibox/omnibox.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698