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

Side by Side Diff: chrome/browser/resources/usb_internals/usb_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 | « chrome/browser/resources/plugins.js ('k') | chrome/test/data/webui/plugins_browsertest.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 usb_internals.html, served from chrome://usb-internals/. 6 * Javascript for usb_internals.html, served from chrome://usb-internals/.
7 */ 7 */
8 8
9 (function() { 9 (function() {
10 // Connection to the UsbInternalsPageHandler instance running in the browser 10 // Connection to the UsbInternalsPageHandler instance running in the browser
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 $('test-device-allowed-origin').value).then(function(response) { 52 $('test-device-allowed-origin').value).then(function(response) {
53 if (response.success) 53 if (response.success)
54 refreshDeviceList(); 54 refreshDeviceList();
55 $('add-test-device-result').textContent = response.message; 55 $('add-test-device-result').textContent = response.message;
56 $('add-test-device-result').className = 56 $('add-test-device-result').className =
57 response.success ? 'action-success' : 'action-failure'; 57 response.success ? 'action-success' : 'action-failure';
58 }); 58 });
59 event.preventDefault(); 59 event.preventDefault();
60 } 60 }
61 61
62 /**
63 * Helper to convert callback-based define() API to a promise-based API.
64 * @param {!Array<string>} moduleNames
65 * @return {!Promise}
66 */
67 function importModules(moduleNames) {
68 return new Promise(function(resolve, reject) {
69 define(moduleNames, function(var_args) {
70 resolve(Array.prototype.slice.call(arguments, 0));
71 });
72 });
73 }
74
75 function initializeProxies() { 62 function initializeProxies() {
76 return importModules([ 63 return importModules([
77 'mojo/public/js/connection', 64 'mojo/public/js/connection',
78 'chrome/browser/ui/webui/usb_internals/usb_internals.mojom', 65 'chrome/browser/ui/webui/usb_internals/usb_internals.mojom',
79 'content/public/renderer/frame_interfaces', 66 'content/public/renderer/frame_interfaces',
80 ]).then(function(modules) { 67 ]).then(function(modules) {
81 let connection = modules[0]; 68 let connection = modules[0];
82 let mojom = modules[1]; 69 let mojom = modules[1];
83 let frameInterfaces = modules[2]; 70 let frameInterfaces = modules[2];
84 71
85 pageHandler = connection.bindHandleToProxy( 72 pageHandler = connection.bindHandleToProxy(
86 frameInterfaces.getInterface(mojom.UsbInternalsPageHandler.name), 73 frameInterfaces.getInterface(mojom.UsbInternalsPageHandler.name),
87 mojom.UsbInternalsPageHandler); 74 mojom.UsbInternalsPageHandler);
88 }); 75 });
89 } 76 }
90 77
91 document.addEventListener('DOMContentLoaded', function() { 78 document.addEventListener('DOMContentLoaded', function() {
92 initializeProxies().then(function() { 79 initializeProxies().then(function() {
93 $('add-test-device-form').addEventListener('submit', addTestDevice); 80 $('add-test-device-form').addEventListener('submit', addTestDevice);
94 refreshDeviceList(); 81 refreshDeviceList();
95 }); 82 });
96 }); 83 });
97 })(); 84 })();
OLDNEW
« no previous file with comments | « chrome/browser/resources/plugins.js ('k') | chrome/test/data/webui/plugins_browsertest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698