Commit 2168eec3 authored by Ken Rockot's avatar Ken Rockot Committed by Commit Bot

Migrate chrome://usb-internals/ to Mojo JS modules

Bug: 1004256
Change-Id: Ibdb339fb95c71028050ffaed42156cca45485370
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2513687
Commit-Queue: Ken Rockot <rockot@google.com>
Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#824226}
parent 854ee3e8
...@@ -6310,10 +6310,11 @@ grit("resources") { ...@@ -6310,10 +6310,11 @@ grit("resources") {
deps = [ deps = [
":chrome_internal_resources_gen", ":chrome_internal_resources_gen",
"//chrome/browser/resources/browser_switch:web_components", "//chrome/browser/resources/browser_switch:web_components",
"//chrome/browser/ui/webui/usb_internals:mojo_bindings_js", "//chrome/browser/ui/webui/usb_internals:mojo_bindings_webui_js",
"//device/bluetooth/public/mojom:deprecated_experimental_interfaces_js", "//device/bluetooth/public/mojom:deprecated_experimental_interfaces_js",
"//device/bluetooth/public/mojom:mojom_js", "//device/bluetooth/public/mojom:mojom_js",
"//services/device//public/mojom:usb_test_js", "//services/device/public/mojom:usb_test_webui_js",
"//services/device/public/mojom:usb_webui_js",
"//url/mojom:url_mojom_gurl_js", "//url/mojom:url_mojom_gurl_js",
"//url/mojom:url_mojom_origin_js", "//url/mojom:url_mojom_origin_js",
] ]
......
...@@ -213,11 +213,11 @@ ...@@ -213,11 +213,11 @@
<include name="IDR_SIGNIN_REAUTH_IMAGES_ACCOUNT_PASSWORDS_REAUTH_ILLUSTRATION_SVG" file="resources\signin\signin_reauth\images\account_passwords_reauth_illustration.svg" type="BINDATA" /> <include name="IDR_SIGNIN_REAUTH_IMAGES_ACCOUNT_PASSWORDS_REAUTH_ILLUSTRATION_SVG" file="resources\signin\signin_reauth\images\account_passwords_reauth_illustration.svg" type="BINDATA" />
<include name="IDR_SIGNIN_REAUTH_IMAGES_ACCOUNT_PASSWORDS_REAUTH_ILLUSTRATION_DARK_SVG" file="resources\signin\signin_reauth\images\account_passwords_reauth_illustration_dark.svg" type="BINDATA" /> <include name="IDR_SIGNIN_REAUTH_IMAGES_ACCOUNT_PASSWORDS_REAUTH_ILLUSTRATION_DARK_SVG" file="resources\signin\signin_reauth\images\account_passwords_reauth_illustration_dark.svg" type="BINDATA" />
</if> </if>
<include name="IDR_USB_ENUMERATION_OPTIONS_MOJOM_LITE_JS" file="${root_gen_dir}\services\device\public\mojom\usb_enumeration_options.mojom-lite.js" use_base_dir="false" flattenhtml="true" allowexternalscript="true" type="BINDATA" /> <include name="IDR_USB_ENUMERATION_OPTIONS_MOJOM_WEBUI_JS" file="${root_gen_dir}\mojom-webui\services\device\public\mojom\usb_enumeration_options.mojom-webui.js" use_base_dir="false" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
<include name="IDR_USB_DEVICE_MANAGER_CLIENT_MOJOM_LITE_JS" file="${root_gen_dir}\services\device\public\mojom\usb_manager_client.mojom-lite.js" use_base_dir="false" flattenhtml="true" allowexternalscript="true" type="BINDATA" /> <include name="IDR_USB_DEVICE_MANAGER_CLIENT_MOJOM_WEBUI_JS" file="${root_gen_dir}\mojom-webui\services\device\public\mojom\usb_manager_client.mojom-webui.js" use_base_dir="false" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
<include name="IDR_USB_DEVICE_MANAGER_MOJOM_LITE_JS" file="${root_gen_dir}\services\device\public\mojom\usb_manager.mojom-lite.js" use_base_dir="false" type="BINDATA" /> <include name="IDR_USB_DEVICE_MANAGER_MOJOM_WEBUI_JS" file="${root_gen_dir}\mojom-webui\services\device\public\mojom\usb_manager.mojom-webui.js" use_base_dir="false" type="BINDATA" />
<include name="IDR_USB_DEVICE_MANAGER_TEST_MOJOM_LITE_JS" file="${root_gen_dir}\services\device\public\mojom\usb_manager_test.mojom-lite.js" use_base_dir="false" flattenhtml="true" allowexternalscript="true" type="BINDATA" /> <include name="IDR_USB_DEVICE_MANAGER_TEST_MOJOM_WEBUI_JS" file="${root_gen_dir}\mojom-webui\services\device\public\mojom\usb_manager_test.mojom-webui.js" use_base_dir="false" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
<include name="IDR_USB_DEVICE_MOJOM_LITE_JS" file="${root_gen_dir}\services\device\public\mojom\usb_device.mojom-lite.js" use_base_dir="false" flattenhtml="true" allowexternalscript="true" type="BINDATA" /> <include name="IDR_USB_DEVICE_MOJOM_WEBUI_JS" file="${root_gen_dir}\mojom-webui\services\device\public\mojom\usb_device.mojom-webui.js" use_base_dir="false" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
<include name="IDR_WEB_FOOTER_EXPERIMENT_HTML" file="resources\web_footer_experiment\index.html" type="BINDATA" /> <include name="IDR_WEB_FOOTER_EXPERIMENT_HTML" file="resources\web_footer_experiment\index.html" type="BINDATA" />
<include name="IDR_WEBSTORE_MANIFEST" file="resources\webstore_app\manifest.json" type="BINDATA" /> <include name="IDR_WEBSTORE_MANIFEST" file="resources\webstore_app\manifest.json" type="BINDATA" />
<include name="IDR_CRYPTOTOKEN_MANIFEST" file="resources\cryptotoken\manifest.json" type="BINDATA" /> <include name="IDR_CRYPTOTOKEN_MANIFEST" file="resources\cryptotoken\manifest.json" type="BINDATA" />
......
...@@ -8,6 +8,15 @@ import("//tools/polymer/html_to_js.gni") ...@@ -8,6 +8,15 @@ import("//tools/polymer/html_to_js.gni")
js_type_check("closure_compile") { js_type_check("closure_compile") {
uses_js_modules = true uses_js_modules = true
closure_flags = default_closure_args + mojom_js_args + [
"js_module_root=" + rebase_path(".", root_build_dir),
"js_module_root=" + rebase_path(
"$root_gen_dir/mojom-webui/chrome/browser/ui/webui/usb_internals",
root_build_dir),
"js_module_root=" + rebase_path(
"$root_gen_dir/mojom-webui/services/device/public/mojom",
root_build_dir),
]
deps = [ deps = [
":app", ":app",
":descriptor_panel", ":descriptor_panel",
...@@ -18,7 +27,7 @@ js_type_check("closure_compile") { ...@@ -18,7 +27,7 @@ js_type_check("closure_compile") {
js_library("app") { js_library("app") {
deps = [ deps = [
":devices_page", ":devices_page",
":mojo", "//chrome/browser/ui/webui/usb_internals:mojo_bindings_webui_js",
"//ui/webui/resources/js:assert.m", "//ui/webui/resources/js:assert.m",
"//ui/webui/resources/js:cr.m", "//ui/webui/resources/js:cr.m",
"//ui/webui/resources/js/cr/ui:tabs.m", "//ui/webui/resources/js/cr/ui:tabs.m",
...@@ -28,7 +37,7 @@ js_library("app") { ...@@ -28,7 +37,7 @@ js_library("app") {
js_library("devices_page") { js_library("devices_page") {
deps = [ deps = [
":descriptor_panel", ":descriptor_panel",
":mojo", "//chrome/browser/ui/webui/usb_internals:mojo_bindings_webui_js",
"//ui/webui/resources/js:assert.m", "//ui/webui/resources/js:assert.m",
"//ui/webui/resources/js:cr.m", "//ui/webui/resources/js:cr.m",
"//ui/webui/resources/js:util.m", "//ui/webui/resources/js:util.m",
...@@ -39,7 +48,7 @@ js_library("devices_page") { ...@@ -39,7 +48,7 @@ js_library("devices_page") {
js_library("descriptor_panel") { js_library("descriptor_panel") {
deps = [ deps = [
":mojo", "//chrome/browser/ui/webui/usb_internals:mojo_bindings_webui_js",
"//ui/webui/resources/js:assert.m", "//ui/webui/resources/js:assert.m",
"//ui/webui/resources/js:util.m", "//ui/webui/resources/js:util.m",
"//ui/webui/resources/js/cr:ui.m", "//ui/webui/resources/js/cr:ui.m",
...@@ -47,10 +56,6 @@ js_library("descriptor_panel") { ...@@ -47,10 +56,6 @@ js_library("descriptor_panel") {
] ]
} }
js_library("mojo") {
deps = [ "//chrome/browser/ui/webui/usb_internals:mojo_bindings_js_library_for_compile" ]
}
grit("resources") { grit("resources") {
source = "resources.grd" source = "resources.grd"
outputs = [ outputs = [
...@@ -66,7 +71,7 @@ grit("resources") { ...@@ -66,7 +71,7 @@ grit("resources") {
] ]
deps = [ deps = [
":web_components", ":web_components",
"//chrome/browser/ui/webui/usb_internals:mojo_bindings_js", "//chrome/browser/ui/webui/usb_internals:mojo_bindings_webui_js",
] ]
} }
......
...@@ -5,13 +5,15 @@ ...@@ -5,13 +5,15 @@
/** /**
* Javascript for usb_internals.html, served from chrome://usb-internals/. * Javascript for usb_internals.html, served from chrome://usb-internals/.
*/ */
import './mojo.js';
import {assert} from 'chrome://resources/js/assert.m.js'; import {assert} from 'chrome://resources/js/assert.m.js';
import {decorate} from 'chrome://resources/js/cr/ui.m.js'; import {decorate} from 'chrome://resources/js/cr/ui.m.js';
import {TabBox} from 'chrome://resources/js/cr/ui/tabs.m.js'; import {TabBox} from 'chrome://resources/js/cr/ui/tabs.m.js';
import {DevicesPage} from './devices_page.js'; import {DevicesPage} from './devices_page.js';
import {UsbInternalsPageHandler} from './usb_internals.mojom-webui.js';
import {UsbDeviceManagerRemote} from './usb_manager.mojom-webui.js';
import {UsbDeviceManagerTestRemote} from './usb_manager_test.mojom-webui.js';
window.setupFn = window.setupFn || function() { window.setupFn = window.setupFn || function() {
return Promise.resolve(); return Promise.resolve();
...@@ -44,20 +46,20 @@ class UsbInternalsAppElement extends HTMLElement { ...@@ -44,20 +46,20 @@ class UsbInternalsAppElement extends HTMLElement {
// actions after the page is loaded but before any script is run. // actions after the page is loaded but before any script is run.
await window.setupFn(); await window.setupFn();
const pageHandler = mojom.UsbInternalsPageHandler.getRemote(); const pageHandler = UsbInternalsPageHandler.getRemote();
// Connection to the UsbInternalsPageHandler instance running in the // Connection to the UsbInternalsPageHandler instance running in the
// browser process. // browser process.
/** @type {device.mojom.UsbDeviceManagerRemote} */ /** @type {UsbDeviceManagerRemote} */
const usbManager = new device.mojom.UsbDeviceManagerRemote; const usbManager = new UsbDeviceManagerRemote;
await pageHandler.bindUsbDeviceManagerInterface( await pageHandler.bindUsbDeviceManagerInterface(
usbManager.$.bindNewPipeAndPassReceiver()); usbManager.$.bindNewPipeAndPassReceiver());
/** @private {!DevicesPage} */ /** @private {!DevicesPage} */
this.devicesPage_ = new DevicesPage(usbManager, assert(this.shadowRoot)); this.devicesPage_ = new DevicesPage(usbManager, assert(this.shadowRoot));
/** @private {device.mojom.UsbDeviceManagerTestRemote} */ /** @private {UsbDeviceManagerTestRemote} */
this.usbManagerTest_ = new device.mojom.UsbDeviceManagerTestRemote; this.usbManagerTest_ = new UsbDeviceManagerTestRemote;
await pageHandler.bindTestInterface( await pageHandler.bindTestInterface(
this.usbManagerTest_.$.bindNewPipeAndPassReceiver()); this.usbManagerTest_.$.bindNewPipeAndPassReceiver());
......
...@@ -6,13 +6,14 @@ ...@@ -6,13 +6,14 @@
* Javascript for DescriptorPanel UI, served from * Javascript for DescriptorPanel UI, served from
* chrome://usb-internals/. * chrome://usb-internals/.
*/ */
import './mojo.js';
import {assert, assertInstanceof} from 'chrome://resources/js/assert.m.js'; import {assert, assertInstanceof} from 'chrome://resources/js/assert.m.js';
import {decorate} from 'chrome://resources/js/cr/ui.m.js'; import {decorate} from 'chrome://resources/js/cr/ui.m.js';
import {Tree, TreeItem} from 'chrome://resources/js/cr/ui/tree.m.js'; import {Tree, TreeItem} from 'chrome://resources/js/cr/ui/tree.m.js';
import {queryRequiredElement} from 'chrome://resources/js/util.m.js'; import {queryRequiredElement} from 'chrome://resources/js/util.m.js';
import {UsbControlTransferParams, UsbControlTransferRecipient, UsbControlTransferType, UsbDeviceInterface, UsbTransferStatus} from './usb_device.mojom-webui.js';
const INPUT_TYPE_DECIMAL_WITH_DROPDOWN = 0; const INPUT_TYPE_DECIMAL_WITH_DROPDOWN = 0;
const INPUT_TYPE_HEX_BYTE = 1; const INPUT_TYPE_HEX_BYTE = 1;
...@@ -116,11 +117,11 @@ const MS_OS_20_PLATFORM_CAPABILITY_UUID = [ ...@@ -116,11 +117,11 @@ const MS_OS_20_PLATFORM_CAPABILITY_UUID = [
export class DescriptorPanel { export class DescriptorPanel {
/** /**
* @param {!device.mojom.UsbDeviceInterface} usbDeviceProxy * @param {!UsbDeviceInterface} usbDeviceProxy
* @param {!HTMLElement} rootElement * @param {!HTMLElement} rootElement
*/ */
constructor(usbDeviceProxy, rootElement) { constructor(usbDeviceProxy, rootElement) {
/** @type {!device.mojom.UsbDeviceInterface} */ /** @type {!UsbDeviceInterface} */
this.usbDeviceProxy_ = usbDeviceProxy; this.usbDeviceProxy_ = usbDeviceProxy;
/** @type {!HTMLElement} */ /** @type {!HTMLElement} */
...@@ -462,10 +463,10 @@ export class DescriptorPanel { ...@@ -462,10 +463,10 @@ export class DescriptorPanel {
* Gets device descriptor of current device, and display it. * Gets device descriptor of current device, and display it.
*/ */
async getDeviceDescriptor() { async getDeviceDescriptor() {
/** @type {!device.mojom.UsbControlTransferParams} */ /** @type {!UsbControlTransferParams} */
const usbControlTransferParams = { const usbControlTransferParams = {
type: device.mojom.UsbControlTransferType.STANDARD, type: UsbControlTransferType.STANDARD,
recipient: device.mojom.UsbControlTransferRecipient.DEVICE, recipient: UsbControlTransferRecipient.DEVICE,
request: GET_DESCRIPTOR_REQUEST, request: GET_DESCRIPTOR_REQUEST,
value: DEVICE_DESCRIPTOR_TYPE << 8, value: DEVICE_DESCRIPTOR_TYPE << 8,
index: 0, index: 0,
...@@ -587,10 +588,10 @@ export class DescriptorPanel { ...@@ -587,10 +588,10 @@ export class DescriptorPanel {
* Gets configuration descriptor of current device, and display it. * Gets configuration descriptor of current device, and display it.
*/ */
async getConfigurationDescriptor() { async getConfigurationDescriptor() {
/** @type {!device.mojom.UsbControlTransferParams} */ /** @type {!UsbControlTransferParams} */
const usbControlTransferParams = { const usbControlTransferParams = {
type: device.mojom.UsbControlTransferType.STANDARD, type: UsbControlTransferType.STANDARD,
recipient: device.mojom.UsbControlTransferRecipient.DEVICE, recipient: UsbControlTransferRecipient.DEVICE,
request: GET_DESCRIPTOR_REQUEST, request: GET_DESCRIPTOR_REQUEST,
value: CONFIGURATION_DESCRIPTOR_TYPE << 8, value: CONFIGURATION_DESCRIPTOR_TYPE << 8,
index: 0, index: 0,
...@@ -866,10 +867,10 @@ export class DescriptorPanel { ...@@ -866,10 +867,10 @@ export class DescriptorPanel {
* @return {!Promise<!Array<number>>} * @return {!Promise<!Array<number>>}
*/ */
async getAllLanguageCodes() { async getAllLanguageCodes() {
/** @type {!device.mojom.UsbControlTransferParams} */ /** @type {!UsbControlTransferParams} */
const usbControlTransferParams = { const usbControlTransferParams = {
type: device.mojom.UsbControlTransferType.STANDARD, type: UsbControlTransferType.STANDARD,
recipient: device.mojom.UsbControlTransferRecipient.DEVICE, recipient: UsbControlTransferRecipient.DEVICE,
request: GET_DESCRIPTOR_REQUEST, request: GET_DESCRIPTOR_REQUEST,
value: STRING_DESCRIPTOR_TYPE << 8, value: STRING_DESCRIPTOR_TYPE << 8,
index: 0, index: 0,
...@@ -930,10 +931,10 @@ export class DescriptorPanel { ...@@ -930,10 +931,10 @@ export class DescriptorPanel {
*/ */
async getStringDescriptorForLanguageCode_( async getStringDescriptorForLanguageCode_(
index, languageCode, treeItem = undefined) { index, languageCode, treeItem = undefined) {
/** @type {!device.mojom.UsbControlTransferParams} */ /** @type {!UsbControlTransferParams} */
const usbControlTransferParams = { const usbControlTransferParams = {
type: device.mojom.UsbControlTransferType.STANDARD, type: UsbControlTransferType.STANDARD,
recipient: device.mojom.UsbControlTransferRecipient.DEVICE, recipient: UsbControlTransferRecipient.DEVICE,
request: GET_DESCRIPTOR_REQUEST, request: GET_DESCRIPTOR_REQUEST,
index: languageCode, index: languageCode,
value: (STRING_DESCRIPTOR_TYPE << 8) | index, value: (STRING_DESCRIPTOR_TYPE << 8) | index,
...@@ -1088,10 +1089,10 @@ export class DescriptorPanel { ...@@ -1088,10 +1089,10 @@ export class DescriptorPanel {
* descriptor, and display it. * descriptor, and display it.
*/ */
async getBosDescriptor() { async getBosDescriptor() {
/** @type {!device.mojom.UsbControlTransferParams} */ /** @type {!UsbControlTransferParams} */
const usbControlTransferParams = { const usbControlTransferParams = {
type: device.mojom.UsbControlTransferType.STANDARD, type: UsbControlTransferType.STANDARD,
recipient: device.mojom.UsbControlTransferRecipient.DEVICE, recipient: UsbControlTransferRecipient.DEVICE,
request: GET_DESCRIPTOR_REQUEST, request: GET_DESCRIPTOR_REQUEST,
value: BOS_DESCRIPTOR_TYPE << 8, value: BOS_DESCRIPTOR_TYPE << 8,
index: 0, index: 0,
...@@ -1450,12 +1451,12 @@ export class DescriptorPanel { ...@@ -1450,12 +1451,12 @@ export class DescriptorPanel {
const vendorCode = rawData[offset + WEB_USB_VENDOR_CODE_OFFSET]; const vendorCode = rawData[offset + WEB_USB_VENDOR_CODE_OFFSET];
const urlIndex = rawData[offset + WEB_USB_URL_DESCRIPTOR_INDEX_OFFSET]; const urlIndex = rawData[offset + WEB_USB_URL_DESCRIPTOR_INDEX_OFFSET];
/** @type {!device.mojom.UsbControlTransferParams} */ /** @type {!UsbControlTransferParams} */
const usbControlTransferParams = { const usbControlTransferParams = {
recipient: device.mojom.UsbControlTransferRecipient.DEVICE, recipient: UsbControlTransferRecipient.DEVICE,
// These constants are defined by the WebUSB specification: // These constants are defined by the WebUSB specification:
// http://wicg.github.io/webusb/ // http://wicg.github.io/webusb/
type: device.mojom.UsbControlTransferType.VENDOR, type: UsbControlTransferType.VENDOR,
request: vendorCode, request: vendorCode,
value: urlIndex, value: urlIndex,
index: GET_URL_REQUEST, index: GET_URL_REQUEST,
...@@ -1512,12 +1513,12 @@ export class DescriptorPanel { ...@@ -1512,12 +1513,12 @@ export class DescriptorPanel {
* @private * @private
*/ */
async getMsOs20DescriptorSet_(vendorCode, msOs20DescriptorSetLength) { async getMsOs20DescriptorSet_(vendorCode, msOs20DescriptorSetLength) {
/** @type {!device.mojom.UsbControlTransferParams} */ /** @type {!UsbControlTransferParams} */
const usbControlTransferParams = { const usbControlTransferParams = {
recipient: device.mojom.UsbControlTransferRecipient.DEVICE, recipient: UsbControlTransferRecipient.DEVICE,
// These constants are defined by Microsoft OS 2.0 Descriptors // These constants are defined by Microsoft OS 2.0 Descriptors
// Specification (July, 2018). // Specification (July, 2018).
type: device.mojom.UsbControlTransferType.VENDOR, type: UsbControlTransferType.VENDOR,
request: vendorCode, request: vendorCode,
value: 0, value: 0,
index: MS_OS_20_DESCRIPTOR_INDEX, index: MS_OS_20_DESCRIPTOR_INDEX,
...@@ -1554,12 +1555,12 @@ export class DescriptorPanel { ...@@ -1554,12 +1555,12 @@ export class DescriptorPanel {
* @private * @private
*/ */
async sendMsOs20DescriptorSetAltEnumCommand_(vendorCode, altEnumCode) { async sendMsOs20DescriptorSetAltEnumCommand_(vendorCode, altEnumCode) {
/** @type {!device.mojom.UsbControlTransferParams} */ /** @type {!UsbControlTransferParams} */
const usbControlTransferParams = { const usbControlTransferParams = {
recipient: device.mojom.UsbControlTransferRecipient.DEVICE, recipient: UsbControlTransferRecipient.DEVICE,
// These constants are defined by Microsoft OS 2.0 Descriptors // These constants are defined by Microsoft OS 2.0 Descriptors
// Specification (July, 2018). // Specification (July, 2018).
type: device.mojom.UsbControlTransferType.VENDOR, type: UsbControlTransferType.VENDOR,
request: vendorCode, request: vendorCode,
value: altEnumCode, value: altEnumCode,
index: MS_OS_20_SET_ALT_ENUMERATION, index: MS_OS_20_SET_ALT_ENUMERATION,
...@@ -2304,7 +2305,7 @@ export class DescriptorPanel { ...@@ -2304,7 +2305,7 @@ export class DescriptorPanel {
/** /**
* Gets response of the given request. * Gets response of the given request.
* @param {!device.mojom.UsbControlTransferParams} usbControlTransferParams * @param {!UsbControlTransferParams} usbControlTransferParams
* @param {number} length * @param {number} length
* @param {string} direction * @param {string} direction
* @private * @private
...@@ -2433,18 +2434,17 @@ export class DescriptorPanel { ...@@ -2433,18 +2434,17 @@ export class DescriptorPanel {
const dataLength = getRequestLength(row, i); const dataLength = getRequestLength(row, i);
if (this.checkEnumParamValid_( if (this.checkEnumParamValid_(
type, 'Transfer Type', device.mojom.UsbControlTransferType) && type, 'Transfer Type', UsbControlTransferType) &&
this.checkEnumParamValid_( this.checkEnumParamValid_(
recipient, 'Transfer Recipient', recipient, 'Transfer Recipient', UsbControlTransferRecipient) &&
device.mojom.UsbControlTransferRecipient) &&
this.checkParamValid_(request, 'Transfer Request', 0, 255) && this.checkParamValid_(request, 'Transfer Request', 0, 255) &&
this.checkParamValid_(value, 'wValue', 0, 65535) && this.checkParamValid_(value, 'wValue', 0, 65535) &&
this.checkParamValid_(index, 'wIndex', 0, 65535) && this.checkParamValid_(index, 'wIndex', 0, 65535) &&
this.checkParamValid_(dataLength, 'Length', 0, 65535)) { this.checkParamValid_(dataLength, 'Length', 0, 65535)) {
/** @type {!device.mojom.UsbControlTransferParams} */ /** @type {!UsbControlTransferParams} */
const usbControlTransferParams = { const usbControlTransferParams = {
type: device.mojom.UsbControlTransferType[type], type: UsbControlTransferType[type],
recipient: device.mojom.UsbControlTransferRecipient[recipient], recipient: UsbControlTransferRecipient[recipient],
request, request,
value, value,
index, index,
...@@ -2890,30 +2890,30 @@ function renderRawDataBytes(rawDataByteElement, rawData) { ...@@ -2890,30 +2890,30 @@ function renderRawDataBytes(rawDataByteElement, rawData) {
function checkTransferSuccess(status, defaultMessage, rootElement) { function checkTransferSuccess(status, defaultMessage, rootElement) {
let failReason = ''; let failReason = '';
switch (status) { switch (status) {
case device.mojom.UsbTransferStatus.COMPLETED: case UsbTransferStatus.COMPLETED:
return; return;
case device.mojom.UsbTransferStatus.SHORT_PACKET: case UsbTransferStatus.SHORT_PACKET:
showError('Descriptor is too short.', rootElement); showError('Descriptor is too short.', rootElement);
return; return;
case device.mojom.UsbTransferStatus.BABBLE: case UsbTransferStatus.BABBLE:
showError('Descriptor is too long.', rootElement); showError('Descriptor is too long.', rootElement);
return; return;
case device.mojom.UsbTransferStatus.TRANSFER_ERROR: case UsbTransferStatus.TRANSFER_ERROR:
failReason = 'Transfer Error'; failReason = 'Transfer Error';
break; break;
case device.mojom.UsbTransferStatus.TIMEOUT: case UsbTransferStatus.TIMEOUT:
failReason = 'Timeout'; failReason = 'Timeout';
break; break;
case device.mojom.UsbTransferStatus.CANCELLED: case UsbTransferStatus.CANCELLED:
failReason = 'Transfer was cancelled'; failReason = 'Transfer was cancelled';
break; break;
case device.mojom.UsbTransferStatus.STALLED: case UsbTransferStatus.STALLED:
failReason = 'Transfer Error'; failReason = 'Transfer Error';
break; break;
case device.mojom.UsbTransferStatus.DISCONNECT: case UsbTransferStatus.DISCONNECT:
failReason = 'Transfer stalled'; failReason = 'Transfer stalled';
break; break;
case device.mojom.UsbTransferStatus.PERMISSION_DENIED: case UsbTransferStatus.PERMISSION_DENIED:
failReason = 'Permission denied'; failReason = 'Permission denied';
break; break;
} }
......
...@@ -7,28 +7,28 @@ ...@@ -7,28 +7,28 @@
* chrome://usb-internals/. * chrome://usb-internals/.
*/ */
import './mojo.js';
import {assertInstanceof} from 'chrome://resources/js/assert.m.js'; import {assertInstanceof} from 'chrome://resources/js/assert.m.js';
import {decorate} from 'chrome://resources/js/cr/ui.m.js'; import {decorate} from 'chrome://resources/js/cr/ui.m.js';
import {Tab, TabPanel} from 'chrome://resources/js/cr/ui/tabs.m.js'; import {Tab, TabPanel} from 'chrome://resources/js/cr/ui/tabs.m.js';
import {Tree, TreeItem} from 'chrome://resources/js/cr/ui/tree.m.js'; import {Tree, TreeItem} from 'chrome://resources/js/cr/ui/tree.m.js';
import {queryRequiredElement} from 'chrome://resources/js/util.m.js'; import {queryRequiredElement} from 'chrome://resources/js/util.m.js';
import {String16} from 'chrome://resources/mojo/mojo/public/mojom/base/string16.mojom-webui.js';
import {DescriptorPanel} from './descriptor_panel.js'; import {DescriptorPanel} from './descriptor_panel.js';
const UsbDeviceRemote = device.mojom.UsbDeviceRemote; import {UsbAlternateInterfaceInfo, UsbConfigurationInfo, UsbDeviceInfo, UsbDeviceRemote, UsbEndpointInfo, UsbInterfaceInfo, UsbTransferDirection, UsbTransferType} from './usb_device.mojom-webui.js';
import {UsbDeviceManagerRemote} from './usb_manager.mojom-webui.js';
/** /**
* Page that contains a tab header and a tab panel displaying devices table. * Page that contains a tab header and a tab panel displaying devices table.
*/ */
export class DevicesPage { export class DevicesPage {
/** /**
* @param {!device.mojom.UsbDeviceManagerRemote} usbManager * @param {!UsbDeviceManagerRemote} usbManager
* @param {!ShadowRoot} root * @param {!ShadowRoot} root
*/ */
constructor(usbManager, root) { constructor(usbManager, root) {
/** @private {!device.mojom.UsbDeviceManagerRemote} */ /** @private {!UsbDeviceManagerRemote} */
this.usbManager_ = usbManager; this.usbManager_ = usbManager;
this.root = root; this.root = root;
this.renderDeviceList_(); this.renderDeviceList_();
...@@ -41,7 +41,7 @@ export class DevicesPage { ...@@ -41,7 +41,7 @@ export class DevicesPage {
async renderDeviceList_() { async renderDeviceList_() {
const response = await this.usbManager_.getDevices(null); const response = await this.usbManager_.getDevices(null);
/** @type {!Array<!device.mojom.UsbDeviceInfo>} */ /** @type {!Array<!UsbDeviceInfo>} */
const devices = response.results; const devices = response.results;
const tableBody = this.root.querySelector('#device-list'); const tableBody = this.root.querySelector('#device-list');
...@@ -83,7 +83,7 @@ export class DevicesPage { ...@@ -83,7 +83,7 @@ export class DevicesPage {
/** /**
* Switches to the device's tab, creating one if necessary. * Switches to the device's tab, creating one if necessary.
* @param {!device.mojom.UsbDeviceInfo} device * @param {!UsbDeviceInfo} device
* @private * @private
*/ */
switchToTab_(device) { switchToTab_(device) {
...@@ -102,8 +102,8 @@ export class DevicesPage { ...@@ -102,8 +102,8 @@ export class DevicesPage {
*/ */
class DevicePage { class DevicePage {
/** /**
* @param {!device.mojom.UsbDeviceManagerRemote} usbManager * @param {!UsbDeviceManagerRemote} usbManager
* @param {!device.mojom.UsbDeviceInfo} device * @param {!UsbDeviceInfo} device
* @param {!ShadowRoot} root * @param {!ShadowRoot} root
*/ */
constructor(usbManager, device, root) { constructor(usbManager, device, root) {
...@@ -114,7 +114,7 @@ class DevicePage { ...@@ -114,7 +114,7 @@ class DevicePage {
/** /**
* Renders a tab to display a tree view showing device's detail information. * Renders a tab to display a tree view showing device's detail information.
* @param {!device.mojom.UsbDeviceInfo} device * @param {!UsbDeviceInfo} device
* @private * @private
*/ */
renderTab_(device) { renderTab_(device) {
...@@ -198,7 +198,7 @@ class DevicePage { ...@@ -198,7 +198,7 @@ class DevicePage {
/** /**
* Renders a tree to display the device's detail information. * Renders a tree to display the device's detail information.
* @param {!device.mojom.UsbDeviceInfo} device * @param {!UsbDeviceInfo} device
* @param {!Tree} root * @param {!Tree} root
*/ */
function renderDeviceTree(device, root) { function renderDeviceTree(device, root) {
...@@ -254,7 +254,7 @@ function renderDeviceTree(device, root) { ...@@ -254,7 +254,7 @@ function renderDeviceTree(device, root) {
/** /**
* Renders a tree item to display the device's configuration information. * Renders a tree item to display the device's configuration information.
* @param {!Array<!device.mojom.UsbConfigurationInfo>} configurationsArray * @param {!Array<!UsbConfigurationInfo>} configurationsArray
* @param {!Tree} root * @param {!Tree} root
*/ */
function renderConfigurationTreeItem(configurationsArray, root) { function renderConfigurationTreeItem(configurationsArray, root) {
...@@ -276,7 +276,7 @@ function renderConfigurationTreeItem(configurationsArray, root) { ...@@ -276,7 +276,7 @@ function renderConfigurationTreeItem(configurationsArray, root) {
/** /**
* Renders a tree item to display the device's interface information. * Renders a tree item to display the device's interface information.
* @param {!Array<!device.mojom.UsbInterfaceInfo>} interfacesArray * @param {!Array<!UsbInterfaceInfo>} interfacesArray
* @param {!TreeItem} root * @param {!TreeItem} root
*/ */
function renderInterfacesTreeItem(interfacesArray, root) { function renderInterfacesTreeItem(interfacesArray, root) {
...@@ -294,7 +294,7 @@ function renderInterfacesTreeItem(interfacesArray, root) { ...@@ -294,7 +294,7 @@ function renderInterfacesTreeItem(interfacesArray, root) {
/** /**
* Renders a tree item to display the device's alternate interfaces * Renders a tree item to display the device's alternate interfaces
* information. * information.
* @param {!Array<!device.mojom.UsbAlternateInterfaceInfo>} alternatesArray * @param {!Array<!UsbAlternateInterfaceInfo>} alternatesArray
* @param {!TreeItem} root * @param {!TreeItem} root
*/ */
function renderAlternatesTreeItem(alternatesArray, root) { function renderAlternatesTreeItem(alternatesArray, root) {
...@@ -324,7 +324,7 @@ function renderAlternatesTreeItem(alternatesArray, root) { ...@@ -324,7 +324,7 @@ function renderAlternatesTreeItem(alternatesArray, root) {
/** /**
* Renders a tree item to display the device's endpoints information. * Renders a tree item to display the device's endpoints information.
* @param {!Array<!device.mojom.UsbEndpointInfo>} endpointsArray * @param {!Array<!UsbEndpointInfo>} endpointsArray
* @param {!TreeItem} root * @param {!TreeItem} root
*/ */
function renderEndpointsTreeItem(endpointsArray, root) { function renderEndpointsTreeItem(endpointsArray, root) {
...@@ -334,10 +334,10 @@ function renderEndpointsTreeItem(endpointsArray, root) { ...@@ -334,10 +334,10 @@ function renderEndpointsTreeItem(endpointsArray, root) {
itemLabel += endpoint.endpointNumber; itemLabel += endpoint.endpointNumber;
switch (endpoint.direction) { switch (endpoint.direction) {
case device.mojom.UsbTransferDirection.INBOUND: case UsbTransferDirection.INBOUND:
itemLabel += ' (INBOUND)'; itemLabel += ' (INBOUND)';
break; break;
case device.mojom.UsbTransferDirection.OUTBOUND: case UsbTransferDirection.OUTBOUND:
itemLabel += ' (OUTBOUND)'; itemLabel += ' (OUTBOUND)';
break; break;
} }
...@@ -346,16 +346,16 @@ function renderEndpointsTreeItem(endpointsArray, root) { ...@@ -346,16 +346,16 @@ function renderEndpointsTreeItem(endpointsArray, root) {
let usbTransferType = ''; let usbTransferType = '';
switch (endpoint.type) { switch (endpoint.type) {
case device.mojom.UsbTransferType.CONTROL: case UsbTransferType.CONTROL:
usbTransferType = 'CONTROL'; usbTransferType = 'CONTROL';
break; break;
case device.mojom.UsbTransferType.ISOCHRONOUS: case UsbTransferType.ISOCHRONOUS:
usbTransferType = 'ISOCHRONOUS'; usbTransferType = 'ISOCHRONOUS';
break; break;
case device.mojom.UsbTransferType.BULK: case UsbTransferType.BULK:
usbTransferType = 'BULK'; usbTransferType = 'BULK';
break; break;
case device.mojom.UsbTransferType.INTERRUPT: case UsbTransferType.INTERRUPT:
usbTransferType = 'INTERRUPT'; usbTransferType = 'INTERRUPT';
break; break;
} }
...@@ -372,7 +372,7 @@ function renderEndpointsTreeItem(endpointsArray, root) { ...@@ -372,7 +372,7 @@ function renderEndpointsTreeItem(endpointsArray, root) {
* Initialize a descriptor panel. * Initialize a descriptor panel.
* @param {!HTMLElement} tabPanel * @param {!HTMLElement} tabPanel
* @param {string} panelType * @param {string} panelType
* @param {!device.mojom.UsbDeviceRemote} usbDevice * @param {!UsbDeviceRemote} usbDevice
* @param {string} guid * @param {string} guid
* @return {!DescriptorPanel} * @return {!DescriptorPanel}
*/ */
...@@ -417,7 +417,7 @@ function initialInspectorPanel(tabPanel, panelType, usbDevice, guid) { ...@@ -417,7 +417,7 @@ function initialInspectorPanel(tabPanel, panelType, usbDevice, guid) {
/** /**
* Parses utf16 coded string. * Parses utf16 coded string.
* @param {!mojoBase.mojom.String16} arr * @param {!String16} arr
* @return {string} * @return {string}
*/ */
function decodeString16(arr) { function decodeString16(arr) {
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// TODO(crbug.com/1004256): Use proper Mojo JS modules instead.
import 'chrome://resources/mojo/mojo/public/js/mojo_bindings_lite.js';
import 'chrome://resources/mojo/mojo/public/mojom/base/big_buffer.mojom-lite.js';
import 'chrome://resources/mojo/mojo/public/mojom/base/file.mojom-lite.js';
import 'chrome://resources/mojo/mojo/public/mojom/base/string16.mojom-lite.js';
import 'chrome://resources/mojo/url/mojom/url.mojom-lite.js';
import './usb_device.mojom-lite.js';
import './usb_manager_client.mojom-lite.js';
import './usb_enumeration_options.mojom-lite.js';
import './usb_manager.mojom-lite.js';
import './usb_manager_test.mojom-lite.js';
import './usb_internals.mojom-lite.js';
...@@ -26,12 +26,9 @@ ...@@ -26,12 +26,9 @@
<include name="IDR_USB_INTERNALS_HTML" <include name="IDR_USB_INTERNALS_HTML"
file="usb_internals.html" file="usb_internals.html"
type="BINDATA" /> type="BINDATA" />
<include name="IDR_USB_INTERNALS_MOJO_JS" <include name="IDR_USB_INTERNALS_MOJOM_WEBUI_JS"
file="mojo.js" file="${root_gen_dir}\mojom-webui\chrome\browser\ui\webui\usb_internals\usb_internals.mojom-webui.js"
type="BINDATA" /> resource_path="usb_internals.mojom-webui.js"
<include name="IDR_USB_INTERNALS_MOJOM_LITE_JS"
file="${root_gen_dir}\chrome\browser\ui\webui\usb_internals\usb_internals.mojom-lite.js"
resource_path="usb_internals.mojom-lite.js"
use_base_dir="false" use_base_dir="false"
type="BINDATA" /> type="BINDATA" />
<include name="IDR_USB_INTERNALS_APP_JS" <include name="IDR_USB_INTERNALS_APP_JS"
......
...@@ -11,4 +11,6 @@ mojom("mojo_bindings") { ...@@ -11,4 +11,6 @@ mojom("mojo_bindings") {
"//services/device/public/mojom:usb", "//services/device/public/mojom:usb",
"//services/device/public/mojom:usb_test", "//services/device/public/mojom:usb_test",
] ]
webui_module_path = "/"
} }
...@@ -21,14 +21,14 @@ UsbInternalsUI::UsbInternalsUI(content::WebUI* web_ui) ...@@ -21,14 +21,14 @@ UsbInternalsUI::UsbInternalsUI(content::WebUI* web_ui)
content::WebUIDataSource::Create(chrome::kChromeUIUsbInternalsHost); content::WebUIDataSource::Create(chrome::kChromeUIUsbInternalsHost);
static constexpr webui::ResourcePath kPaths[] = { static constexpr webui::ResourcePath kPaths[] = {
{"usb_device.mojom-lite.js", IDR_USB_DEVICE_MOJOM_LITE_JS}, {"usb_device.mojom-webui.js", IDR_USB_DEVICE_MOJOM_WEBUI_JS},
{"usb_enumeration_options.mojom-lite.js", {"usb_enumeration_options.mojom-webui.js",
IDR_USB_ENUMERATION_OPTIONS_MOJOM_LITE_JS}, IDR_USB_ENUMERATION_OPTIONS_MOJOM_WEBUI_JS},
{"usb_manager.mojom-lite.js", IDR_USB_DEVICE_MANAGER_MOJOM_LITE_JS}, {"usb_manager.mojom-webui.js", IDR_USB_DEVICE_MANAGER_MOJOM_WEBUI_JS},
{"usb_manager_client.mojom-lite.js", {"usb_manager_client.mojom-webui.js",
IDR_USB_DEVICE_MANAGER_CLIENT_MOJOM_LITE_JS}, IDR_USB_DEVICE_MANAGER_CLIENT_MOJOM_WEBUI_JS},
{"usb_manager_test.mojom-lite.js", {"usb_manager_test.mojom-webui.js",
IDR_USB_DEVICE_MANAGER_TEST_MOJOM_LITE_JS}, IDR_USB_DEVICE_MANAGER_TEST_MOJOM_WEBUI_JS},
}; };
webui::AddResourcePathsBulk(source, kPaths); webui::AddResourcePathsBulk(source, kPaths);
......
...@@ -360,7 +360,6 @@ if (include_js_tests) { ...@@ -360,7 +360,6 @@ if (include_js_tests) {
"media/media_history_webui_browsertest.js", "media/media_history_webui_browsertest.js",
"new_tab_page/new_tab_page_browsertest.js", "new_tab_page/new_tab_page_browsertest.js",
"read_later/read_later_browsertest.js", "read_later/read_later_browsertest.js",
"usb_internals_browsertest.js",
] ]
deps = [ "//chrome/browser/ui" ] deps = [ "//chrome/browser/ui" ]
...@@ -388,6 +387,7 @@ if (include_js_tests) { ...@@ -388,6 +387,7 @@ if (include_js_tests) {
sources = [ sources = [
"downloads/downloads_browsertest.js", "downloads/downloads_browsertest.js",
"engagement/site_engagement_browsertest.js", "engagement/site_engagement_browsertest.js",
"usb_internals_browsertest.js",
] ]
if (is_win || is_mac || is_linux || is_chromeos) { if (is_win || is_mac || is_linux || is_chromeos) {
sources += [ "discards/discards_browsertest.js" ] sources += [ "discards/discards_browsertest.js" ]
......
...@@ -2,13 +2,18 @@ ...@@ -2,13 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'chrome://usb-internals/mojo.js';
import 'chrome://usb-internals/app.js'; import 'chrome://usb-internals/app.js';
import 'chrome://test/mojo_webui_test_support.js';
import {PromiseResolver} from 'chrome://resources/js/promise_resolver.m.js'; import {PromiseResolver} from 'chrome://resources/js/promise_resolver.m.js';
import {String16} from 'chrome://resources/mojo/mojo/public/mojom/base/string16.mojom-webui.js';
import {TestBrowserProxy} from 'chrome://test/test_browser_proxy.m.js'; import {TestBrowserProxy} from 'chrome://test/test_browser_proxy.m.js';
import {UsbControlTransferParams, UsbControlTransferRecipient, UsbControlTransferType, UsbDeviceCallbackRouter, UsbDeviceRemote, UsbOpenDeviceError, UsbTransferStatus} from 'chrome://usb-internals/usb_device.mojom-webui.js';
import {UsbInternalsPageHandler, UsbInternalsPageHandlerReceiver, UsbInternalsPageHandlerRemote} from 'chrome://usb-internals/usb_internals.mojom-webui.js';
import {UsbDeviceManagerReceiver, UsbDeviceManagerRemote} from 'chrome://usb-internals/usb_manager.mojom-webui.js';
/** @implements {mojom.UsbInternalsPageHandlerRemote} */ /** @implements {UsbInternalsPageHandlerRemote} */
class FakePageHandlerRemote extends TestBrowserProxy { class FakePageHandlerRemote extends TestBrowserProxy {
constructor(handle) { constructor(handle) {
super([ super([
...@@ -16,7 +21,7 @@ class FakePageHandlerRemote extends TestBrowserProxy { ...@@ -16,7 +21,7 @@ class FakePageHandlerRemote extends TestBrowserProxy {
'bindTestInterface', 'bindTestInterface',
]); ]);
this.receiver_ = new mojom.UsbInternalsPageHandlerReceiver(this); this.receiver_ = new UsbInternalsPageHandlerReceiver(this);
this.receiver_.$.bindHandle(handle); this.receiver_.$.bindHandle(handle);
} }
...@@ -32,7 +37,7 @@ class FakePageHandlerRemote extends TestBrowserProxy { ...@@ -32,7 +37,7 @@ class FakePageHandlerRemote extends TestBrowserProxy {
} }
} }
/** @implements {device.mojom.UsbDeviceManagerRemote} */ /** @implements {UsbDeviceManagerRemote} */
class FakeDeviceManagerRemote extends TestBrowserProxy { class FakeDeviceManagerRemote extends TestBrowserProxy {
constructor(pendingReceiver) { constructor(pendingReceiver) {
super([ super([
...@@ -45,7 +50,7 @@ class FakeDeviceManagerRemote extends TestBrowserProxy { ...@@ -45,7 +50,7 @@ class FakeDeviceManagerRemote extends TestBrowserProxy {
'setClient', 'setClient',
]); ]);
this.receiver_ = new device.mojom.UsbDeviceManagerReceiver(this); this.receiver_ = new UsbDeviceManagerReceiver(this);
this.receiver_.$.bindHandle(pendingReceiver.handle); this.receiver_.$.bindHandle(pendingReceiver.handle);
this.devices = []; this.devices = [];
...@@ -88,7 +93,7 @@ class FakeDeviceManagerRemote extends TestBrowserProxy { ...@@ -88,7 +93,7 @@ class FakeDeviceManagerRemote extends TestBrowserProxy {
async setClient() {} async setClient() {}
} }
/** @implements {device.mojom.UsbDeviceRemote} */ /** @implements {UsbDeviceRemote} */
class FakeUsbDeviceRemote extends TestBrowserProxy { class FakeUsbDeviceRemote extends TestBrowserProxy {
constructor() { constructor() {
super([ super([
...@@ -102,9 +107,9 @@ class FakeUsbDeviceRemote extends TestBrowserProxy { ...@@ -102,9 +107,9 @@ class FakeUsbDeviceRemote extends TestBrowserProxy {
// device.mojom.UsbDevice defines lots of methods we don't care to mock // device.mojom.UsbDevice defines lots of methods we don't care to mock
// here. UsbDeviceCallbackRouter callback silently discards messages // here. UsbDeviceCallbackRouter callback silently discards messages
// that have no listeners. // that have no listeners.
this.router = new device.mojom.UsbDeviceCallbackRouter; this.router = new UsbDeviceCallbackRouter;
this.router.open.addListener(async () => { this.router.open.addListener(async () => {
return {error: device.mojom.UsbOpenDeviceError.OK}; return {error: UsbOpenDeviceError.OK};
}); });
this.router.controlTransferIn.addListener( this.router.controlTransferIn.addListener(
(params, length, timeout) => (params, length, timeout) =>
...@@ -117,7 +122,7 @@ class FakeUsbDeviceRemote extends TestBrowserProxy { ...@@ -117,7 +122,7 @@ class FakeUsbDeviceRemote extends TestBrowserProxy {
this.responses.get(usbControlTransferParamsToString(params)); this.responses.get(usbControlTransferParamsToString(params));
if (!response) { if (!response) {
return { return {
status: device.mojom.UsbTransferStatus.TRANSFER_ERROR, status: UsbTransferStatus.TRANSFER_ERROR,
data: [], data: [],
}; };
} }
...@@ -127,7 +132,7 @@ class FakeUsbDeviceRemote extends TestBrowserProxy { ...@@ -127,7 +132,7 @@ class FakeUsbDeviceRemote extends TestBrowserProxy {
/** /**
* Set a response for a given request. * Set a response for a given request.
* @param {!device.mojom.UsbControlTransferParams} params * @param {!UsbControlTransferParams} params
* @param {!Object} response * @param {!Object} response
*/ */
setResponse(params, response) { setResponse(params, response) {
...@@ -140,8 +145,8 @@ class FakeUsbDeviceRemote extends TestBrowserProxy { ...@@ -140,8 +145,8 @@ class FakeUsbDeviceRemote extends TestBrowserProxy {
*/ */
setDeviceDescriptor(response) { setDeviceDescriptor(response) {
const params = {}; const params = {};
params.type = device.mojom.UsbControlTransferType.STANDARD; params.type = UsbControlTransferType.STANDARD;
params.recipient = device.mojom.UsbControlTransferRecipient.DEVICE; params.recipient = UsbControlTransferRecipient.DEVICE;
params.request = 6; params.request = 6;
params.index = 0; params.index = 0;
params.value = (1 << 8); params.value = (1 << 8);
...@@ -185,7 +190,7 @@ function fakeDeviceInfo(num) { ...@@ -185,7 +190,7 @@ function fakeDeviceInfo(num) {
function createDeviceWithValidDeviceDescriptor() { function createDeviceWithValidDeviceDescriptor() {
const deviceRemote = new FakeUsbDeviceRemote(); const deviceRemote = new FakeUsbDeviceRemote();
deviceRemote.setDeviceDescriptor({ deviceRemote.setDeviceDescriptor({
status: device.mojom.UsbTransferStatus.COMPLETED, status: UsbTransferStatus.COMPLETED,
data: [ data: [
0x12, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x40, 0x50, 0x10, 0xEF, 0x17, 0x12, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x40, 0x50, 0x10, 0xEF, 0x17,
0x21, 0x03, 0x01, 0x02, 0x00, 0x01 0x21, 0x03, 0x01, 0x02, 0x00, 0x01
...@@ -200,7 +205,7 @@ function createDeviceWithValidDeviceDescriptor() { ...@@ -200,7 +205,7 @@ function createDeviceWithValidDeviceDescriptor() {
function createDeviceWithShortDeviceDescriptor() { function createDeviceWithShortDeviceDescriptor() {
const deviceRemote = new FakeUsbDeviceRemote(); const deviceRemote = new FakeUsbDeviceRemote();
deviceRemote.setDeviceDescriptor({ deviceRemote.setDeviceDescriptor({
status: device.mojom.UsbTransferStatus.SHORT_PACKET, status: UsbTransferStatus.SHORT_PACKET,
data: [0x12, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x40, 0x50], data: [0x12, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x40, 0x50],
}); });
return deviceRemote; return deviceRemote;
...@@ -209,7 +214,7 @@ function createDeviceWithShortDeviceDescriptor() { ...@@ -209,7 +214,7 @@ function createDeviceWithShortDeviceDescriptor() {
/** /**
* Converts an ECMAScript string to an instance of mojo_base.mojom.String16. * Converts an ECMAScript string to an instance of mojo_base.mojom.String16.
* @param {string} string * @param {string} string
* @return {!object} * @return {!String16}
*/ */
function stringToMojoString16(string) { function stringToMojoString16(string) {
return {data: Array.from(string, c => c.charCodeAt(0))}; return {data: Array.from(string, c => c.charCodeAt(0))};
...@@ -218,7 +223,7 @@ function stringToMojoString16(string) { ...@@ -218,7 +223,7 @@ function stringToMojoString16(string) {
/** /**
* Stringify a UsbControlTransferParams type object to be the key of * Stringify a UsbControlTransferParams type object to be the key of
* response map. * response map.
* @param {!device.mojom.UsbControlTransferParams} params * @param {!UsbControlTransferParams} params
* @return {string} * @return {string}
*/ */
function usbControlTransferParamsToString(params) { function usbControlTransferParamsToString(params) {
...@@ -245,8 +250,8 @@ window.deviceDescriptorCompleteFn = () => { ...@@ -245,8 +250,8 @@ window.deviceDescriptorCompleteFn = () => {
}; };
window.setupFn = () => { window.setupFn = () => {
const pageHandlerInterceptor = new MojoInterfaceInterceptor( const pageHandlerInterceptor =
mojom.UsbInternalsPageHandler.$interfaceName); new MojoInterfaceInterceptor(UsbInternalsPageHandler.$interfaceName);
pageHandlerInterceptor.oninterfacerequest = (e) => { pageHandlerInterceptor.oninterfacerequest = (e) => {
pageHandler = new FakePageHandlerRemote(e.handle); pageHandler = new FakePageHandlerRemote(e.handle);
setupResolver.resolve(); setupResolver.resolve();
......
...@@ -45,15 +45,15 @@ ...@@ -45,15 +45,15 @@
use_base_dir="false" use_base_dir="false"
resource_path="mojo/mojo/public/mojom/base/big_buffer.mojom-lite.js" resource_path="mojo/mojo/public/mojom/base/big_buffer.mojom-lite.js"
type="BINDATA" /> type="BINDATA" />
<include name="IDR_MOJO_FILE_MOJOM_HTML" <include name="IDR_MOJO_BIG_BUFFER_MOJOM_WEBUI_JS"
file="${root_gen_dir}/mojo/public/mojom/base/file.mojom.html" file="${root_gen_dir}/mojom-webui/mojo/public/mojom/base/big_buffer.mojom-webui.js"
use_base_dir="false" use_base_dir="false"
resource_path="mojo/mojo/public/mojom/base/file.mojom.html" resource_path="mojo/mojo/public/mojom/base/big_buffer.mojom-webui.js"
type="BINDATA" /> type="BINDATA" />
<include name="IDR_MOJO_FILE_MOJOM_LITE_JS" <include name="IDR_MOJO_FILE_MOJOM_WEBUI_JS"
file="${root_gen_dir}/mojo/public/mojom/base/file.mojom-lite.js" file="${root_gen_dir}/mojom-webui/mojo/public/mojom/base/file.mojom-webui.js"
use_base_dir="false" use_base_dir="false"
resource_path="mojo/mojo/public/mojom/base/file.mojom-lite.js" resource_path="mojo/mojo/public/mojom/base/file.mojom-webui.js"
type="BINDATA" /> type="BINDATA" />
<include name="IDR_MOJO_STRING16_MOJOM_HTML" <include name="IDR_MOJO_STRING16_MOJOM_HTML"
file="${root_gen_dir}/mojo/public/mojom/base/string16.mojom.html" file="${root_gen_dir}/mojo/public/mojom/base/string16.mojom.html"
...@@ -65,6 +65,11 @@ ...@@ -65,6 +65,11 @@
use_base_dir="false" use_base_dir="false"
resource_path="mojo/mojo/public/mojom/base/string16.mojom-lite.js" resource_path="mojo/mojo/public/mojom/base/string16.mojom-lite.js"
type="BINDATA" /> type="BINDATA" />
<include name="IDR_MOJO_STRING16_MOJOM_WEBUI_JS"
file="${root_gen_dir}/mojom-webui/mojo/public/mojom/base/string16.mojom-webui.js"
use_base_dir="false"
resource_path="mojo/mojo/public/mojom/base/string16.mojom-webui.js"
type="BINDATA" />
<include name="IDR_MOJO_TEXT_DIRECTION_MOJOM_HTML" <include name="IDR_MOJO_TEXT_DIRECTION_MOJOM_HTML"
file="${root_gen_dir}/mojo/public/mojom/base/text_direction.mojom.html" file="${root_gen_dir}/mojo/public/mojom/base/text_direction.mojom.html"
use_base_dir="false" use_base_dir="false"
......
...@@ -178,11 +178,13 @@ mojom("usb") { ...@@ -178,11 +178,13 @@ mojom("usb") {
"//third_party/blink/renderer/modules/webusb", "//third_party/blink/renderer/modules/webusb",
"//chrome/browser/ui/webui/usb_internals:mojo_bindings_blink", "//chrome/browser/ui/webui/usb_internals:mojo_bindings_blink",
] ]
webui_module_path = "/"
} }
mojom("usb_test") { mojom("usb_test") {
generate_java = true generate_java = true
sources = [ "usb_manager_test.mojom" ] sources = [ "usb_manager_test.mojom" ]
public_deps = [ "//url/mojom:url_mojom_gurl" ] public_deps = [ "//url/mojom:url_mojom_gurl" ]
webui_module_path = "/"
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment