| # Copyright 2022 The Chromium Authors |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//chrome/browser/resources/tools/optimize_webui.gni") |
| import("//chrome/common/features.gni") |
| import("//third_party/closure_compiler/compile_js.gni") |
| import("//tools/grit/grit_rule.gni") |
| import("//tools/grit/preprocess_if_expr.gni") |
| import("//ui/webui/resources/tools/generate_grd.gni") |
| |
| js_type_check("closure_compile") { |
| is_polymer3 = true |
| closure_flags = default_closure_args + mojom_js_args |
| deps = [ |
| ":untrusted_closure_compile", |
| "//chrome/browser/ui/webui/image_editor:mojo_bindings_webui_js", |
| ] |
| } |
| |
| js_library("untrusted_closure_compile") { |
| sources = [ "untrusted/untrusted.js" ] |
| deps = [ |
| "//chrome/browser/ui/webui/image_editor:mojo_bindings_webui_js", |
| "//ui/webui/resources/js:cr.m", |
| "//ui/webui/resources/js:util.m", |
| ] |
| } |
| |
| grd_prefix = "image_editor" |
| preprocess_folder = "$target_gen_dir/preprocessed" |
| preprocess_manifest = "preprocessed_manifest.json" |
| |
| preprocess_if_expr("preprocess_untrusted") { |
| in_folder = "./untrusted/" #target_gen_dir |
| out_folder = preprocess_folder |
| out_manifest = "$target_gen_dir/untrusted/$preprocess_manifest" |
| in_files = [ |
| "untrusted.js", |
| "untrusted.html", |
| ] |
| } |
| |
| mojo_grdp = "$target_gen_dir/image_editor_mojo_resources.grdp" |
| generate_grd("build_image_editor_mojo_grdp") { |
| grd_prefix = grd_prefix |
| out_grd = mojo_grdp |
| input_files = [ "image_editor.mojom-webui.js" ] |
| deps = [ "//chrome/browser/ui/webui/image_editor:mojo_bindings_webui_js" ] |
| |
| input_files_base_dir = |
| rebase_path( |
| "$root_gen_dir/mojom-webui/chrome/browser/ui/webui/image_editor", |
| root_build_dir) |
| } |
| |
| generate_grd("build_trusted_grd") { |
| grd_prefix = grd_prefix |
| out_grd = "$target_gen_dir/resources.grd" |
| input_files = [ "image_editor.html" ] |
| |
| input_files_base_dir = rebase_path(".", "//") |
| } |
| |
| generate_grd("build_untrusted_grd") { |
| grd_prefix = "image_editor_untrusted" |
| out_grd = "$target_gen_dir/${grd_prefix}_resources.grd" |
| |
| deps = [ |
| ":build_image_editor_mojo_grdp", |
| ":preprocess_untrusted", |
| ] |
| manifest_files = [ "$target_gen_dir/untrusted/$preprocess_manifest" ] |
| |
| grdp_files = [ mojo_grdp ] |
| } |
| |
| grit("trusted_resources") { |
| source = "$target_gen_dir/resources.grd" |
| enable_input_discovery_for_gn_analyze = false |
| deps = [ ":build_trusted_grd" ] |
| |
| outputs = [ |
| "grit/image_editor_resources.h", |
| "grit/image_editor_resources_map.cc", |
| "grit/image_editor_resources_map.h", |
| "image_editor_resources.pak", |
| ] |
| output_dir = "$root_gen_dir/chrome" |
| } |
| |
| grit("untrusted_resources") { |
| source = "$target_gen_dir/image_editor_untrusted_resources.grd" |
| enable_input_discovery_for_gn_analyze = false |
| deps = [ |
| ":build_untrusted_grd", |
| "//chrome/browser/ui/webui/image_editor:mojo_bindings_webui_js", |
| ] |
| |
| outputs = [ |
| "grit/image_editor_untrusted_resources.h", |
| "grit/image_editor_untrusted_resources_map.cc", |
| "grit/image_editor_untrusted_resources_map.h", |
| "image_editor_untrusted_resources.pak", |
| ] |
| output_dir = "$root_gen_dir/chrome" |
| } |