chromium/content/utility/BUILD.gn

# Copyright 2014 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("//chromeos/ash/components/assistant/assistant.gni")
import("//device/vr/buildflags/buildflags.gni")
import("//media/gpu/args.gni")
import("//media/media_options.gni")
import("//mojo/public/tools/bindings/mojom.gni")
import("//printing/buildflags/buildflags.gni")
import("//services/accessibility/buildflags.gni")
import("//services/screen_ai/buildflags/features.gni")
import("//services/video_effects/args.gni")

source_set("utility") {
  # Only the public target should depend on this. All other targets (even
  # internal content ones other than test) should depend on the public one.
  visibility = [
    ":for_content_tests",
    "//content/app:*",
    "//content/public/utility:utility_sources",
  ]

  sources = [
    "browser_exposed_utility_interfaces.cc",
    "browser_exposed_utility_interfaces.h",
    "in_process_utility_thread.cc",
    "in_process_utility_thread.h",
    "services.cc",
    "services.h",
    "utility_blink_platform_with_sandbox_support_impl.cc",
    "utility_blink_platform_with_sandbox_support_impl.h",
    "utility_main.cc",
    "utility_thread_impl.cc",
    "utility_thread_impl.h",
  ]

  configs += [ "//content:content_implementation" ]

  deps = [
    "//base",
    "//build:branding_buildflags",
    "//build:chromeos_buildflags",
    "//components/optimization_guide/core:features",
    "//components/services/storage",
    "//components/services/storage/public/mojom",
    "//content:export",
    "//content/child",
    "//content/public/child:child_sources",
    "//content/public/common:common_sources",
    "//content/public/common:content_descriptor_keys",
    "//content/services/auction_worklet",
    "//device/vr/buildflags",
    "//media:media_buildflags",
    "//mojo/public/cpp/bindings",
    "//net",
    "//printing/buildflags",
    "//sandbox",
    "//services/accessibility:buildflags",
    "//services/audio",
    "//services/data_decoder:lib",
    "//services/data_decoder/public/cpp",
    "//services/network:network_service",
    "//services/on_device_model:on_device_model_service",
    "//services/on_device_model/public/cpp",
    "//services/on_device_model/public/mojom",
    "//services/screen_ai/buildflags",
    "//services/service_manager/public/cpp",
    "//services/service_manager/public/mojom",
    "//services/shape_detection:lib",
    "//services/shape_detection/public/mojom",
    "//services/tracing:lib",
    "//services/tracing/public/mojom",
    "//services/video_capture:lib",
    "//services/video_capture/public/mojom:constants",
    "//services/video_effects:buildflags",
    "//third_party/blink/public:blink_headers",
    "//url",
  ]

  if (enable_video_effects) {
    deps += [ "//services/video_effects:service" ]
  }

  # When library CDMs are supported, we support running the CDM in the utility
  # process using mojo MediaService. On Windows, we use MediaFoundationService.
  if (enable_library_cdms || is_win) {
    deps += [
      "//media",
      "//media/mojo:buildflags",
      "//media/mojo/services",
    ]
  }

  if (is_chromeos_ash) {
    deps += [
      "//chromeos/ash/components/assistant:buildflags",
      "//chromeos/ash/services/ime:sandbox_hook",
      "//chromeos/services/tts:sandbox_hook",
    ]
    if (use_vaapi || use_v4l2_codec) {
      deps += [ "//ash/components/arc/video_accelerator" ]
    }
  }

  if (is_linux || is_chromeos) {
    deps += [
      "//gpu/config",
      "//media/gpu/sandbox",
      "//media/mojo/services",
      "//third_party/angle:angle_gpu_info_util",
    ]
  }

  if (is_chromeos_ash && is_chrome_branded) {
    deps += [
      "//services/shape_detection:lib",
      "//services/shape_detection/public/mojom",
    ]
  }

  if (is_chromeos_ash && enable_cros_libassistant) {
    deps += [
      "//chromeos/ash/services/libassistant:sandbox_hook",
      "//chromeos/assistant/internal:libassistant",
    ]
  }

  # PAC execution is done in process on Android.
  if (!is_android) {
    deps += [ "//services/proxy_resolver:lib" ]
  }

  if (is_linux || is_chromeos) {
    deps += [
      "//content/utility/speech:speech_recognition_sandbox_hook",
      "//services/network:network_sandbox_hook",
    ]
    if (enable_oop_printing) {
      deps += [ "//printing:printing_sandbox_hook" ]
    }
  }

  if (enable_screen_ai_service && (is_linux || is_chromeos)) {
    deps += [ "//services/screen_ai:screen_ai_sandbox_hook" ]
  }

  if (enable_accessibility_service) {
    deps += [ "//services/accessibility:lib" ]
  }

  if (enable_vr && !is_android) {
    deps += [
      "//content/services/isolated_xr_device:lib",
      "//device/vr/public/mojom:isolated_xr_service",
    ]
  }

  if (is_win) {
    deps += [ ":delegate_data" ]
  }
}

if (is_win) {
  mojom("delegate_data") {
    disable_variants = true

    sources = [ "sandbox_delegate_data.mojom" ]
    public_deps = [ "//mojo/public/mojom/base" ]
  }
}

# See comment at the top of //content/BUILD.gn for how this works.
group("for_content_tests") {
  visibility = [ "//content/test/*" ]
  if (!is_component_build) {
    public_deps = [ ":utility" ]
  }
}