diff options
Diffstat (limited to 'chromium/ui/webui/resources/cr_components/chromeos/bluetooth')
20 files changed, 245 insertions, 104 deletions
diff --git a/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/BUILD.gn b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/BUILD.gn index a0a82921c34..4032cb62755 100644 --- a/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/BUILD.gn +++ b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/BUILD.gn @@ -9,6 +9,8 @@ assert(is_chromeos, "Bluetooth dialog is Chrome OS only.") js_type_check("closure_compile_module") { is_polymer3 = true + closure_flags = default_closure_args + mojom_js_args + deps = [ ":bluetooth_base_page", ":bluetooth_battery_icon_percentage", @@ -39,6 +41,10 @@ js_library("bluetooth_metrics_utils") { } js_library("bluetooth_utils") { + deps = [ + ":bluetooth_types", + "//chromeos/services/bluetooth_config/public/mojom:mojom_webui_js", + ] } js_library("bluetooth_icons") { @@ -50,7 +56,7 @@ js_library("bluetooth_types") { js_library("bluetooth_icon") { deps = [ ":bluetooth_icons", - "//chromeos/services/bluetooth_config/public/mojom:mojom_js_library_for_compile", + "//chromeos/services/bluetooth_config/public/mojom:mojom_webui_js", "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", ] } @@ -59,7 +65,7 @@ js_library("bluetooth_pairing_device_item") { deps = [ ":bluetooth_icon", ":bluetooth_types", - "//chromeos/services/bluetooth_config/public/mojom:mojom_js_library_for_compile", + "//chromeos/services/bluetooth_config/public/mojom:mojom_webui_js", "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", ] } @@ -87,6 +93,7 @@ js_library("bluetooth_pairing_device_selection_page") { ":bluetooth_base_page", ":bluetooth_pairing_device_item", ":bluetooth_types", + "//chromeos/services/bluetooth_config/public/mojom:mojom_webui_js", "//third_party/polymer/v3_0/components-chromium/iron-list:iron-list", "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", "//ui/webui/resources/cr_elements:cr_scrollable_behavior.m", @@ -98,6 +105,7 @@ js_library("bluetooth_pairing_device_selection_page") { js_library("bluetooth_pairing_request_code_page") { deps = [ ":bluetooth_base_page", + "//chromeos/services/bluetooth_config/public/mojom:mojom_webui_js", "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", "//ui/webui/resources/cr_elements/cr_input:cr_input.m", ] @@ -114,6 +122,7 @@ js_library("bluetooth_pairing_enter_code_page") { deps = [ ":bluetooth_base_page", ":bluetooth_types", + "//chromeos/services/bluetooth_config/public/mojom:mojom_webui_js", "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", ] } @@ -124,7 +133,7 @@ js_library("bluetooth_pairing_ui") { ":bluetooth_pairing_device_selection_page", ":bluetooth_pairing_request_code_page", ":cros_bluetooth_config", - "//chromeos/services/bluetooth_config/public/mojom:mojom_js_library_for_compile", + "//chromeos/services/bluetooth_config/public/mojom:mojom_webui_js", "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", "//ui/webui/resources/js:assert.m", ] @@ -141,6 +150,7 @@ js_library("bluetooth_base_page") { js_library("bluetooth_battery_icon_percentage") { deps = [ + "//chromeos/services/bluetooth_config/public/mojom:mojom_webui_js", "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", "//ui/webui/resources/cr_components/chromeos/bluetooth:bluetooth_utils", "//ui/webui/resources/js:i18n_behavior.m", @@ -149,6 +159,7 @@ js_library("bluetooth_battery_icon_percentage") { js_library("bluetooth_device_battery_info") { deps = [ + "//chromeos/services/bluetooth_config/public/mojom:mojom_webui_js", "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", "//ui/webui/resources/cr_components/chromeos/bluetooth:bluetooth_utils", "//ui/webui/resources/js:i18n_behavior.m", @@ -157,7 +168,7 @@ js_library("bluetooth_device_battery_info") { } js_library("cros_bluetooth_config") { - deps = [ "//chromeos/services/bluetooth_config/public/mojom:mojom_js_library_for_compile" ] + deps = [ "//chromeos/services/bluetooth_config/public/mojom:mojom_webui_js" ] } js_library("bluetooth_spinner_page") { diff --git a/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_base_page.d.ts b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_base_page.d.ts new file mode 100644 index 00000000000..a0e627fbaf3 --- /dev/null +++ b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_base_page.d.ts @@ -0,0 +1,13 @@ +// Copyright 2022 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. + +import {PolymerElement} from '//resources/polymer/v3_0/polymer/polymer_bundled.min.js'; + +export class SettingsBluetoothBasePageElement extends PolymerElement {} + +declare global { + interface HTMLElementTagNameMap { + 'bluetooth-base-page': SettingsBluetoothBasePageElement; + } +} diff --git a/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_battery_icon_percentage.d.ts b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_battery_icon_percentage.d.ts new file mode 100644 index 00000000000..ba54a953060 --- /dev/null +++ b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_battery_icon_percentage.d.ts @@ -0,0 +1,13 @@ +// Copyright 2022 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. + +import {PolymerElement} from '//resources/polymer/v3_0/polymer/polymer_bundled.min.js'; + +export class BluetoothBatteryIconPercentageElement extends PolymerElement {} + +declare global { + interface HTMLElementTagNameMap { + 'bluetooth-battery-icon-percentage': BluetoothBatteryIconPercentageElement; + } +} diff --git a/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_battery_icon_percentage.js b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_battery_icon_percentage.js index 703d39efdbb..6003ccf2f5d 100644 --- a/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_battery_icon_percentage.js +++ b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_battery_icon_percentage.js @@ -15,9 +15,10 @@ import './bluetooth_icons.js'; import {I18nBehavior, I18nBehaviorInterface} from '//resources/js/i18n_behavior.m.js'; import {html, mixinBehaviors, PolymerElement} from '//resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {assert} from 'chrome://resources/js/assert.m.js'; +import {BluetoothDeviceProperties} from 'chrome://resources/mojo/chromeos/services/bluetooth_config/public/mojom/cros_bluetooth_config.mojom-webui.js'; import {BatteryType} from './bluetooth_types.js'; -import {getBatteryPercentage, hasAnyDetailedBatteryInfo} from './bluetooth_utils.js'; +import {getBatteryPercentage} from './bluetooth_utils.js'; /** * The threshold percentage where any battery percentage lower is considered @@ -59,7 +60,7 @@ export class BluetoothBatteryIconPercentageElement extends static get properties() { return { /** - * @type {!chromeos.bluetoothConfig.mojom.BluetoothDeviceProperties} + * @type {!BluetoothDeviceProperties} */ device: { type: Object, @@ -99,7 +100,7 @@ export class BluetoothBatteryIconPercentageElement extends } /** - * @param {!chromeos.bluetoothConfig.mojom.BluetoothDeviceProperties} + * @param {!BluetoothDeviceProperties} * device * @param {!BatteryType} batteryType * @return {boolean} @@ -131,7 +132,7 @@ export class BluetoothBatteryIconPercentageElement extends } /** - * @param {!chromeos.bluetoothConfig.mojom.BluetoothDeviceProperties} + * @param {!BluetoothDeviceProperties} * device * @param {!BatteryType} batteryType * @return {string} @@ -171,7 +172,7 @@ export class BluetoothBatteryIconPercentageElement extends } /** - * @param {!chromeos.bluetoothConfig.mojom.BluetoothDeviceProperties} + * @param {!BluetoothDeviceProperties} * device * @param {!BatteryType} batteryType * @return {string} diff --git a/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_device_battery_info.d.ts b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_device_battery_info.d.ts new file mode 100644 index 00000000000..14b42d4759c --- /dev/null +++ b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_device_battery_info.d.ts @@ -0,0 +1,13 @@ +// Copyright 2022 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. + +import {PolymerElement} from '//resources/polymer/v3_0/polymer/polymer_bundled.min.js'; + +export class BluetoothDeviceBatteryInfoElement extends PolymerElement {} + +declare global { + interface HTMLElementTagNameMap { + 'bluetooth-device-battery-info': BluetoothDeviceBatteryInfoElement; + } +} diff --git a/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_device_battery_info.js b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_device_battery_info.js index 63117e2d0a9..47697f849c2 100644 --- a/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_device_battery_info.js +++ b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_device_battery_info.js @@ -11,6 +11,7 @@ import '../../../cr_elements/shared_style_css.m.js'; import './bluetooth_battery_icon_percentage.js'; import {html, PolymerElement} from '//resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {BluetoothDeviceProperties} from 'chrome://resources/mojo/chromeos/services/bluetooth_config/public/mojom/cros_bluetooth_config.mojom-webui.js'; import {BatteryType} from './bluetooth_types.js'; import {getBatteryPercentage, hasAnyDetailedBatteryInfo} from './bluetooth_utils.js'; @@ -28,7 +29,7 @@ export class BluetoothDeviceBatteryInfoElement extends PolymerElement { static get properties() { return { /** - * @type {!chromeos.bluetoothConfig.mojom.BluetoothDeviceProperties} + * @type {!BluetoothDeviceProperties} */ device: { type: Object, @@ -55,7 +56,7 @@ export class BluetoothDeviceBatteryInfoElement extends PolymerElement { } /** - * @param {!chromeos.bluetoothConfig.mojom.BluetoothDeviceProperties} + * @param {!BluetoothDeviceProperties} * device * @return {boolean} * @private @@ -65,7 +66,7 @@ export class BluetoothDeviceBatteryInfoElement extends PolymerElement { } /** - * @param {!chromeos.bluetoothConfig.mojom.BluetoothDeviceProperties} + * @param {!BluetoothDeviceProperties} * device * @param {!BatteryType} batteryType * @return {boolean} diff --git a/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_icon.d.ts b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_icon.d.ts new file mode 100644 index 00000000000..b6a9bbf7efc --- /dev/null +++ b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_icon.d.ts @@ -0,0 +1,13 @@ +// Copyright 2022 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. + +import {PolymerElement} from '//resources/polymer/v3_0/polymer/polymer_bundled.min.js'; + +export class SettingsBluetoothIconElement extends PolymerElement {} + +declare global { + interface HTMLElementTagNameMap { + 'bluetooth-icon': SettingsBluetoothIconElement; + } +} diff --git a/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_icon.js b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_icon.js index 66b69a54834..996522709ba 100644 --- a/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_icon.js +++ b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_icon.js @@ -10,6 +10,8 @@ import './bluetooth_icons.js'; import {html, PolymerElement} from '//resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {BluetoothDeviceProperties, DeviceType} from 'chrome://resources/mojo/chromeos/services/bluetooth_config/public/mojom/cros_bluetooth_config.mojom-webui.js'; + import {hasDefaultImage} from './bluetooth_utils.js'; /** @polymer */ @@ -25,7 +27,7 @@ export class SettingsBluetoothIconElement extends PolymerElement { static get properties() { return { /** - * @type {!chromeos.bluetoothConfig.mojom.BluetoothDeviceProperties} + * @type {!BluetoothDeviceProperties} */ device: { type: Object, @@ -42,24 +44,23 @@ export class SettingsBluetoothIconElement extends PolymerElement { return 'default'; } - const deviceType = chromeos.bluetoothConfig.mojom.DeviceType; switch (this.device.deviceType) { - case deviceType.kComputer: + case DeviceType.kComputer: return 'computer'; - case deviceType.kPhone: + case DeviceType.kPhone: return 'phone'; - case deviceType.kHeadset: + case DeviceType.kHeadset: return 'headset'; - case deviceType.kVideoCamera: + case DeviceType.kVideoCamera: return 'video-camera'; - case deviceType.kGameController: + case DeviceType.kGameController: return 'game-controller'; - case deviceType.kKeyboard: - case deviceType.kKeyboardMouseCombo: + case DeviceType.kKeyboard: + case DeviceType.kKeyboardMouseCombo: return 'keyboard'; - case deviceType.kMouse: + case DeviceType.kMouse: return 'mouse'; - case deviceType.kTablet: + case DeviceType.kTablet: return 'tablet'; default: return 'default'; diff --git a/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_device_item.d.ts b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_device_item.d.ts new file mode 100644 index 00000000000..5556f051b23 --- /dev/null +++ b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_device_item.d.ts @@ -0,0 +1,13 @@ +// Copyright 2022 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. + +import {PolymerElement} from '//resources/polymer/v3_0/polymer/polymer_bundled.min.js'; + +export class SettingsBluetoothPairingDeviceItemElement extends PolymerElement {} + +declare global { + interface HTMLElementTagNameMap { + 'bluetooth-pairing-device-item': SettingsBluetoothPairingDeviceItemElement; + } +} diff --git a/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_device_item.js b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_device_item.js index d674c066d42..83abe3c02e1 100644 --- a/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_device_item.js +++ b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_device_item.js @@ -13,7 +13,10 @@ import './bluetooth_icon.js'; import {I18nBehavior, I18nBehaviorInterface} from '//resources/js/i18n_behavior.m.js'; import {html, mixinBehaviors, PolymerElement} from '//resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {FocusRowBehavior} from 'chrome://resources/js/cr/ui/focus_row_behavior.m.js'; +import {BluetoothDeviceProperties, DeviceType} from 'chrome://resources/mojo/chromeos/services/bluetooth_config/public/mojom/cros_bluetooth_config.mojom-webui.js'; + import {assertNotReached} from '../../../js/assert.m.js'; + import {DeviceItemState} from './bluetooth_types.js'; import {mojoString16ToString} from './bluetooth_utils.js'; @@ -39,7 +42,7 @@ export class SettingsBluetoothPairingDeviceItemElement extends static get properties() { return { /** - * @type {?chromeos.bluetoothConfig.mojom.BluetoothDeviceProperties} + * @type {?BluetoothDeviceProperties} */ device: Object, @@ -170,27 +173,26 @@ export class SettingsBluetoothPairingDeviceItemElement extends * @private */ getA11yDeviceTypeTextName_() { - const deviceType = chromeos.bluetoothConfig.mojom.DeviceType; switch (this.device.deviceType) { - case deviceType.kUnknown: + case DeviceType.kUnknown: return 'bluetoothA11yDeviceTypeUnknown'; - case deviceType.kComputer: + case DeviceType.kComputer: return 'bluetoothA11yDeviceTypeComputer'; - case deviceType.kPhone: + case DeviceType.kPhone: return 'bluetoothA11yDeviceTypePhone'; - case deviceType.kHeadset: + case DeviceType.kHeadset: return 'bluetoothA11yDeviceTypeHeadset'; - case deviceType.kVideoCamera: + case DeviceType.kVideoCamera: return 'bluetoothA11yDeviceTypeVideoCamera'; - case deviceType.kGameController: + case DeviceType.kGameController: return 'bluetoothA11yDeviceTypeGameController'; - case deviceType.kKeyboard: + case DeviceType.kKeyboard: return 'bluetoothA11yDeviceTypeKeyboard'; - case deviceType.kKeyboardMouseCombo: + case DeviceType.kKeyboardMouseCombo: return 'bluetoothA11yDeviceTypeKeyboardMouseCombo'; - case deviceType.kMouse: + case DeviceType.kMouse: return 'bluetoothA11yDeviceTypeMouse'; - case deviceType.kTablet: + case DeviceType.kTablet: return 'bluetoothA11yDeviceTypeTablet'; default: assertNotReached(); diff --git a/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_device_selection_page.d.ts b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_device_selection_page.d.ts new file mode 100644 index 00000000000..163d20fa465 --- /dev/null +++ b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_device_selection_page.d.ts @@ -0,0 +1,15 @@ +// Copyright 2022 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. + +import {PolymerElement} from '//resources/polymer/v3_0/polymer/polymer_bundled.min.js'; + +export class SettingsBluetoothPairingDeviceSelectionPageElementBase extends + PolymerElement {} + +declare global { + interface HTMLElementTagNameMap { + 'bluetooth-pairing-device-selection-page': + SettingsBluetoothPairingDeviceSelectionPageElementBase; + } +} diff --git a/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_device_selection_page.js b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_device_selection_page.js index 29c70f51ffd..9f64671e55c 100644 --- a/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_device_selection_page.js +++ b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_device_selection_page.js @@ -16,6 +16,7 @@ import '../../localized_link/localized_link.js'; import {CrScrollableBehavior, CrScrollableBehaviorInterface} from '//resources/cr_elements/cr_scrollable_behavior.m.js'; import {I18nBehavior, I18nBehaviorInterface} from '//resources/js/i18n_behavior.m.js'; import {afterNextRender, html, mixinBehaviors, PolymerElement} from '//resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {BluetoothDeviceProperties} from 'chrome://resources/mojo/chromeos/services/bluetooth_config/public/mojom/cros_bluetooth_config.mojom-webui.js'; import {ButtonBarState, ButtonState, DeviceItemState} from './bluetooth_types.js'; @@ -42,7 +43,7 @@ export class SettingsBluetoothPairingDeviceSelectionPageElement extends static get properties() { return { /** - * @type {!Array<!chromeos.bluetoothConfig.mojom.BluetoothDeviceProperties>} + * @type {!Array<!BluetoothDeviceProperties>} */ devices: { type: Array, @@ -60,7 +61,7 @@ export class SettingsBluetoothPairingDeviceSelectionPageElement extends }, /** - * @type {?chromeos.bluetoothConfig.mojom.BluetoothDeviceProperties} + * @type {?BluetoothDeviceProperties} */ devicePendingPairing: { type: Object, @@ -112,7 +113,7 @@ export class SettingsBluetoothPairingDeviceSelectionPageElement extends /** * The last device that was selected for pairing. - * @private {?chromeos.bluetoothConfig.mojom.BluetoothDeviceProperties} + * @private {?BluetoothDeviceProperties} */ this.lastSelectedDevice_ = null; } @@ -203,7 +204,7 @@ export class SettingsBluetoothPairingDeviceSelectionPageElement extends } /** - * @param {?chromeos.bluetoothConfig.mojom.BluetoothDeviceProperties} device + * @param {?BluetoothDeviceProperties} device * @return {!DeviceItemState} * @private */ diff --git a/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_enter_code_page.d.ts b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_enter_code_page.d.ts new file mode 100644 index 00000000000..ce29c7402ea --- /dev/null +++ b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_enter_code_page.d.ts @@ -0,0 +1,14 @@ +// Copyright 2022 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. + +import {PolymerElement} from '//resources/polymer/v3_0/polymer/polymer_bundled.min.js'; + +export class SettingsBluetoothPairingEnterCodeElement extends PolymerElement {} + +declare global { + interface HTMLElementTagNameMap { + 'bluetooth-pairing-enter-code-page': + SettingsBluetoothPairingEnterCodeElement; + } +} diff --git a/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_enter_code_page.js b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_enter_code_page.js index aa62d655182..041af85dae2 100644 --- a/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_enter_code_page.js +++ b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_enter_code_page.js @@ -15,8 +15,9 @@ import '//resources/polymer/v3_0/iron-flex-layout/iron-flex-layout-classes.js'; import {I18nBehavior, I18nBehaviorInterface} from '//resources/js/i18n_behavior.m.js'; import {html, mixinBehaviors, PolymerElement} from '//resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {assert} from 'chrome://resources/js/assert.m.js'; +import {BluetoothDeviceProperties} from 'chrome://resources/mojo/chromeos/services/bluetooth_config/public/mojom/cros_bluetooth_config.mojom-webui.js'; -import {ButtonBarState, ButtonState, PairingAuthType} from './bluetooth_types.js'; +import {ButtonBarState, ButtonState} from './bluetooth_types.js'; import {mojoString16ToString} from './bluetooth_utils.js'; // Pairing passkey can be a maximum of 16 characters while pairing code a max @@ -45,7 +46,7 @@ export class SettingsBluetoothPairingEnterCodeElement extends static get properties() { return { /** - * @type {?chromeos.bluetoothConfig.mojom.BluetoothDeviceProperties} + * @type {?BluetoothDeviceProperties} */ device: { type: Object, @@ -163,4 +164,4 @@ export class SettingsBluetoothPairingEnterCodeElement extends customElements.define( SettingsBluetoothPairingEnterCodeElement.is, - SettingsBluetoothPairingEnterCodeElement);
\ No newline at end of file + SettingsBluetoothPairingEnterCodeElement); diff --git a/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_request_code_page.d.ts b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_request_code_page.d.ts new file mode 100644 index 00000000000..8d069f2b425 --- /dev/null +++ b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_request_code_page.d.ts @@ -0,0 +1,14 @@ +// Copyright 2022 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. + +import {PolymerElement} from '//resources/polymer/v3_0/polymer/polymer_bundled.min.js'; + +export class SettingsBluetoothRequestCodePageElement extends PolymerElement {} + +declare global { + interface HTMLElementTagNameMap { + 'bluetooth-pairing-request-code-page': + SettingsBluetoothRequestCodePageElement; + } +} diff --git a/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_request_code_page.js b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_request_code_page.js index 26789f68ea6..fe31fc7a69e 100644 --- a/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_request_code_page.js +++ b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_request_code_page.js @@ -14,11 +14,11 @@ import '../../../cr_elements/cr_input/cr_input.m.js'; import {I18nBehavior, I18nBehaviorInterface} from '//resources/js/i18n_behavior.m.js'; import {afterNextRender, html, mixinBehaviors, PolymerElement} from '//resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {BluetoothDeviceProperties} from 'chrome://resources/mojo/chromeos/services/bluetooth_config/public/mojom/cros_bluetooth_config.mojom-webui.js'; import {ButtonBarState, ButtonState, PairingAuthType} from './bluetooth_types.js'; import {mojoString16ToString} from './bluetooth_utils.js'; - /** * Maximum length of a PIN code, it can range from 1 to 6 digits. * @type {number} @@ -53,7 +53,7 @@ export class SettingsBluetoothRequestCodePageElement extends static get properties() { return { /** - * @type {?chromeos.bluetoothConfig.mojom.BluetoothDeviceProperties} + * @type {?BluetoothDeviceProperties} */ device: { type: Object, diff --git a/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_ui.d.ts b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_ui.d.ts new file mode 100644 index 00000000000..91d4f5fd88c --- /dev/null +++ b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_ui.d.ts @@ -0,0 +1,13 @@ +// Copyright 2022 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. + +import {PolymerElement} from '//resources/polymer/v3_0/polymer/polymer_bundled.min.js'; + +export class SettingsBluetoothPairingUiElement extends PolymerElement {} + +declare global { + interface HTMLElementTagNameMap { + 'bluetooth-pairing-ui': SettingsBluetoothPairingUiElement; + } +} diff --git a/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_ui.js b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_ui.js index 572f67e3dce..b212670cd20 100644 --- a/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_ui.js +++ b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_pairing_ui.js @@ -15,24 +15,26 @@ import './bluetooth_pairing_confirm_code_page.js'; import './bluetooth_spinner_page.js'; import {html, PolymerElement} from '//resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {BluetoothDeviceProperties, BluetoothDiscoveryDelegateInterface, BluetoothDiscoveryDelegateReceiver, BluetoothSystemState, DevicePairingDelegateInterface, DevicePairingDelegateReceiver, DevicePairingHandlerInterface, KeyEnteredHandlerInterface, KeyEnteredHandlerPendingReceiver, KeyEnteredHandlerReceiver, PairingResult, SystemPropertiesObserverInterface, SystemPropertiesObserverReceiver} from 'chrome://resources/mojo/chromeos/services/bluetooth_config/public/mojom/cros_bluetooth_config.mojom-webui.js'; + import {assert, assertNotReached} from '../../../js/assert.m.js'; + import {PairingAuthType} from './bluetooth_types.js'; import {getBluetoothConfig} from './cros_bluetooth_config.js'; -/** @implements {chromeos.bluetoothConfig.mojom.KeyEnteredHandlerInterface} */ +/** @implements {KeyEnteredHandlerInterface} */ class KeyEnteredHandler { /** * @param {!SettingsBluetoothPairingUiElement} page - * @param {!chromeos.bluetoothConfig.mojom.KeyEnteredHandlerPendingReceiver} + * @param {!KeyEnteredHandlerPendingReceiver} * keyEnteredHandlerReceiver */ constructor(page, keyEnteredHandlerReceiver) { /** @private {!SettingsBluetoothPairingUiElement} */ this.page_ = page; - /** @private {!chromeos.bluetoothConfig.mojom.KeyEnteredHandlerReceiver} */ - this.keyEnteredHandlerReceiver_ = - new chromeos.bluetoothConfig.mojom.KeyEnteredHandlerReceiver(this); + /** @private {!KeyEnteredHandlerReceiver} */ + this.keyEnteredHandlerReceiver_ = new KeyEnteredHandlerReceiver(this); this.keyEnteredHandlerReceiver_.$.bindHandle( keyEnteredHandlerReceiver.handle); } @@ -73,10 +75,10 @@ let RequestCodeCallback; let ConfirmCodeCallback; /** - * @implements {chromeos.bluetoothConfig.mojom.SystemPropertiesObserverInterface} - * @implements {chromeos.bluetoothConfig.mojom.BluetoothDiscoveryDelegateInterface} - * @implements {chromeos.bluetoothConfig.mojom.DevicePairingDelegateInterface} - * @implements {chromeos.bluetoothConfig.mojom.KeyEnteredHandlerInterface} + * @implements {SystemPropertiesObserverInterface} + * @implements {BluetoothDiscoveryDelegateInterface} + * @implements {DevicePairingDelegateInterface} + * @implements {KeyEnteredHandlerInterface} * @polymer */ export class SettingsBluetoothPairingUiElement extends PolymerElement { @@ -124,7 +126,7 @@ export class SettingsBluetoothPairingUiElement extends PolymerElement { }, /** - * @private {Array<!chromeos.bluetoothConfig.mojom.BluetoothDeviceProperties>} + * @private {Array<!BluetoothDeviceProperties>} */ discoveredDevices_: { type: Array, @@ -134,7 +136,7 @@ export class SettingsBluetoothPairingUiElement extends PolymerElement { /** * This can be null if no pairing attempt was started or a pairing attempt * was cancelled by user. - * @private {?chromeos.bluetoothConfig.mojom.BluetoothDeviceProperties} + * @private {?BluetoothDeviceProperties} */ devicePendingPairing_: { type: Object, @@ -188,38 +190,37 @@ export class SettingsBluetoothPairingUiElement extends PolymerElement { constructor() { super(); /** - * @private {!chromeos.bluetoothConfig.mojom.SystemPropertiesObserverReceiver} + * @private {!SystemPropertiesObserverReceiver} */ this.systemPropertiesObserverReceiver_ = - new chromeos.bluetoothConfig.mojom.SystemPropertiesObserverReceiver( + new SystemPropertiesObserverReceiver( /** - * @type {!chromeos.bluetoothConfig.mojom.SystemPropertiesObserverInterface} + * @type {!SystemPropertiesObserverInterface} */ (this)); /** - * @private {!chromeos.bluetoothConfig.mojom.BluetoothDiscoveryDelegateReceiver} + * @private {!BluetoothDiscoveryDelegateReceiver} */ this.bluetoothDiscoveryDelegateReceiver_ = - new chromeos.bluetoothConfig.mojom.BluetoothDiscoveryDelegateReceiver( - this); + new BluetoothDiscoveryDelegateReceiver(this); /** - * @private {?chromeos.bluetoothConfig.mojom.DevicePairingHandlerInterface} + * @private {?DevicePairingHandlerInterface} */ this.devicePairingHandler_; /** * The device to be paired with after the current pairDevice_() request has * finished. - * @private {?chromeos.bluetoothConfig.mojom.BluetoothDeviceProperties} + * @private {?BluetoothDeviceProperties} */ this.queuedDevicePendingPairing_; /** * The Mojo receiver of the current ongoing pairing. If null indicates no * pairing is occurring. - * @private {?chromeos.bluetoothConfig.mojom.DevicePairingDelegateReceiver} + * @private {?DevicePairingDelegateReceiver} */ this.pairingDelegateReceiver_ = null; @@ -241,8 +242,6 @@ export class SettingsBluetoothPairingUiElement extends PolymerElement { ready() { super.ready(); - getBluetoothConfig().observeSystemProperties( - this.systemPropertiesObserverReceiver_.$.bindNewPipeAndPassRemote()); // If there's a specific device to pair with, immediately go to the spinner // page. @@ -251,19 +250,35 @@ export class SettingsBluetoothPairingUiElement extends PolymerElement { } } + connectedCallback() { + super.connectedCallback(); + + getBluetoothConfig().observeSystemProperties( + this.systemPropertiesObserverReceiver_.$.bindNewPipeAndPassRemote()); + } + disconnectedCallback() { super.disconnectedCallback(); + if (this.systemPropertiesObserverReceiver_) { + this.systemPropertiesObserverReceiver_.$.close(); + } if (this.bluetoothDiscoveryDelegateReceiver_) { this.bluetoothDiscoveryDelegateReceiver_.$.close(); } + if (this.pairingDelegateReceiver_) { + this.pairingDelegateReceiver_.$.close(); + } + if (this.keyEnteredReceiver_) { + this.keyEnteredReceiver_.close(); + } } /** @override */ onPropertiesUpdated(properties) { const wasBluetoothEnabled = this.isBluetoothEnabled_; - this.isBluetoothEnabled_ = properties.systemState === - chromeos.bluetoothConfig.mojom.BluetoothSystemState.kEnabled; + this.isBluetoothEnabled_ = + properties.systemState === BluetoothSystemState.kEnabled; if (!wasBluetoothEnabled && this.isBluetoothEnabled_) { // If Bluetooth enables after being disabled, initialize the UI state. @@ -299,7 +314,7 @@ export class SettingsBluetoothPairingUiElement extends PolymerElement { } /** - * @param {Array<!chromeos.bluetoothConfig.mojom.BluetoothDeviceProperties>} + * @param {Array<!BluetoothDeviceProperties>} * devices * @private */ @@ -356,7 +371,7 @@ export class SettingsBluetoothPairingUiElement extends PolymerElement { /** * @param {!CustomEvent<!{device: - * chromeos.bluetoothConfig.mojom.BluetoothDeviceProperties}>} event + * BluetoothDeviceProperties}>} event * @private */ onPairDevice_(event) { @@ -402,15 +417,14 @@ export class SettingsBluetoothPairingUiElement extends PolymerElement { } /** - * @param {!chromeos.bluetoothConfig.mojom.BluetoothDeviceProperties} device + * @param {!BluetoothDeviceProperties} device * @private */ pairDevice_(device) { assert( this.devicePairingHandler_, 'devicePairingHandler_ has not been set.'); - this.pairingDelegateReceiver_ = - new chromeos.bluetoothConfig.mojom.DevicePairingDelegateReceiver(this); + this.pairingDelegateReceiver_ = new DevicePairingDelegateReceiver(this); this.devicePendingPairing_ = device; assert(this.devicePendingPairing_); @@ -427,13 +441,12 @@ export class SettingsBluetoothPairingUiElement extends PolymerElement { .catch(() => { // Pairing failed due to external issues, such as Mojo pipe // disconnecting from Bluetooth disabling. - this.handlePairDeviceResult_( - chromeos.bluetoothConfig.mojom.PairingResult.kNonAuthFailure); + this.handlePairDeviceResult_(PairingResult.kNonAuthFailure); }); } /** - * @param {!chromeos.bluetoothConfig.mojom.PairingResult} result + * @param {!PairingResult} result * @private */ handlePairDeviceResult_(result) { @@ -449,7 +462,7 @@ export class SettingsBluetoothPairingUiElement extends PolymerElement { this.pairingDelegateReceiver_ = null; - if (result === chromeos.bluetoothConfig.mojom.PairingResult.kSuccess) { + if (result === PairingResult.kSuccess) { this.closeDialog_(); return; } @@ -546,7 +559,7 @@ export class SettingsBluetoothPairingUiElement extends PolymerElement { } /**s - * @param {!chromeos.bluetoothConfig.mojom.KeyEnteredHandlerPendingReceiver} + * @param {!KeyEnteredHandlerPendingReceiver} * handler * @param {string} code * @private diff --git a/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_utils.js b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_utils.js index cac2e654a7a..04112f74284 100644 --- a/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_utils.js +++ b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/bluetooth_utils.js @@ -2,16 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -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/string16.mojom-lite.js'; +import {BluetoothDeviceProperties, PairedBluetoothDeviceProperties} from 'chrome://resources/mojo/chromeos/services/bluetooth_config/public/mojom/cros_bluetooth_config.mojom-webui.js'; +import {String16} from 'chrome://resources/mojo/mojo/public/mojom/base/string16.mojom-webui.js'; import {BatteryType} from './bluetooth_types.js'; /** * Converts a JS string to mojoBase.mojom.String16 object. * @param {string} str - * @return {!mojoBase.mojom.String16} + * @return {!String16} */ export function stringToMojoString16(str) { const arr = []; @@ -23,7 +22,7 @@ export function stringToMojoString16(str) { /** * Converts mojoBase.mojom.String16 to a JS string. - * @param {!mojoBase.mojom.String16} str16 + * @param {!String16} str16 * @return {string} */ export function mojoString16ToString(str16) { @@ -31,8 +30,7 @@ export function mojoString16ToString(str16) { } /** - * @param {?chromeos.bluetoothConfig.mojom.PairedBluetoothDeviceProperties} - * device + * @param {?PairedBluetoothDeviceProperties} device * @return {string} */ export function getDeviceName(device) { @@ -53,8 +51,7 @@ export function getDeviceName(device) { * the battery type, or the battery percentage is out of bounds. Clients that * call this method should explicitly check if the return value is undefined to * differentiate it from a return value of 0. - * @param {!chromeos.bluetoothConfig.mojom.BluetoothDeviceProperties} - * device + * @param {!BluetoothDeviceProperties} device * @param {!BatteryType} batteryType * @return {number|undefined} */ @@ -98,8 +95,7 @@ export function getBatteryPercentage(device, batteryType) { /** * Returns true if the the device contains any multiple battery information. - * @param {!chromeos.bluetoothConfig.mojom.BluetoothDeviceProperties} - * device + * @param {!BluetoothDeviceProperties} device * @return {boolean} */ export function hasAnyDetailedBatteryInfo(device) { @@ -110,8 +106,7 @@ export function hasAnyDetailedBatteryInfo(device) { /** * Returns true if the device contains the default image URL. - * @param {!chromeos.bluetoothConfig.mojom.BluetoothDeviceProperties} - * device + * @param {!BluetoothDeviceProperties} device * @return {boolean} */ export function hasDefaultImage(device) { @@ -121,8 +116,7 @@ export function hasDefaultImage(device) { /** * Returns true if the device contains True Wireless Images. - * @param {!chromeos.bluetoothConfig.mojom.BluetoothDeviceProperties} - * device + * @param {!BluetoothDeviceProperties} device * @return {boolean} */ export function hasTrueWirelessImages(device) { diff --git a/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/cros_bluetooth_config.js b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/cros_bluetooth_config.js index 2aa44a51152..ed2010e82d8 100644 --- a/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/cros_bluetooth_config.js +++ b/chromium/ui/webui/resources/cr_components/chromeos/bluetooth/cros_bluetooth_config.js @@ -2,11 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// cros_bluetooth_config.mojom-lite.js depends on url.mojom.Url. -import 'chrome://resources/mojo/url/mojom/url.mojom-lite.js'; -// TODO(crbug.com/1010321): Use cros_bluetooth_config.mojom-webui.js instead -// as non-module JS is deprecated. -import 'chrome://resources/mojo/chromeos/services/bluetooth_config/public/mojom/cros_bluetooth_config.mojom-lite.js'; +import {CrosBluetoothConfig, CrosBluetoothConfigInterface} from 'chrome://resources/mojo/chromeos/services/bluetooth_config/public/mojom/cros_bluetooth_config.mojom-webui.js'; /** * @fileoverview @@ -14,11 +10,11 @@ import 'chrome://resources/mojo/chromeos/services/bluetooth_config/public/mojom/ * CrosBluetoothConfig implementation for tests. */ -/** @type {?chromeos.bluetoothConfig.mojom.CrosBluetoothConfigInterface} */ +/** @type {?CrosBluetoothConfigInterface} */ let bluetoothConfig = null; /** - * @param {?chromeos.bluetoothConfig.mojom.CrosBluetoothConfigInterface} + * @param {?CrosBluetoothConfigInterface} * testBluetoothConfig The CrosBluetoothConfig implementation used for * testing. Passing null reverses the override. */ @@ -27,14 +23,13 @@ export function setBluetoothConfigForTesting(testBluetoothConfig) { } /** - * @return {!chromeos.bluetoothConfig.mojom.CrosBluetoothConfigInterface} + * @return {!CrosBluetoothConfigInterface} */ export function getBluetoothConfig() { if (bluetoothConfig) { return bluetoothConfig; } - bluetoothConfig = - chromeos.bluetoothConfig.mojom.CrosBluetoothConfig.getRemote(); + bluetoothConfig = CrosBluetoothConfig.getRemote(); return bluetoothConfig; -}
\ No newline at end of file +} |