chromium/chrome/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("//build/config/features.gni")
import("//build/config/sysroot.gni")
import("//chrome/common/features.gni")
import("//chrome/services/speech/buildflags/buildflags.gni")
import("//chromeos/ash/components/assistant/assistant.gni")
import("//crypto/features.gni")
import("//extensions/buildflags/buildflags.gni")
import("//pdf/features.gni")
import("//printing/buildflags/buildflags.gni")
import("//services/screen_ai/buildflags/features.gni")

assert(!is_fuchsia, "Fuchsia shouldn't use anything in //chrome")

static_library("utility") {
  sources = [
    "chrome_content_utility_client.cc",
    "chrome_content_utility_client.h",
    "services.cc",
    "services.h",
  ]

  defines = []
  configs += [
    "//build/config:precompiled_headers",
    "//build/config/compiler:wexit_time_destructors",
  ]

  public_deps = []
  deps = [
    "//base",
    "//build:chromeos_buildflags",
    "//chrome:resources",
    "//chrome:strings",
    "//chrome/common",
    "//chrome/common:mojo_bindings",
    "//chrome/services/on_device_translation:on_device_translation_service",
    "//chrome/services/speech/buildflags",
    "//components/heap_profiling/in_process",
    "//components/metrics:child_call_stack_profile_builder",
    "//components/mirroring/service:mirroring_service",
    "//components/paint_preview/buildflags",
    "//components/password_manager/services/csv_password:lib",
    "//components/safe_browsing:buildflags",
    "//components/search_engines",
    "//components/services/language_detection",
    "//components/services/paint_preview_compositor",
    "//components/services/patch:lib",
    "//components/services/unzip:lib",
    "//components/strings",
    "//components/url_formatter",
    "//components/webapps/services/web_app_origin_association:lib",
    "//content/public/child",
    "//content/public/common",
    "//content/public/utility",
    "//extensions/buildflags",
    "//ipc",
    "//media",
    "//net",
    "//pdf:buildflags",
    "//printing/buildflags",
    "//services/data_decoder:lib",
    "//services/network:network_service",
    "//services/passage_embeddings:passage_embeddings",
    "//services/passage_embeddings/public/mojom",
    "//services/screen_ai/buildflags",
    "//services/service_manager/public/cpp",
    "//skia",
    "//sql",
    "//third_party/blink/public/common",
    "//third_party/zlib/google:zip",
    "//ui/base:buildflags",
  ]

  if (is_win) {
    deps += [
      "//components/services/quarantine",
      "//components/services/quarantine/public/mojom",
    ]
  }

  if (is_mac) {
    deps += [ "//chrome/services/mac_notifications" ]
  }

  if (!is_android) {
    sources += [
      "importer/bookmark_html_reader.cc",
      "importer/bookmark_html_reader.h",
      "importer/bookmarks_file_importer.cc",
      "importer/bookmarks_file_importer.h",
      "importer/external_process_importer_bridge.cc",
      "importer/external_process_importer_bridge.h",
      "importer/favicon_reencode.cc",
      "importer/favicon_reencode.h",
      "importer/importer.cc",
      "importer/importer.h",
      "importer/importer_creator.cc",
      "importer/importer_creator.h",
      "importer/profile_import_impl.cc",
      "importer/profile_import_impl.h",
    ]
    if (!is_chromeos) {
      sources += [
        "importer/firefox_importer.cc",
        "importer/firefox_importer.h",
      ]
    }
    if (is_mac) {
      sources += [
        "importer/safari_importer.h",
        "importer/safari_importer.mm",
      ]
    }
    if (!is_mac && !is_chromeos) {
      # NSS decryptor is not needed on ChromeOS. Additionally, it depends on
      # system NSS that is unavailable on MacOS/Fuchsia.
      sources += [
        "importer/nss_decryptor.cc",
        "importer/nss_decryptor.h",
      ]

      deps += [ "//crypto:buildflags" ]
    }
    if (is_win) {
      sources += [
        "importer/edge_database_reader_win.cc",
        "importer/edge_database_reader_win.h",
        "importer/edge_importer_win.cc",
        "importer/edge_importer_win.h",
        "importer/ie_importer_win.cc",
        "importer/ie_importer_win.h",
        "importer/nss_decryptor_win.cc",
        "importer/nss_decryptor_win.h",
      ]

      deps += [ "//services/proxy_resolver_win" ]
    }
    deps += [
      "//chrome/common:mojo_bindings",
      "//chrome/common/importer:interfaces",
      "//components/autofill/core/common",
      "//services/proxy_resolver:lib",
      "//services/screen_ai",
    ]
  }

  if (enable_extensions) {
    deps += [
      "//chrome/common/extensions/api",
      "//chrome/services/removable_storage_writer:lib",
      "//chrome/utility/image_writer",
    ]

    public_deps += [
      "//chrome/common/extensions/api",
      "//chrome/services/removable_storage_writer/public/mojom",
      "//mojo/public/cpp/bindings",
    ]

    # Prevent wininet from loading in the renderer. http://crbug.com/460679
    if (is_win) {
      ldflags = [ "/DELAYLOAD:wininet.dll" ]

      # Add ESE library for Edge Import support.
      libs = [ "esent.lib" ]
      ldflags += [ "/DELAYLOAD:esent.dll" ]

      deps += [
        "//chrome/services/util_win:lib",
        "//components/device_signals/core/common/mojom",
      ]
    }

    if (is_win || is_mac || is_linux) {
      deps += [ "//chrome/services/system_signals" ]
    }
  }

  if (is_chromeos_ash) {
    deps += [
      "//chrome/services/file_util",
      "//chrome/services/sharing",
      "//chromeos/ash/components/assistant:buildflags",
      "//chromeos/ash/components/local_search_service",
      "//chromeos/ash/components/local_search_service/public/mojom",
      "//chromeos/ash/components/mojo_service_manager",
      "//chromeos/ash/components/trash_service",
      "//chromeos/ash/components/trash_service/public/mojom",
      "//chromeos/ash/services/ime:lib",
      "//chromeos/ash/services/ime/public/mojom",
      "//chromeos/ash/services/nearby/public/mojom:mojom",
      "//chromeos/ash/services/orca",
      "//chromeos/ash/services/orca/public/mojom",
      "//chromeos/ash/services/quick_pair",
      "//chromeos/ash/services/recording",
      "//chromeos/constants:constants",
      "//chromeos/services/tts",
      "//chromeos/services/tts/public/mojom",
    ]

    if (enable_cros_libassistant) {
      deps += [
        "//chromeos/ash/services/assistant/audio_decoder:lib",
        "//chromeos/ash/services/assistant/public/mojom",
        "//chromeos/ash/services/libassistant",
        "//chromeos/ash/services/libassistant/public/mojom",
      ]
    }

    assert(enable_pdf)
    deps += [ "//chrome/services/pdf:lib" ]
  }

  if (is_chromeos) {
    deps += [
      "//chromeos/components/mahi:content_extraction",
      "//chromeos/components/mahi/public/mojom",
      "//chromeos/components/quick_answers/public/cpp",
      "//chromeos/components/quick_answers/public/mojom",
    ]
  }

  # NSS decryptor is not needed on ChromeOS.
  if (!is_chromeos && use_nss_certs) {
    sources += [
      "importer/nss_decryptor_system_nss.cc",
      "importer/nss_decryptor_system_nss.h",
    ]
    deps += [ "//crypto" ]
    configs += [ "//build/config/linux/nss" ]
  }

  if (enable_printing) {
    deps += [
      "//components/services/print_compositor",
      "//components/services/print_compositor/public/mojom",
    ]

    if (!is_android) {
      deps += [ "//chrome/services/printing:lib" ]
    }

    if (is_chromeos_ash) {
      deps += [
        "//chrome/services/ipp_parser",
        "//chrome/services/ipp_parser/public/mojom",
      ]
    }
  }

  if (safe_browsing_mode == 1) {
    deps += [
      "//chrome/services/file_util",
      "//chrome/utility/safe_browsing",
    ]
  }

  if (is_android || enable_extensions) {
    deps += [ "//chrome/services/media_gallery_util:lib" ]
  }

  if (enable_browser_speech_service) {
    deps += [ "//chrome/services/speech:lib" ]
  }
}