chromium/components/services/app_service/public/cpp/BUILD.gn

# Copyright 2019 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")

# Component for the core data structures and types used by App Service. Large
# parts of the codebase are dependent on this target (via
# //chromeos/crosapi/mojom), so this must have minimal deps to avoid circular
# chains.
component("app_types") {
  output_name = "APP_TYPES"
  sources = [
    "app.cc",
    "app.h",
    "app_launch_util.cc",
    "app_launch_util.h",
    "app_types.cc",
    "app_types.h",
    "capability_access.cc",
    "capability_access.h",
    "features.cc",
    "features.h",
    "icon_effects.h",
    "icon_types.cc",
    "icon_types.h",
    "intent_filter.cc",
    "intent_filter.h",
    "menu.cc",
    "menu.h",
    "package_id.cc",
    "package_id.h",
    "permission.cc",
    "permission.h",
    "preferred_app.cc",
    "preferred_app.h",
    "run_on_os_login_types.cc",
    "run_on_os_login_types.h",
    "types_util.cc",
    "types_util.h",
  ]

  defines = [ "IS_APP_TYPES_IMPL" ]

  public_deps = [
    "//base",
    "//components/services/app_service/public/protos",
  ]

  deps = [
    ":macros",
    "//third_party/abseil-cpp:absl",
    "//ui/gfx",
    "//url",
  ]

  if (is_chromeos) {
    sources += [
      "browser_app_instance_update.cc",
      "browser_app_instance_update.h",
      "browser_window_instance_update.h",
    ]
  }
}

# This target is separate from //components/services/app_service because not all
# clients of App Service are allowed to have a dependency on //content.
if (is_chromeos_ash) {
  source_set("instance_update") {
    sources = [
      "instance.cc",
      "instance.h",
      "instance_registry.cc",
      "instance_registry.h",
      "instance_update.cc",
      "instance_update.h",
    ]
    deps = [
      ":macros",
      "//ash/public/cpp",
      "//content/public/browser",
      "//skia",
      "//ui/aura",
      "//ui/compositor",
    ]
  }
}

source_set("test_support") {
  testonly = true

  sources = [
    "intent_test_util.cc",
    "intent_test_util.h",
    "stub_icon_loader.cc",
    "stub_icon_loader.h",
  ]

  deps = [
    ":app_types",
    ":icon_loader",
    ":intents",
    "//skia",
    "//third_party/abseil-cpp:absl",
    "//ui/gfx",
  ]

  public_deps = []

  if (is_chromeos_ash) {
    sources += [
      "app_instance_waiter.cc",
      "app_instance_waiter.h",
    ]
    public_deps += [
      ":instance_update",
      "//base",
    ]
  }
}

# The following targets are used for internal code organization, and are not
# exposed publicly. Clients should depend on "//components/services/app_service"
# instead of individual targets. New targets added below should also be added to
# public_deps on "//components/services/app_service" to make them available to
# clients.

source_set("app_file_handling") {
  sources = [
    "file_handler.cc",
    "file_handler.h",
    "file_handler_info.cc",
    "file_handler_info.h",
  ]

  public_deps = [ ":app_icon_info" ]

  deps = [
    "//base",
    "//url",
  ]

  visibility = [ "//components/services/app_service/*" ]
}

source_set("app_icon_info") {
  sources = [
    "icon_info.cc",
    "icon_info.h",
  ]

  deps = [
    "//base",
    "//url",
  ]

  visibility = [ "//components/services/app_service/*" ]
}

source_set("app_share_target") {
  sources = [
    "share_target.cc",
    "share_target.h",
  ]

  deps = [
    "//base",
    "//url",
  ]

  visibility = [ "//components/services/app_service/*" ]
}

source_set("macros") {
  sources = [ "macros.h" ]
  public_deps = [ "//base" ]

  # Not exported through //components/services/app_service, and only exposed to
  # App Service code.
  visibility = [
    "//chrome/browser/apps/app_service/*",
    "//components/services/app_service/*",
  ]
}

component("app_update") {
  output_name = "APP_UPDATE"
  sources = [
    "app_capability_access_cache.cc",
    "app_capability_access_cache.h",
    "app_capability_access_cache_wrapper.cc",
    "app_capability_access_cache_wrapper.h",
    "app_registry_cache.cc",
    "app_registry_cache.h",
    "app_registry_cache_wrapper.cc",
    "app_registry_cache_wrapper.h",
    "app_storage/app_storage.cc",
    "app_storage/app_storage.h",
    "app_storage/app_storage_file_handler.cc",
    "app_storage/app_storage_file_handler.h",
    "app_update.cc",
    "app_update.h",
    "capability_access_update.cc",
    "capability_access_update.h",
  ]

  defines = [ "IS_APP_UPDATE_IMPL" ]

  public_deps = [ "//components/account_id:account_id" ]

  deps = [
    ":app_types",
    ":intents",
    ":macros",
    "//ui/gfx",
  ]

  visibility = [ "//components/services/app_service/*" ]
}

source_set("app_url_handling") {
  sources = [
    "url_handler_info.cc",
    "url_handler_info.h",
  ]

  deps = [ "//url" ]

  visibility = [ "//components/services/app_service/*" ]
}

source_set("icon_loader") {
  sources = [
    "icon_cache.cc",
    "icon_cache.h",
    "icon_coalescer.cc",
    "icon_coalescer.h",
    "icon_loader.cc",
    "icon_loader.h",
  ]

  deps = [
    ":app_types",
    "//ui/gfx:gfx",
  ]

  visibility = [ "//components/services/app_service/*" ]
}

source_set("intents") {
  sources = [
    "intent.cc",
    "intent.h",
    "intent_filter_util.cc",
    "intent_filter_util.h",
    "intent_util.cc",
    "intent_util.h",
  ]

  deps = [
    ":app_types",
    "//base",
    "//third_party/blink/public/common",
    "//url",
  ]

  visibility = [ "//components/services/app_service/*" ]
}

source_set("protocol_handling") {
  sources = [
    "protocol_handler_info.cc",
    "protocol_handler_info.h",
  ]

  deps = [ "//url" ]

  visibility = [ "//components/services/app_service/*" ]
}

source_set("preferred_apps") {
  sources = [
    "preferred_apps_converter.cc",
    "preferred_apps_converter.h",
    "preferred_apps_impl.cc",
    "preferred_apps_impl.h",
    "preferred_apps_list.cc",
    "preferred_apps_list.h",
    "preferred_apps_list_handle.cc",
    "preferred_apps_list_handle.h",
  ]

  deps = [
    ":app_types",
    ":intents",
    "//base",
    "//url",
  ]

  visibility = [ "//components/services/app_service/*" ]
}

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

  deps = [
    "//base",
    "//cc/paint",
    "//skia",
    "//ui/gfx",
  ]

  visibility = [ "//components/services/app_service/*" ]
}

source_set("crosapi_utils") {
  sources = [ "crosapi_utils.h" ]

  visibility = [ "//components/services/app_service/*" ]
}

source_set("unit_tests") {
  testonly = true

  sources = [
    "app_capability_access_cache_unittest.cc",
    "app_capability_access_cache_wrapper_unittest.cc",
    "app_registry_cache_unittest.cc",
    "app_registry_cache_wrapper_unittest.cc",
    "app_unittest.cc",
    "app_update_unittest.cc",
    "capability_access_update_unittest.cc",
    "icon_cache_unittest.cc",
    "icon_coalescer_unittest.cc",
    "intent_filter_util_unittest.cc",
    "intent_util_unittest.cc",
    "package_id_unittest.cc",
    "preferred_apps_converter_unittest.cc",
    "preferred_apps_list_unittest.cc",
  ]

  deps = [
    ":app_types",
    ":app_update",
    ":icon_loader",
    ":intents",
    ":preferred_apps",
    ":test_support",
    "//content/test:test_support",
    "//testing/gtest",
  ]

  if (is_chromeos_ash) {
    sources += [
      "app_storage/app_storage_file_handler_unittest.cc",
      "app_storage/app_storage_unittest.cc",
      "icon_types_unittest.cc",
      "instance_registry_unittest.cc",
      "instance_unittest.cc",
      "instance_update_unittest.cc",
      "permission_unittest.cc",
      "run_on_os_login_types_unittest.cc",
    ]

    deps += [
      ":instance_update",
      "//chrome/test:test_support",
    ]
  }

  if (is_chromeos) {
    deps +=
        [ "//components/services/app_service/public/cpp/shortcut:unit_tests" ]
  }
}