Commit ab528d76 authored by Luciano Pacheco's avatar Luciano Pacheco Committed by Commit Bot

Files app: Generate JS Module for Audio Player Background deps

JS Modules for the following files:

//ui/file_manger/base/js/filtered_volume_manager.js
//ui/file_manger/file_manager/background/js/test_util_base.js
//ui/file_manger/audio_player/js:
 background.js
 error_util.js
 test_util.js


Add the main_background.m.js to act as the entry point for the
background page.

Bug: 1133186
Change-Id: If679c77d9e5226fc7931f4cbe042b50c17abb549
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2531596Reviewed-by: default avatarJeremie Boulic <jboulic@chromium.org>
Commit-Queue: Jeremie Boulic <jboulic@chromium.org>
Auto-Submit: Luciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826183}
parent d803e6ff
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import("//chrome/browser/resources/optimize_webui.gni") import("//chrome/browser/resources/optimize_webui.gni")
import("//third_party/closure_compiler/compile_js.gni") import("//third_party/closure_compiler/compile_js.gni")
import("//ui/webui/resources/tools/js_modulizer.gni")
group("closure_compile") { group("closure_compile") {
testonly = true testonly = true
...@@ -25,7 +26,11 @@ js_type_check("closure_compile_legacy") { ...@@ -25,7 +26,11 @@ js_type_check("closure_compile_legacy") {
js_type_check("closure_compile_jsmodules") { js_type_check("closure_compile_jsmodules") {
uses_js_modules = true uses_js_modules = true
deps = [ ":main.m" ] deps = [
":background.m",
":error_util.m",
":main.m",
]
} }
js_library("closure_compile_externs") { js_library("closure_compile_externs") {
...@@ -60,15 +65,40 @@ js_library("background") { ...@@ -60,15 +65,40 @@ js_library("background") {
] ]
} }
js_library("background.m") {
sources = [ "$root_gen_dir/ui/file_manager/audio_player/js/background.m.js" ]
deps = [
"//ui/file_manager/file_manager/background/js:app_window_wrapper.m",
"//ui/file_manager/file_manager/background/js:background_base.m",
"//ui/file_manager/file_manager/common/js:file_type.m",
"//ui/file_manager/file_manager/common/js:util.m",
]
extra_deps = [ ":modulize" ]
}
js_library("error_util") { js_library("error_util") {
} }
js_library("error_util.m") {
sources = [ "$root_gen_dir/ui/file_manager/audio_player/js/error_util.m.js" ]
extra_deps = [ ":modulize" ]
}
js_library("metadata_worker") { js_library("metadata_worker") {
deps = [ deps = [
"//ui/file_manager/file_manager/foreground/js/metadata:metadata_dispatcher", "//ui/file_manager/file_manager/foreground/js/metadata:metadata_dispatcher",
] ]
} }
js_library("test_util") {
}
js_library("test_util.m") {
sources = [ "$root_gen_dir/ui/file_manager/audio_player/js/test_util.m.js" ]
extra_deps = [ ":modulize" ]
}
js_library("main.m") { js_library("main.m") {
deps = [ deps = [
"//ui/file_manager/base/js:app_util.m", "//ui/file_manager/base/js:app_util.m",
...@@ -76,6 +106,22 @@ js_library("main.m") { ...@@ -76,6 +106,22 @@ js_library("main.m") {
] ]
} }
js_library("main_background.m") {
deps = [
":background.m",
":error_util.m",
"//ui/file_manager/file_manager/background/js:test_util_base.m",
]
}
js_modulizer("modulize") {
input_files = [
"background.js",
"error_util.js",
"test_util.js",
]
}
preprocess_folder = preprocess_folder =
rebase_path("$target_gen_dir/../../preprocessed/audio_player/js", rebase_path("$target_gen_dir/../../preprocessed/audio_player/js",
root_build_dir) root_build_dir)
......
...@@ -2,6 +2,13 @@ ...@@ -2,6 +2,13 @@
// 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.
// clang-format off
// #import {BackgroundBase} from '../../file_manager/background/js/background_base.m.js';
// #import {SingletonAppWindowWrapper} from '../../file_manager/background/js/app_window_wrapper.m.js';
// #import * as wrappedUtil from '../../file_manager/common/js/util.m.js'; const {util} = wrappedUtil;
// #import {FileType} from '../../file_manager/common/js/file_type.m.js';
// clang-format on
/** /**
* Icon of the audio player. * Icon of the audio player.
* Use maximum size and let ash downsample the icon. * Use maximum size and let ash downsample the icon.
...@@ -56,7 +63,7 @@ class AudioPlayerBackground extends BackgroundBase { ...@@ -56,7 +63,7 @@ class AudioPlayerBackground extends BackgroundBase {
* @type {!AudioPlayerBackground} * @type {!AudioPlayerBackground}
*/ */
// eslint-disable-next-line no-var // eslint-disable-next-line no-var
var background = new AudioPlayerBackground(); /* #export */ var background = new AudioPlayerBackground();
/** /**
* Audio player app window wrapper. * Audio player app window wrapper.
...@@ -71,7 +78,7 @@ const audioPlayer = new SingletonAppWindowWrapper( ...@@ -71,7 +78,7 @@ const audioPlayer = new SingletonAppWindowWrapper(
* playing. * playing.
* @return {!Promise} Promise to be fulfilled on success, or rejected on error. * @return {!Promise} Promise to be fulfilled on success, or rejected on error.
*/ */
function open(urls) { /* #export */ function open(urls) {
let position = 0; let position = 0;
const startUrl = (position < urls.length) ? urls[position] : ''; const startUrl = (position < urls.length) ? urls[position] : '';
......
// 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.
/**
* @fileoverview Entry point for it replaces background_scripts.js.
*/
import './error_util.m.js';
import './test_util.m.js';
import './background.m.js';
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
// 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.
// clang-format off
// #import {open} from './background.m.js';
// #import * as wrappedTest from '../../file_manager/background/js/test_util_base.m.js'; const {test} = wrappedTest;
// clang-format on
/** /**
* Opens the audio player and waits until it is ready. * Opens the audio player and waits until it is ready.
* *
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import("//third_party/closure_compiler/compile_js.gni") import("//third_party/closure_compiler/compile_js.gni")
import("//third_party/closure_compiler/js_unit_tests.gni") import("//third_party/closure_compiler/js_unit_tests.gni")
import("//ui/file_manager/base/gn/js_test_gen_html.gni") import("//ui/file_manager/base/gn/js_test_gen_html.gni")
import("//ui/webui/resources/js/cr.gni")
import("//ui/webui/resources/tools/js_modulizer.gni") import("//ui/webui/resources/tools/js_modulizer.gni")
visibility = [ "//ui/file_manager/*" ] visibility = [ "//ui/file_manager/*" ]
...@@ -24,6 +25,7 @@ js_type_check("closure_compile_jsmodules") { ...@@ -24,6 +25,7 @@ js_type_check("closure_compile_jsmodules") {
uses_js_modules = true uses_js_modules = true
deps = [ deps = [
":app_util.m", ":app_util.m",
":filtered_volume_manager.m",
":volume_manager_types.m", ":volume_manager_types.m",
] ]
} }
...@@ -82,6 +84,26 @@ js_library("filtered_volume_manager") { ...@@ -82,6 +84,26 @@ js_library("filtered_volume_manager") {
[ "//ui/file_manager/externs/background/volume_manager_factory.js" ] [ "//ui/file_manager/externs/background/volume_manager_factory.js" ]
} }
js_library("filtered_volume_manager.m") {
sources =
[ "$root_gen_dir/ui/file_manager/base/js/filtered_volume_manager.m.js" ]
deps = [
"//ui/file_manager/base/js:volume_manager_types.m",
"//ui/file_manager/externs:entry_location.m",
"//ui/file_manager/externs:files_app_entry_interfaces.m",
"//ui/file_manager/externs:volume_info.m",
"//ui/file_manager/externs:volume_info_list.m",
"//ui/file_manager/externs:volume_manager.m",
"//ui/file_manager/file_manager/common/js:files_app_entry_types.m",
"//ui/webui/resources/js:assert.m",
"//ui/webui/resources/js:cr.m",
"//ui/webui/resources/js/cr:event_target.m",
"//ui/webui/resources/js/cr/ui:array_data_model.m",
]
extra_deps = [ ":modulize" ]
}
js_library("mock_chrome") { js_library("mock_chrome") {
testonly = true testonly = true
} }
...@@ -157,9 +179,12 @@ js_library("mediasession_types.m") { ...@@ -157,9 +179,12 @@ js_library("mediasession_types.m") {
js_modulizer("modulize") { js_modulizer("modulize") {
input_files = [ input_files = [
"app_util.js", "app_util.js",
"volume_manager_types.js", "filtered_volume_manager.js",
"mock_chrome.js",
"mediasession_types.js", "mediasession_types.js",
"mock_chrome.js",
"test_error_reporting.js", "test_error_reporting.js",
"volume_manager_types.js",
] ]
namespace_rewrites = cr_namespace_rewrites
} }
...@@ -2,6 +2,19 @@ ...@@ -2,6 +2,19 @@
// 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.
// clang-format off
// #import {assert} from 'chrome://resources/js/assert.m.js';
// #import {VolumeInfo} from '../../externs/volume_info.m.js';
// #import {VolumeInfoList} from '../../externs/volume_info_list.m.js';
// #import {VolumeManager, ExternallyUnmountedEvent} from '../../externs/volume_manager.m.js';
// #import {FilesAppEntry} from '../../externs/files_app_entry_interfaces.m.js';
// #import {EntryLocation} from '../../externs/entry_location.m.js';
// #import * as wrappedVolumeManagerCommon from './volume_manager_types.m.js'; const {VolumeManagerCommon, AllowedPaths} = wrappedVolumeManagerCommon;
// #import {dispatchSimpleEvent} from 'chrome://resources/js/cr.m.js';
// #import {ArrayDataModel} from 'chrome://resources/js/cr/ui/array_data_model.m.js';
// #import {NativeEventTarget as EventTarget} from 'chrome://resources/js/cr/event_target.m.js';
// clang-format on
/** /**
* Implementation of VolumeInfoList for FilteredVolumeManager. * Implementation of VolumeInfoList for FilteredVolumeManager.
* In foreground/ we want to enforce this list to be filtered, so we forbid * In foreground/ we want to enforce this list to be filtered, so we forbid
...@@ -12,7 +25,7 @@ ...@@ -12,7 +25,7 @@
* @final * @final
* @implements {VolumeInfoList} * @implements {VolumeInfoList}
*/ */
class FilteredVolumeInfoList { /* #export */ class FilteredVolumeInfoList {
/** /**
* @param {!cr.ui.ArrayDataModel} list * @param {!cr.ui.ArrayDataModel} list
*/ */
...@@ -60,7 +73,7 @@ class FilteredVolumeInfoList { ...@@ -60,7 +73,7 @@ class FilteredVolumeInfoList {
* *
* @implements {VolumeManager} * @implements {VolumeManager}
*/ */
class FilteredVolumeManager extends cr.EventTarget { /* #export */ class FilteredVolumeManager extends cr.EventTarget {
/** /**
* *
* @param {!AllowedPaths} allowedPaths Which paths are supported in the Files * @param {!AllowedPaths} allowedPaths Which paths are supported in the Files
...@@ -117,7 +130,7 @@ class FilteredVolumeManager extends cr.EventTarget { ...@@ -117,7 +130,7 @@ class FilteredVolumeManager extends cr.EventTarget {
case AllowedPaths.ANY_PATH_OR_URL: case AllowedPaths.ANY_PATH_OR_URL:
return true; return true;
case AllowedPaths.NATIVE_PATH: case AllowedPaths.NATIVE_PATH:
return VolumeManagerCommon.VolumeType.isNative(volumeType); return VolumeManagerCommon.VolumeType.isNative(assert(volumeType));
} }
return false; return false;
} }
......
...@@ -138,4 +138,4 @@ ...@@ -138,4 +138,4 @@
* Event object which is dispached with 'externally-unmounted' event. * Event object which is dispached with 'externally-unmounted' event.
* @typedef {!CustomEvent<!VolumeInfo>} * @typedef {!CustomEvent<!VolumeInfo>}
*/ */
let ExternallyUnmountedEvent; /* #export */ let ExternallyUnmountedEvent;
...@@ -76,6 +76,7 @@ js_type_check("closure_compile_jsmodules") { ...@@ -76,6 +76,7 @@ js_type_check("closure_compile_jsmodules") {
":app_windows.m", ":app_windows.m",
":background_base.m", ":background_base.m",
":entry_location_impl.m", ":entry_location_impl.m",
":test_util_base.m",
":volume_info_impl.m", ":volume_info_impl.m",
":volume_info_list_impl.m", ":volume_info_list_impl.m",
":volume_manager_factory.m", ":volume_manager_factory.m",
...@@ -628,6 +629,12 @@ js_unittest("task_queue_unittest") { ...@@ -628,6 +629,12 @@ js_unittest("task_queue_unittest") {
js_library("test_util_base") { js_library("test_util_base") {
} }
js_library("test_util_base.m") {
visibility += related_apps
sources = [ "$root_gen_dir/ui/file_manager/file_manager/background/js/test_util_base.m.js" ]
extra_deps = [ ":modulize" ]
}
js_library("test_import_history") { js_library("test_import_history") {
testonly = true testonly = true
deps = [ deps = [
...@@ -787,6 +794,7 @@ js_modulizer("modulize") { ...@@ -787,6 +794,7 @@ js_modulizer("modulize") {
"background_base.js", "background_base.js",
"entry_location_impl.js", "entry_location_impl.js",
"mock_volume_manager.js", "mock_volume_manager.js",
"test_util_base.js",
"volume_info_impl.js", "volume_info_impl.js",
"volume_info_list_impl.js", "volume_info_list_impl.js",
"volume_manager_factory.js", "volume_manager_factory.js",
......
...@@ -2,9 +2,15 @@ ...@@ -2,9 +2,15 @@
// 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.
/**
* @fileoverview
* @suppress {uselessCode} Temporary suppress because of the line exporting.
*/
/** /**
* Namespace for test related things. * Namespace for test related things.
*/ */
// eslint-disable-next-line no-var
var test = test || {}; var test = test || {};
/** /**
...@@ -84,7 +90,7 @@ test.util.registerRemoteTestUtils = () => { ...@@ -84,7 +90,7 @@ test.util.registerRemoteTestUtils = () => {
} }
// Asynchronously load the testing functions. // Asynchronously load the testing functions.
let script = document.createElement('script'); const script = document.createElement('script');
document.body.appendChild(script); document.body.appendChild(script);
script.onload = () => { script.onload = () => {
...@@ -110,3 +116,6 @@ test.util.registerRemoteTestUtils = () => { ...@@ -110,3 +116,6 @@ test.util.registerRemoteTestUtils = () => {
return true; return true;
}); });
}; };
// eslint-disable-next-line semi,no-extra-semi
/* #export */ {test};
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