# Copyright 2019 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//ash/webui/media_app_ui/media_app_files.gni")
import("//ash/webui/media_app_ui/media_app_ui.gni")
import("//ash/webui/web_applications/system_apps.gni")
import("//build/buildflag_header.gni")
import("//build/config/chromeos/ui_mode.gni")
import("//mojo/public/tools/bindings/mojom.gni")
import("//tools/typescript/ts_library.gni")
import("//tools/typescript/webui_ts_library.gni")
assert(is_chromeos_ash, "Media App is ash-chrome only")
static_library("media_app_ui") {
sources = [
"file_system_access_helpers.cc",
"file_system_access_helpers.h",
"media_app_guest_ui.cc",
"media_app_guest_ui.h",
"media_app_page_handler.cc",
"media_app_page_handler.h",
"media_app_ui.cc",
"media_app_ui.h",
"media_app_ui_delegate.h",
"url_constants.cc",
"url_constants.h",
]
deps = [
":mojo_bindings",
":mojo_bindings_js",
":mojo_bindings_untrusted",
"//ash/constants:constants",
"//ash/webui/media_app_ui:buildflags",
"//ash/webui/resources:media_app_bundle_resources",
"//ash/webui/resources:media_app_resources",
"//ash/webui/system_apps/public:system_web_app_config",
"//ash/webui/system_apps/public:system_web_app_type",
"//ash/webui/web_applications",
"//chromeos/constants",
"//chromeos/strings",
"//content/public/browser",
"//content/public/common",
"//mojo/public/cpp/bindings",
"//mojo/public/cpp/platform",
"//third_party/blink/public/common",
"//ui/file_manager:resources",
"//ui/gfx/geometry/mojom",
"//ui/webui",
"//url/mojom:url_mojom_gurl",
]
}
source_set("browser_test_support") {
testonly = true
sources = [
"test/media_app_ui_browsertest.cc",
"test/media_app_ui_browsertest.h",
]
defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]
deps = [
":media_app_ui",
":test_build_ts",
"//ash/public/cpp:cpp",
"//ash/webui/web_applications/test:test_support",
"//chrome/test:test_support_ui",
]
data = [
"//ash/webui/system_apps/public/js/dom_testing_helpers.js",
"$target_gen_dir/driver.js",
"$target_gen_dir/guest_query_receiver.js",
"$target_gen_dir/media_app_guest_ui_browsertest.js",
"$target_gen_dir/media_app_ui_browsertest.js",
"$target_gen_dir/test_worker.js",
]
}
group("closure_compile") {
testonly = true
deps = [ "resources/js:closure_compile" ]
}
mojom("mojo_bindings") {
sources = [ "media_app_ui.mojom" ]
deps = [
"//third_party/blink/public/mojom:mojom_platform",
"//url/mojom:url_mojom_gurl",
]
}
mojom("mojo_bindings_untrusted") {
sources = [ "media_app_ui_untrusted.mojom" ]
public_deps = [
"//skia/public/mojom",
"//ui/gfx/geometry/mojom",
]
webui_module_path = "/"
}
copy("copy_mojo") {
visibility = [
":build_ts",
"//ash/webui/media_app_ui/resources/mock/js:stage_for_mock_tsc",
]
public_deps = [ ":mojo_bindings_untrusted_ts__generator" ]
sources = []
foreach(file, media_app_mojom_sources) {
sources += [ "$target_gen_dir/$file" ]
}
outputs = [ "${ts_root_dir}/{{source_file_part}}" ]
}
# All files in the rollup for the untrusted context should be here.
webui_ts_library("build_ts") {
root_dir = ts_root_dir
in_files = media_app_converted_ts_sources + media_app_unconverted_js_sources +
[ "piex_loader.ts" ]
# Add all Mojo TS as inputs to the TS compiler.
target_outputs = get_target_outputs(":copy_mojo")
foreach(o, target_outputs) {
in_files += [ rebase_path(o, ts_root_dir) ]
}
definitions = media_app_definitions_staged
# The out_dir needs to be a different folder from the folder containing files
# generated by targets in this BUILD.gn, otherwise it may be treated as an
# artifact from a previous build which will cause ts_library to delete them.
out_dir = "${target_gen_dir}/tsc"
composite = true
deps = [
"//ash/webui/common/resources:build_ts",
"//ash/webui/system_apps/public/js:build_ts",
"//ui/webui/resources/cr_components/color_change_listener:build_ts",
"//ui/webui/resources/mojo:build_ts",
]
extra_deps = [
":copy_mojo",
"//ash/webui/media_app_ui/resources/js:generate_definitions",
"//ash/webui/media_app_ui/resources/js:stage_for_tsc",
]
path_mappings = [ "//system_apps/*|" + rebase_path(
"$root_gen_dir/ash/webui/system_apps/public/js/*",
target_gen_dir) ]
}
# Supporting files for tests have historically been in ./test. That becomes a
# problem when using `ts_library` because we want to stage everything in
# ./gen/resources/js. In order for those paths to be merged, the `ts_library`
# rules must be here, in the common ancestor. Staging in ./test would trigger
# `Error: root_dir (...) should be within gen/.../test or ../../.../test`.
ts_library("test_build_ts") {
root_dir = ts_root_dir
testonly = true
in_files = media_app_test_ts
definitions = media_app_definitions_staged + media_app_test_definitions_staged
deps = [
":build_ts",
"//chrome/test/data/webui:build_ts",
]
extra_deps = [
"//ash/webui/media_app_ui/resources/js:generate_definitions",
"//ash/webui/media_app_ui/resources/js:stage_for_tsc",
"//ash/webui/media_app_ui/test:stage_for_test_tsc",
]
path_mappings = [ "chrome://webui-test/*|" +
rebase_path("$root_gen_dir/chrome/test/data/webui/tsc/*",
target_gen_dir) ]
}
# Used to turn off tests that only work with our CIPD package e.g. loading ink.
buildflag_header("buildflags") {
header = "buildflags.h"
flags = [ "ENABLE_CROS_MEDIA_APP=$enable_cros_media_app" ]
}