Skip to content

Commit

Permalink
Nearby Share: Convert shared code to TS
Browse files Browse the repository at this point in the history
Convert shared Nearby share code to TS. Temporary externs are created
to satisfy Closure compilation until the main chrome://nearby app is
also converted to TS.

Bug: b/263413628
Test: browser_tests --gtest_filter="Nearby*"
Test: browser_tests --gtest_filter="OSSettings*"
Change-Id: I656abf4a8c49e400fd8e36de23d1de6985dfa8ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4272932
Reviewed-by: Demetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: Pu Shi <pushi@google.com>
Commit-Queue: Wes Okuhara <wesokuhara@google.com>
Cr-Commit-Position: refs/heads/main@{#1108662}
  • Loading branch information
Wes Okuhara authored and Chromium LUCI CQ committed Feb 22, 2023
1 parent 2450f7e commit a65f649
Show file tree
Hide file tree
Showing 41 changed files with 1,000 additions and 1,150 deletions.
1 change: 0 additions & 1 deletion chrome/browser/resources/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ if (is_chromeos_ash && enable_js_type_check) {
"gaia_auth_host:closure_compile",
"nearby_internals:closure_compile",
"nearby_share:closure_compile",
"nearby_share/shared:closure_compile_module",
]
}
}
Expand Down
22 changes: 9 additions & 13 deletions chrome/browser/resources/nearby_share/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,15 @@ js_library("app") {
deps = [
":nearby_confirmation_page",
":nearby_discovery_page",
"./shared:nearby_onboarding_one_page",
"./shared:nearby_onboarding_page",
"./shared:nearby_share_settings_behavior",
"./shared:nearby_visibility_page",
"./shared:types",
"//ash/webui/common/resources:load_time_data.m",
"//chrome/browser/ui/webui/nearby_share:mojom_webui_js",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
]
externs_list = [ "//ui/webui/resources/cr_elements/cr_view_manager/cr_view_manager_externs.js" ]
externs_list = [
"//ui/webui/resources/cr_elements/cr_view_manager/cr_view_manager_externs.js",
"./shared/shared_closure_types.js",
"$externs_path/chrome_send.js",
]
}

js_library("discovery_manager") {
Expand All @@ -184,22 +183,19 @@ js_library("discovery_manager") {

js_library("nearby_confirmation_page") {
deps = [
"./shared:nearby_preview",
"./shared:nearby_progress",
"./shared:types",
"//ash/webui/common/resources:i18n_behavior",
"//chrome/browser/ui/webui/nearby_share:mojom_webui_js",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
]
externs_list =
[ "//ui/webui/resources/cr_elements/cr_button/cr_button_externs.js" ]
externs_list = [
"//ui/webui/resources/cr_elements/cr_button/cr_button_externs.js",
"./shared/shared_closure_types.js",
]
}

js_library("nearby_discovery_page") {
deps = [
":discovery_manager",
"./shared:nearby_device",
"./shared:nearby_preview",
"//ash/webui/common/resources:assert",
"//chrome/browser/ui/webui/nearby_share:mojom_webui_js",
"//third_party/polymer/v3_0/components-chromium/iron-list",
Expand Down
25 changes: 19 additions & 6 deletions chrome/browser/resources/nearby_share/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {loadTimeData} from 'chrome://resources/ash/common/load_time_data.m.js';
import {mixinBehaviors, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';

import {getTemplate} from './app.html.js';
import {NearbyShareSettingsBehavior, NearbyShareSettingsBehaviorInterface} from './shared/nearby_share_settings_behavior.js';
import {NearbyShareSettingsMixin} from './shared/nearby_share_settings_mixin.js';
import {CloseReason} from './shared/types.js';

/**
Expand All @@ -23,6 +23,20 @@ import {CloseReason} from './shared/types.js';
* of the ChromeOS share sheet.
*/

/**
* TODO: Remove this manual type declaration once this file is converted to TS.
*
* The reason a page was closed. Keep in sync with NearbyShareDialogUI.
* @enum {number}
*/
const CloseReasonType = {
UNKNOWN: 0,
TRANSFER_STARTED: 1,
TRANSFER_SUCCEEDED: 2,
CANCELLED: 3,
REJECTED: 4,
};

/** @enum {string} */
const Page = {
CONFIRMATION: 'confirmation',
Expand All @@ -35,10 +49,9 @@ const Page = {
/**
* @constructor
* @extends {PolymerElement}
* @implements {NearbyShareSettingsBehaviorInterface}
* @implements {NearbyShareSettingsMixinInterface}
*/
const NearbyShareAppElementBase =
mixinBehaviors([NearbyShareSettingsBehavior], PolymerElement);
const NearbyShareAppElementBase = NearbyShareSettingsMixin(PolymerElement);

/** @polymer */
export class NearbyShareAppElement extends NearbyShareAppElementBase {
Expand Down Expand Up @@ -111,7 +124,7 @@ export class NearbyShareAppElement extends NearbyShareAppElementBase {
this.addEventListener(
'close',
e => this.onClose_(
/** @type {!CustomEvent<!{reason: CloseReason}>} */ (e)));
/** @type {!CustomEvent<!{reason: CloseReasonType}>} */ (e)));
this.addEventListener('onboarding-complete', this.onOnboardingComplete_);
}

Expand Down Expand Up @@ -183,7 +196,7 @@ export class NearbyShareAppElement extends NearbyShareAppElementBase {

/**
* Handler for the close event.
* @param {!CustomEvent<!{reason: CloseReason}>} event
* @param {!CustomEvent<!{reason: CloseReasonType}>} event
* @private
*/
onClose_(event) {
Expand Down

0 comments on commit a65f649

Please sign in to comment.