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

import("//build/config/features.gni")
import("//build/config/ui.gni")
import("//ppapi/buildflags/buildflags.gni")
import("//third_party/blink/public/public_features.gni")

if (is_component_build) {
  link_target_type = "source_set"
} else {
  link_target_type = "static_library"
}
target(link_target_type, "child") {
  # Targets external to content should always link to the public API.
  # Internal targets can link to this but only if they're child processes
  # (i.e. not content/browser or content/common) and only if they're inside the
  # content component (i.e. not content/test or content/shell).
  visibility = [
    ":*",
    "//content/gpu/*",
    "//content/ppapi_plugin/*",
    "//content/public/child:child_sources",
    "//content/renderer/*",
    "//content/utility/*",
    "//tools/ipc_fuzzer/*",
  ]
  if (is_android) {
    # See comment in content/app/BUILD.gn above content_app_deps.
    visibility += [ "//content/app:*" ]
  }

  sources = [
    "assert_matching_enums.cc",
    "blink_platform_impl.cc",
    "blink_platform_impl.h",
    "browser_font_resource_trusted.cc",
    "browser_font_resource_trusted.h",
    "child_histogram_fetcher_impl.cc",
    "child_histogram_fetcher_impl.h",
    "child_process.cc",
    "child_process.h",
    "child_process_sandbox_support_impl_linux.cc",
    "child_process_sandbox_support_impl_linux.h",
    "child_process_sandbox_support_impl_mac.cc",
    "child_process_sandbox_support_impl_mac.h",
    "child_thread_impl.cc",
    "child_thread_impl.h",
    "dwrite_font_proxy/dwrite_font_proxy_init_impl_win.cc",
    "dwrite_font_proxy/dwrite_font_proxy_init_impl_win.h",
    "dwrite_font_proxy/dwrite_font_proxy_win.cc",
    "dwrite_font_proxy/dwrite_font_proxy_win.h",
    "dwrite_font_proxy/dwrite_localized_strings_win.cc",
    "dwrite_font_proxy/dwrite_localized_strings_win.h",
    "dwrite_font_proxy/font_fallback_win.cc",
    "dwrite_font_proxy/font_fallback_win.h",
    "font_warmup_win.cc",
    "font_warmup_win.h",
    "image_decoder.cc",
    "image_decoder.h",
    "memory/child_memory_coordinator_impl.cc",
    "memory/child_memory_coordinator_impl.h",
    "memory/child_memory_coordinator_impl_android.cc",
    "memory/child_memory_coordinator_impl_android.h",
    "runtime_features.cc",
    "runtime_features.h",
    "scoped_child_process_reference.cc",
    "scoped_child_process_reference.h",
    "service_factory.cc",
    "service_factory.h",
    "thread_safe_sender.cc",
    "thread_safe_sender.h",
    "webthemeengine_impl_android.cc",
    "webthemeengine_impl_android.h",
    "webthemeengine_impl_default.cc",
    "webthemeengine_impl_default.h",
    "webthemeengine_impl_mac.h",
  ]

  configs += [ "//build/config:precompiled_headers" ]

  public_deps = [
    "//gpu/ipc/client:client",
    "//ipc",
    "//services/service_manager/public/mojom:mojom_blink",
  ]

  deps = [
    "//base",
    "//cc/paint",
    "//components/discardable_memory/client",
    "//components/discardable_memory/public/interfaces",
    "//components/tracing",
    "//components/tracing:startup_tracing",
    "//components/variations",
    "//components/webcrypto",
    "//content/app/resources",
    "//content/app/strings",
    "//content/common",
    "//content/public/common:common_sources",
    "//crypto:platform",
    "//gpu/command_buffer/client",
    "//media",
    "//media/blink",
    "//mojo/core/embedder",
    "//net",
    "//services/device/public/cpp:device_features",
    "//services/device/public/cpp/power_monitor",
    "//services/device/public/mojom:constants",
    "//services/resource_coordinator/public/cpp:resource_coordinator_cpp",
    "//services/service_manager/public/cpp",
    "//services/service_manager/public/mojom",
    "//services/service_manager/runner/common",
    "//services/tracing/public/cpp",
    "//skia",
    "//storage/common",
    "//third_party/blink/public:blink_headers",
    "//third_party/blink/public:buildflags",
    "//third_party/blink/public:mojo_bindings",
    "//third_party/blink/public:resources",
    "//third_party/blink/public:scaled_resources",
    "//third_party/blink/public/common",
    "//third_party/ced",
    "//third_party/zlib/google:compression_utils",
    "//ui/base",
    "//ui/events/gestures/blink",
    "//ui/gfx",
    "//ui/gfx/geometry",
    "//ui/gl",
    "//ui/native_theme",
    "//url",
    "//v8",
  ]

  if (!use_default_render_theme) {
    sources -= [
      "webthemeengine_impl_default.cc",
      "webthemeengine_impl_default.h",
    ]
  }

  if (is_android) {
    deps += [ "//third_party/android_tools:cpu_features" ]
  }

  if (is_linux) {
    deps += [
      "//components/services/font/public/cpp",
      "//components/services/font/public/interfaces",
      "//services/service_manager/zygote",
    ]
  }

  if (is_win) {
    libs = [ "dwrite.lib" ]
  }

  if (enable_plugins) {
    deps += [
      "//ppapi/proxy",
      "//ppapi/shared_impl",
    ]
  } else {
    sources -= [
      "browser_font_resource_trusted.cc",
      "browser_font_resource_trusted.h",
    ]
  }

  configs += [
    "//content:content_implementation",
    "//build/config/compiler:no_size_t_to_int_warning",
  ]
}

# 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 = [
      ":child",
    ]
  }
}
