| # Copyright 2018 The Chromium Authors |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//pdf/features.gni") |
| import("//ui/webui/resources/tools/build_webui.gni") |
| import("//ui/webui/resources/tools/generate_grd.gni") |
| import("//ui/webui/resources/tools/optimize_webui.gni") |
| |
| assert(enable_pdf, "enable_pdf check failed") |
| |
| build_webui("build") { |
| static_files = [ |
| "index.css", |
| "index.html", |
| "index_print.html", |
| "pdf_embedder.css", |
| ] |
| |
| # TODO(crbug.com/362783117): Check in the .html.ts files for these two |
| # elements, once the bug with <if expr> breaking UIs when JS code coverage |
| # is enabled has been fixed. |
| web_component_files = [ |
| "elements/viewer_toolbar.ts", |
| "pdf_viewer.ts", |
| ] |
| |
| ts_files = [ |
| "before_unload_proxy.ts", |
| "bookmark_type.ts", |
| "browser_api.ts", |
| "constants.ts", |
| "controller.ts", |
| "elements/viewer_attachment.html.ts", |
| "elements/viewer_attachment.ts", |
| "elements/viewer_attachment_bar.html.ts", |
| "elements/viewer_attachment_bar.ts", |
| "elements/viewer_bookmark.html.ts", |
| "elements/viewer_bookmark.ts", |
| "elements/viewer_document_outline.html.ts", |
| "elements/viewer_document_outline.ts", |
| "elements/viewer_download_controls.html.ts", |
| "elements/viewer_download_controls.ts", |
| "elements/viewer_error_dialog.html.ts", |
| "elements/viewer_error_dialog.ts", |
| "elements/viewer_page_selector.html.ts", |
| "elements/viewer_page_selector.ts", |
| "elements/viewer_password_dialog.html.ts", |
| "elements/viewer_password_dialog.ts", |
| "elements/viewer_pdf_sidenav.html.ts", |
| "elements/viewer_pdf_sidenav.ts", |
| "elements/viewer_properties_dialog.html.ts", |
| "elements/viewer_properties_dialog.ts", |
| "elements/viewer_save_controls_mixin.ts", |
| "elements/viewer_thumbnail.html.ts", |
| "elements/viewer_thumbnail.ts", |
| "elements/viewer_thumbnail_bar.html.ts", |
| "elements/viewer_thumbnail_bar.ts", |
| "gesture_detector.ts", |
| "internal_plugin.ts", |
| "local_storage_proxy.ts", |
| "main.ts", |
| "message_converter.ts", |
| "metrics.ts", |
| "navigator.ts", |
| "open_pdf_params_parser.ts", |
| "pdf_internal_plugin_wrapper.ts", |
| "pdf_print_wrapper.ts", |
| "pdf_scripting_api.ts", |
| "pdf_viewer_base.ts", |
| "pdf_viewer_private_proxy.ts", |
| "pdf_viewer_utils.ts", |
| "pdf_viewer_wrapper.ts", |
| "swipe_detector.ts", |
| "viewport.ts", |
| "zoom_manager.ts", |
| |
| # Files only used in Print Preview's PDF viewer UI. |
| "elements/viewer_page_indicator.html.ts", |
| "elements/viewer_page_indicator.ts", |
| "elements/viewer_zoom_button.html.ts", |
| "elements/viewer_zoom_button.ts", |
| "elements/viewer_zoom_toolbar.html.ts", |
| "elements/viewer_zoom_toolbar.ts", |
| "main_print.ts", |
| "pdf_viewer_print.html.ts", |
| "pdf_viewer_print.ts", |
| "toolbar_manager.ts", |
| ] |
| |
| if (enable_pdf_ink2) { |
| ts_files += [ |
| "elements/ink_annotation_brush_mixin.ts", |
| "elements/ink_annotation_text_mixin.ts", |
| "elements/ink_brush_selector.html.ts", |
| "elements/ink_brush_selector.ts", |
| "elements/ink_color_selector.html.ts", |
| "elements/ink_color_selector.ts", |
| "elements/ink_size_selector.html.ts", |
| "elements/ink_size_selector.ts", |
| "elements/ink_text_box.html.ts", |
| "elements/ink_text_box.ts", |
| "elements/ink_text_observer_mixin.ts", |
| "elements/selectable_icon_button.html.ts", |
| "elements/selectable_icon_button.ts", |
| "elements/text_alignment_selector.html.ts", |
| "elements/text_alignment_selector.ts", |
| "elements/text_styles_selector.html.ts", |
| "elements/text_styles_selector.ts", |
| "elements/viewer_bottom_toolbar.html.ts", |
| "elements/viewer_bottom_toolbar.ts", |
| "elements/viewer_bottom_toolbar_dropdown.html.ts", |
| "elements/viewer_bottom_toolbar_dropdown.ts", |
| "elements/viewer_side_panel.html.ts", |
| "elements/viewer_side_panel.ts", |
| "elements/viewer_text_bottom_toolbar.html.ts", |
| "elements/viewer_text_bottom_toolbar.ts", |
| "elements/viewer_text_side_panel.html.ts", |
| "elements/viewer_text_side_panel.ts", |
| "ink2_manager.ts", |
| ] |
| } |
| |
| if (enable_pdf_save_to_drive) { |
| ts_files += [ |
| "save_to_drive_metrics.ts", |
| "elements/circular_progress_ring.html.ts", |
| "elements/circular_progress_ring.ts", |
| "elements/viewer_save_to_drive_bubble.html.ts", |
| "elements/viewer_save_to_drive_bubble.ts", |
| "elements/viewer_save_to_drive_controls.html.ts", |
| "elements/viewer_save_to_drive_controls.ts", |
| ] |
| } |
| |
| css_files = [ |
| "elements/pdf_shared.css", |
| "elements/shared_vars.css", |
| "elements/viewer_attachment.css", |
| "elements/viewer_attachment_bar.css", |
| "elements/viewer_bookmark.css", |
| "elements/viewer_document_outline.css", |
| "elements/viewer_page_selector.css", |
| "elements/viewer_password_dialog.css", |
| "elements/viewer_pdf_sidenav.css", |
| "elements/viewer_properties_dialog.css", |
| "elements/viewer_save_controls_shared.css", |
| "elements/viewer_thumbnail.css", |
| "elements/viewer_thumbnail_bar.css", |
| "elements/viewer_toolbar.css", |
| "pdf_viewer.css", |
| "pdf_viewer_shared_style.css", |
| |
| # Files only used in Print Preview's PDF Viewer UI. |
| "elements/viewer_page_indicator.css", |
| "elements/viewer_zoom_button.css", |
| "elements/viewer_zoom_toolbar.css", |
| "pdf_viewer_print.css", |
| ] |
| |
| if (enable_pdf_ink2) { |
| css_files += [ |
| "elements/bottom_toolbar_shared.css", |
| "elements/ink_brush_selector.css", |
| "elements/ink_color_selector.css", |
| "elements/ink_size_selector.css", |
| "elements/ink_text_box.css", |
| "elements/selectable_icon_button.css", |
| "elements/side_panel_shared.css", |
| "elements/text_alignment_selector.css", |
| "elements/text_styles_selector.css", |
| "elements/viewer_bottom_toolbar.css", |
| "elements/viewer_bottom_toolbar_dropdown.css", |
| "elements/viewer_side_panel.css", |
| "elements/viewer_text_bottom_toolbar.css", |
| "elements/viewer_text_side_panel.css", |
| ] |
| } |
| |
| if (enable_pdf_save_to_drive) { |
| css_files += [ |
| "elements/circular_progress_ring.css", |
| "elements/viewer_save_to_drive_bubble.css", |
| "elements/viewer_save_to_drive_controls.css", |
| ] |
| } |
| |
| icons_html_files = [ "elements/icons.html" ] |
| |
| html_to_wrapper_scheme = "chrome" |
| |
| # TypeScript Compiler parameters |
| ts_composite = true |
| ts_definitions = [ |
| "//tools/typescript/definitions/chrome_event.d.ts", |
| "//tools/typescript/definitions/content_settings.d.ts", |
| "//tools/typescript/definitions/file_system.d.ts", |
| "//tools/typescript/definitions/metrics_private.d.ts", |
| "//tools/typescript/definitions/mime_handler_private.d.ts", |
| "//tools/typescript/definitions/pdf_viewer_private.d.ts", |
| "//tools/typescript/definitions/pending.d.ts", |
| "//tools/typescript/definitions/resources_private.d.ts", |
| "//tools/typescript/definitions/runtime.d.ts", |
| "//tools/typescript/definitions/tabs.d.ts", |
| "//tools/typescript/definitions/windows.d.ts", |
| ] |
| ts_deps = [ |
| "//third_party/lit/v3_0:build_ts", |
| "//ui/webui/resources/cr_components/help_bubble:build_ts", |
| "//ui/webui/resources/cr_elements:build_ts", |
| "//ui/webui/resources/js:build_ts", |
| ] |
| |
| # grd file generation parameters |
| grd_prefix = "pdf" |
| extra_grdp_deps = [ ":build_internal_plugin_grdp" ] |
| extra_grdp_files = [ "$target_gen_dir/internal_plugin_resources.grdp" ] |
| grd_resource_path_prefix = "pdf" |
| |
| eslint_enable_web_component_missing_deps = true |
| |
| # Optimization parameters |
| webui_context_type = "trusted_only" |
| optimize = optimize_webui |
| if (optimize) { |
| optimize_webui_host = "chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai" |
| optimize_webui_in_files = [ |
| "pdf_viewer_wrapper.js", |
| "pdf_print_wrapper.js", |
| ] |
| optimize_webui_excludes = [ |
| "browser_api.js", |
| |
| # Exclude pdf_scripting_api so that Print Preview can import |
| # pdfCreateOutOfProcessPlugin without importing the entire PDF bundle. |
| "pdf_scripting_api.js", |
| ] |
| extra_grdp_deps += [ ":build_excluded_grdp" ] |
| extra_grdp_files += [ "$target_gen_dir/excluded_resources.grdp" ] |
| } |
| } |
| |
| # Extra grdp build targets |
| |
| tsc_folder = "tsc" |
| |
| # This script is injected by `pdf::PluginResponseWriter`, and must stand alone. |
| # Consequently, it must always be rolled up by `optimize_webui()`. |
| build_internal_plugin_manifest = "build_internal_plugin_manifest.json" |
| optimize_webui("build_internal_plugin") { |
| host = "about:blank" |
| input = rebase_path("$target_gen_dir/$tsc_folder", root_build_dir) |
| js_module_in_files = [ "pdf_internal_plugin_wrapper.js" ] |
| out_manifest = "$target_gen_dir/$build_internal_plugin_manifest" |
| |
| deps = [ ":build_ts" ] |
| excludes = [ "browser_api.js" ] |
| } |
| |
| generate_grd("build_internal_plugin_grdp") { |
| manifest_files = [ "$target_gen_dir/$build_internal_plugin_manifest" ] |
| deps = [ ":build_internal_plugin" ] |
| grd_prefix = "pdf" |
| resource_path_prefix = "pdf" |
| out_grd = "$target_gen_dir/internal_plugin_resources.grdp" |
| } |
| |
| if (optimize_webui) { |
| # Need to manually register files that are excluded from the optimized bundle. |
| generate_grd("build_excluded_grdp") { |
| input_files = [ |
| "browser_api.js", |
| "main.js", |
| "main_print.js", |
| "pdf_scripting_api.js", |
| ] |
| input_files_base_dir = |
| rebase_path("$target_gen_dir/$tsc_folder", root_build_dir) |
| deps = [ ":build_ts" ] |
| |
| grd_prefix = "pdf" |
| out_grd = "$target_gen_dir/excluded_resources.grdp" |
| resource_path_prefix = "pdf" |
| } |
| } |