chromium/chrome/browser/resources/print_preview/BUILD.gn

# 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("//build/config/chromeos/ui_mode.gni")
import("//printing/buildflags/buildflags.gni")

import("//ui/webui/resources/tools/build_webui.gni")

assert(enable_print_preview, "enable_print_preview check failed")

build_webui("build") {
  grd_prefix = "print_preview"

  static_files = [ "print_preview.html" ]

  # Files holding a Polymer element definition and have an equivalent .html file.
  web_component_files = [
    "ui/advanced_options_settings.ts",
    "ui/advanced_settings_dialog.ts",
    "ui/advanced_settings_item.ts",
    "ui/app.ts",
    "ui/button_strip.ts",
    "ui/color_settings.ts",
    "ui/copies_settings.ts",
    "ui/destination_list.ts",
    "ui/destination_settings.ts",
    "ui/dpi_settings.ts",
    "ui/duplex_settings.ts",
    "ui/header.ts",
    "ui/layout_settings.ts",
    "ui/margin_control.ts",
    "ui/margin_control_container.ts",
    "ui/margins_settings.ts",
    "ui/media_size_settings.ts",
    "ui/media_type_settings.ts",
    "ui/more_settings.ts",
    "ui/number_settings_section.ts",
    "ui/other_options_settings.ts",
    "ui/pages_per_sheet_settings.ts",
    "ui/pages_settings.ts",
    "ui/preview_area.ts",
    "ui/print_preview_search_box.ts",
    "ui/scaling_settings.ts",
    "ui/settings_section.ts",
    "ui/settings_select.ts",
    "ui/sidebar.ts",
  ]

  if (is_chromeos) {
    web_component_files += [
      "ui/destination_dropdown_cros.ts",
      "ui/destination_list_item_cros.ts",
      "ui/destination_select_cros.ts",
      "ui/pin_settings.ts",
      "ui/printer_setup_info_cros.ts",
      "ui/provisional_destination_resolver.ts",
      "ui/destination_dialog_cros.ts",
      "ui/searchable_drop_down_cros.ts",
    ]
  } else {
    web_component_files += [
      "ui/destination_select.ts",
      "ui/link_container.ts",
      "ui/destination_dialog.ts",
      "ui/destination_list_item.ts",
    ]
  }

  non_web_component_files = [
    "dark_mode_mixin.ts",
    "metrics.ts",
    "native_layer.ts",
    "print_preview.ts",
    "print_preview_utils.ts",
    "data/cdd.ts",
    "data/coordinate2d.ts",
    "data/destination.ts",
    "data/destination_match.ts",
    "data/destination_store.ts",
    "data/document_info.ts",
    "data/local_parsers.ts",
    "data/margins.ts",
    "data/measurement_system.ts",
    "data/model.ts",
    "data/printable_area.ts",
    "data/scaling.ts",
    "data/size.ts",
    "data/state.ts",
    "ui/highlight_utils.ts",
    "ui/input_mixin.ts",
    "ui/plugin_proxy.ts",
    "ui/select_mixin.ts",
    "ui/settings_mixin.ts",
  ]

  if (is_chromeos) {
    non_web_component_files += [
      "data/print_server_store.ts",
      "data/printer_status_cros.ts",
      "native_layer_cros.ts",
    ]
  }

  # Files that are passed as input to css_to_wrapper().
  css_files = [
    "ui/destination_dialog_style.css",
    "ui/destination_list_item_style.css",
    "ui/destination_select_style.css",
    "ui/print_preview_shared.css",
    "ui/print_preview_vars.css",
    "ui/throbber.css",
  ]

  icons_html_files = [ "ui/icons.html" ]

  ts_composite = true
  ts_definitions = [
    "//tools/typescript/definitions/chrome_event.d.ts",
    "//tools/typescript/definitions/chrome_send.d.ts",
    "//tools/typescript/definitions/mime_handler_private.d.ts",
    "//tools/typescript/definitions/pending.d.ts",
  ]

  ts_deps = [
    "//chrome/browser/resources/pdf:build_ts",
    "//third_party/polymer/v3_0:library",
    "//ui/webui/resources/cr_elements:build_ts",
    "//ui/webui/resources/js:build_ts",
  ]

  ts_path_mappings = [ "chrome://print/pdf/*|" + rebase_path(
                           "$root_gen_dir/chrome/browser/resources/pdf/tsc/*",
                           target_gen_dir) ]

  webui_context_type = "trusted"
  optimize = optimize_webui
  if (optimize) {
    optimize_webui_host = "print"
    optimize_webui_in_files = [ "print_preview.js" ]
    optimize_webui_excludes = [ "chrome://print/pdf/pdf_scripting_api.js" ]
  }
}