chromium/ui/webui/resources/cr_components/app_management/BUILD.gn

# Copyright 2021 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//mojo/public/tools/bindings/mojom.gni")
import("//ui/webui/resources/tools/build_webui.gni")

assert(!is_android && !is_ios)

mojom("mojo_bindings") {
  sources = [ "app_management.mojom" ]
  webui_module_path = "chrome://resources/cr_components/app_management/"

  public_deps = [
    "//mojo/public/mojom/base",
    "//url/mojom:url_mojom_gurl",
  ]

  cpp_typemaps = [
    {
      types = [
        {
          mojom = "app_management.mojom.AppType"
          cpp = "::apps::AppType"
        },
        {
          mojom = "app_management.mojom.PermissionType"
          cpp = "::apps::PermissionType"
        },
        {
          mojom = "app_management.mojom.Permission"
          cpp = "::apps::PermissionPtr"
          move_only = true
        },
        {
          mojom = "app_management.mojom.InstallReason"
          cpp = "::apps::InstallReason"
        },
        {
          mojom = "app_management.mojom.InstallSource"
          cpp = "::apps::InstallSource"
        },
        {
          mojom = "app_management.mojom.WindowMode"
          cpp = "::apps::WindowMode"
        },
        {
          mojom = "app_management.mojom.RunOnOsLoginMode"
          cpp = "::apps::RunOnOsLoginMode"
        },
        {
          mojom = "app_management.mojom.RunOnOsLogin"
          cpp = "::apps::RunOnOsLoginPtr"
          move_only = true
        },
      ]
      traits_headers = [
        "//components/services/app_service/public/cpp/app_types.h",
        "//components/services/app_service/public/cpp/permission.h",
        "//components/services/app_service/public/cpp/run_on_os_login_types.h",
        "//ui/webui/resources/cr_components/app_management/app_management_mojom_traits.h",
      ]
      traits_sources = [ "//ui/webui/resources/cr_components/app_management/app_management_mojom_traits.cc" ]
      traits_public_deps = [ "//components/services/app_service" ]
    },
  ]
}

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

  non_web_component_files = [
    "constants.ts",
    "permission_constants.ts",
    "permission_util.ts",
    "browser_proxy.ts",
    "util.ts",
  ]

  mojo_files_deps = [ ":mojo_bindings_ts__generator" ]
  mojo_files = [ "$target_gen_dir/app_management.mojom-webui.ts" ]

  ts_out_dir =
      "$root_gen_dir/ui/webui/resources/tsc/cr_components/app_management"
  ts_composite = true

  # Do not add a dependency on //ui/webui/resources/cr_elements:build_ts here,
  # since this target is also used by OS Settings.
  ts_deps = [
    "//ui/webui/resources/js:build_ts",
    "//ui/webui/resources/mojo:build_ts",
  ]
  ts_definitions = [ "//tools/typescript/definitions/metrics_private.d.ts" ]
  webui_context_type = "relative"
  generate_grdp = true
  grd_resource_path_prefix = rebase_path(".", "//ui/webui/resources")
}

source_set("unit_tests") {
  testonly = true
  sources = [ "app_management_mojom_traits_unittests.cc" ]

  deps = [
    ":mojo_bindings",
    "//base/test:test_support",
    "//mojo/public/cpp/test_support:test_utils",
    "//testing/gtest",
  ]
}