chromium/ash/webui/camera_app_ui/BUILD.gn

# Copyright 2020 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/camera_app_ui/resources/css/css.gni")
import("//ash/webui/camera_app_ui/resources/images/images.gni")
import("//ash/webui/camera_app_ui/resources/js/js.gni")
import("//ash/webui/camera_app_ui/resources/sounds/sounds.gni")
import("//ash/webui/camera_app_ui/resources/views/views.gni")
import("//build/config/chromeos/ui_mode.gni")
import("//mojo/public/tools/bindings/mojom.gni")
import("//ui/webui/resources/tools/generate_grd.gni")

assert(is_chromeos_ash, "Camera App is ash-chrome only")

static_library("camera_app_ui") {
  sources = [
    "camera_app_helper_impl.cc",
    "camera_app_helper_impl.h",
    "camera_app_ui.cc",
    "camera_app_ui.h",
    "camera_app_ui_delegate.h",
    "camera_app_untrusted_ui.cc",
    "camera_app_untrusted_ui.h",
    "resources.h",
    "url_constants.cc",
    "url_constants.h",
  ]

  public_deps = [
    "resources/strings",
    "//ash/webui/resources:camera_app_resources",
  ]

  deps = [
    ":document_scanning",
    ":events_sender",
    ":mojo_bindings",
    ":window_managemet",
    "//ash",
    "//ash/public/cpp",
    "//ash/webui/common:trusted_types_util",
    "//ash/webui/system_apps/public:system_web_app_config",
    "//ash/webui/web_applications",
    "//chromeos/ash/components/dbus/session_manager:session_manager",
    "//chromeos/ash/components/mojo_service_manager",
    "//chromeos/utils",
    "//components/arc",
    "//components/media_device_salt",
    "//components/onc",
    "//content/public/browser",
    "//content/public/common",
    "//media/capture:capture_lib",
    "//media/capture/video/chromeos/mojom:system_event_monitor",
    "//mojo/public/cpp/bindings",
    "//mojo/public/js:resources_grit",
    "//net",
    "//services/network/public/mojom",
    "//ui/webui",
  ]
}

source_set("window_managemet") {
  sources = [
    "camera_app_window_state_controller.cc",
    "camera_app_window_state_controller.h",
  ]

  deps = [
    ":mojo_bindings",
    "//ash/public/cpp",
    "//base",
    "//content/public/browser",
    "//mojo/public/cpp/bindings",
    "//ui/aura",
    "//ui/views",
  ]
}

source_set("events_sender") {
  sources = [
    "camera_app_events_sender.cc",
    "camera_app_events_sender.h",
  ]

  deps = [
    ":mojo_bindings",
    "//ash/constants",
    "//base",
    "//components/metrics/structured:structured_events",
    "//mojo/public/cpp/bindings",
  ]
}

source_set("document_scanning") {
  sources = [
    "document_scanner_installer.cc",
    "document_scanner_installer.h",
    "document_scanner_service_client.cc",
    "document_scanner_service_client.h",
    "document_scanner_service_host.cc",
    "document_scanner_service_host.h",
  ]

  public_deps = [ "//dbus" ]

  deps = [
    "//base",
    "//chromeos/ash/components/dbus/dlcservice",
    "//chromeos/ash/components/dbus/dlcservice:dlcservice_proto",
    "//chromeos/ash/components/mojo_service_manager",
    "//chromeos/services/machine_learning/public/cpp",
    "//chromeos/services/machine_learning/public/mojom",
    "//components/device_event_log",
    "//media/capture/video/chromeos/mojom:document_scanner",
    "//mojo/public/cpp/bindings",
    "//ui/gfx/geometry",
  ]
}

mojom("ocr") {
  sources = [ "ocr.mojom" ]

  deps = [ "//ui/gfx/geometry/mojom" ]

  webui_module_path = "/ash/webui/camera_app_ui"
}

mojom("pdf_builder") {
  sources = [ "pdf_builder.mojom" ]

  public_deps = [ "//mojo/public/mojom/base" ]

  webui_module_path = "/ash/webui/camera_app_ui"
}

mojom("mojo_bindings") {
  sources = [
    "camera_app_helper.mojom",
    "events_sender.mojom",
    "types.mojom",
  ]

  public_deps = [ "//mojo/public/mojom/base" ]

  deps = [
    ":ocr",
    ":pdf_builder",
    "//ash/components/arc/mojom:camera_intent",
    "//chromeos/services/machine_learning/public/mojom:document_scanner_param_types",
    "//ui/gfx/geometry/mojom",
    "//url/mojom:url_mojom_gurl",
  ]

  webui_module_path = "/ash/webui/camera_app_ui"
}

cca_grd_prefix = "ash_camera_app"
resources_grd_file = "$target_gen_dir/${cca_grd_prefix}_resources.grd"

generated_grdp_file = "$target_gen_dir/generated.grdp"

generate_grd("build_grd") {
  deps = [
    ":build_generated_grdp",
    "resources:build_ts",
  ]

  grd_prefix = cca_grd_prefix
  out_grd = resources_grd_file
  grdp_files = [ generated_grdp_file ]

  manifest_files = [ "$target_gen_dir/resources/build_ts_manifest.json" ]
  input_files_base_dir = rebase_path("resources", "//")
  input_files = []

  # CSS Files.
  foreach(css, css_files) {
    input_files += [ "css/$css" ]
  }

  # View Files.
  foreach(view, view_files) {
    input_files += [ "views/$view" ]
  }

  # Image Files.
  foreach(image, standalone_images) {
    input_files += [ "images/$image" ]
  }
  foreach(image, icon_images) {
    input_files += [ "images/$image" ]
  }

  # JS Files.
  foreach(js, no_compile_js_files) {
    input_files += [ "js/$js" ]
  }
  foreach(wasm, wasm_files) {
    input_files += [ "js/$wasm" ]
  }

  # Sound Files.
  foreach(sound, sound_files) {
    input_files += [ "sounds/$sound" ]
  }

  # Other Files.
  input_files += [
    # We put test.html outside of views/ directory to avoid test page and the
    # main window sharing the same shelf icon.
    "test/test.html",
  ]
}

generate_grd("build_generated_grdp") {
  deps = [ "//ash/webui/camera_app_ui/resources:gen_preload_images_js" ]
  grd_prefix = "ash_camera_app_js"
  input_files_base_dir =
      rebase_path("$root_gen_dir/ash/webui/camera_app_ui/resources",
                  root_build_dir)
  input_files = [ "js/preload_images.js" ]
  out_grd = generated_grdp_file
}

source_set("unit_tests") {
  testonly = true
  sources = [ "camera_app_events_sender_unittest.cc" ]
  deps = [
    ":events_sender",
    "//ash/constants",
    "//base",
    "//base/test:test_support",
    "//components/metrics/structured:structured_events",
    "//components/metrics/structured:test_support",
    "//testing/gtest",
  ]
}