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 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 27 matching lines...) Expand all Loading... |
38 row.appendChild(landingPage); | 38 row.appendChild(landingPage); |
39 row.appendChild(allowedOrigin); | 39 row.appendChild(allowedOrigin); |
40 remove.appendChild(removeButton); | 40 remove.appendChild(removeButton); |
41 row.appendChild(remove); | 41 row.appendChild(remove); |
42 tableBody.appendChild(row); | 42 tableBody.appendChild(row); |
43 } | 43 } |
44 }); | 44 }); |
45 } | 45 } |
46 | 46 |
47 function addTestDevice(event) { | 47 function addTestDevice(event) { |
48 pageHandler.addDeviceForTesting( | 48 pageHandler |
49 $('test-device-name').value, | 49 .addDeviceForTesting( |
50 $('test-device-serial').value, | 50 $('test-device-name').value, $('test-device-serial').value, |
51 $('test-device-landing-page').value, | 51 $('test-device-landing-page').value, |
52 $('test-device-allowed-origin').value).then(function(response) { | 52 $('test-device-allowed-origin').value) |
53 if (response.success) | 53 .then(function(response) { |
54 refreshDeviceList(); | 54 if (response.success) |
55 $('add-test-device-result').textContent = response.message; | 55 refreshDeviceList(); |
56 $('add-test-device-result').className = | 56 $('add-test-device-result').textContent = response.message; |
57 response.success ? 'action-success' : 'action-failure'; | 57 $('add-test-device-result').className = |
58 }); | 58 response.success ? 'action-success' : 'action-failure'; |
| 59 }); |
59 event.preventDefault(); | 60 event.preventDefault(); |
60 } | 61 } |
61 | 62 |
62 function initializeProxies() { | 63 function initializeProxies() { |
63 return importModules([ | 64 return importModules([ |
64 'chrome/browser/ui/webui/usb_internals/usb_internals.mojom', | 65 'chrome/browser/ui/webui/usb_internals/usb_internals.mojom', |
65 'content/public/renderer/frame_interfaces', | 66 'content/public/renderer/frame_interfaces', |
66 ]).then(function(modules) { | 67 ]) |
67 let mojom = modules[0]; | 68 .then(function(modules) { |
68 let frameInterfaces = modules[1]; | 69 let mojom = modules[0]; |
| 70 let frameInterfaces = modules[1]; |
69 | 71 |
70 pageHandler = new mojom.UsbInternalsPageHandlerPtr( | 72 pageHandler = new mojom.UsbInternalsPageHandlerPtr( |
71 frameInterfaces.getInterface(mojom.UsbInternalsPageHandler.name)); | 73 frameInterfaces.getInterface(mojom.UsbInternalsPageHandler.name)); |
72 }); | 74 }); |
73 } | 75 } |
74 | 76 |
75 document.addEventListener('DOMContentLoaded', function() { | 77 document.addEventListener('DOMContentLoaded', function() { |
76 initializeProxies().then(function() { | 78 initializeProxies().then(function() { |
77 $('add-test-device-form').addEventListener('submit', addTestDevice); | 79 $('add-test-device-form').addEventListener('submit', addTestDevice); |
78 refreshDeviceList(); | 80 refreshDeviceList(); |
79 }); | 81 }); |
80 }); | 82 }); |
81 })(); | 83 })(); |
OLD | NEW |