chromium/components/safe_browsing/content/browser/BUILD.gn

# Copyright 2017 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/features.gni")
import("//components/safe_browsing/buildflags.gni")

# NOTE: This target is separated from :browser as
# //components/safe_browsing/content/browser/web_ui, which :browser depends on, depends
# on this.
# TODO(crbug.com/40770425): Consider folding all of three these together into
# :browser, along with the other browser process code in
# //components/safe_browsing/content.
source_set("safe_browsing_service") {
  sources = [
    "safe_browsing_service_interface.cc",
    "safe_browsing_service_interface.h",
  ]

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

  deps = [
    "//base:base",
    "//components/safe_browsing/core/common/proto:csd_proto",
    "//content/public/browser",
  ]

  if (is_android) {
    deps += [ "//components/safe_browsing/android:referring_app_info" ]
  }
}

# NOTE: This target is separated from :browser as
# //components/safe_browsing/content/browser/triggers, which this depends on, depends
# on :browser.
# TODO(crbug.com/40770425): Consider folding all of three these together into
# :browser, along with the other browser process code in
# //components/safe_browsing/content.
if (safe_browsing_mode > 0) {
  source_set("safe_browsing_blocking_page") {
    sources = [
      "safe_browsing_blocking_page.cc",
      "safe_browsing_blocking_page.h",
      "safe_browsing_blocking_page_factory.h",
      "safe_browsing_navigation_throttle.cc",
      "safe_browsing_navigation_throttle.h",
      "ui_manager.cc",
      "ui_manager.h",
    ]

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

    deps = [
      ":browser",
      "//base",
      "//components/no_state_prefetch/browser",
      "//components/prefs",
      "//components/safe_browsing/content/browser/triggers",
      "//components/safe_browsing/content/browser/web_ui",
      "//components/safe_browsing/core/browser",
      "//components/safe_browsing/core/browser:safe_browsing_metrics_collector",
      "//components/safe_browsing/core/common",
      "//components/safe_browsing/core/common:safe_browsing_prefs",
      "//components/safe_browsing/core/common/proto:csd_proto",
      "//components/security_interstitials/content:security_interstitial_page",
      "//components/security_interstitials/core",
      "//components/security_interstitials/core:unsafe_resource",
      "//content/public/browser",
      "//services/metrics/public/cpp:ukm_builders",
    ]
  }
}

source_set("browser") {
  sources = [
    "async_check_tracker.cc",
    "async_check_tracker.h",
    "base_blocking_page.cc",
    "base_blocking_page.h",
    "base_ui_manager.cc",
    "base_ui_manager.h",
    "browser_url_loader_throttle.cc",
    "browser_url_loader_throttle.h",
    "client_report_util.cc",
    "client_report_util.h",
    "mojo_safe_browsing_impl.cc",
    "mojo_safe_browsing_impl.h",
    "safe_browsing_controller_client.cc",
    "safe_browsing_controller_client.h",
    "safe_browsing_network_context.cc",
    "safe_browsing_network_context.h",
    "threat_details.cc",
    "threat_details.h",
    "threat_details_cache.cc",
    "threat_details_cache.h",
    "threat_details_history.cc",
    "threat_details_history.h",
    "unsafe_resource_util.cc",
    "unsafe_resource_util.h",
    "url_checker_holder.cc",
    "url_checker_holder.h",
    "web_contents_key.cc",
    "web_contents_key.h",
  ]

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

  deps = [
    "//base",
    "//base:i18n",
    "//components/back_forward_cache",
    "//components/history/core/browser",
    "//components/prefs",
    "//components/safe_browsing:buildflags",
    "//components/safe_browsing/content/browser/web_ui:web_ui",
    "//components/safe_browsing/content/common:interfaces",
    "//components/safe_browsing/core/browser",
    "//components/safe_browsing/core/browser:referrer_chain_provider",
    "//components/safe_browsing/core/browser:verdict_cache_manager",
    "//components/safe_browsing/core/browser/db:database_manager",
    "//components/safe_browsing/core/browser/hashprefix_realtime:hash_realtime_service",
    "//components/safe_browsing/core/browser/realtime:policy_engine",
    "//components/safe_browsing/core/browser/realtime:url_lookup_service_base",
    "//components/safe_browsing/core/browser/utils",
    "//components/safe_browsing/core/common:common",
    "//components/safe_browsing/core/common:safe_browsing_prefs",
    "//components/safe_browsing/core/common/hashprefix_realtime:hash_realtime_utils",
    "//components/safe_browsing/core/common/proto:csd_proto",
    "//components/safe_browsing/core/common/proto:realtimeapi_proto",
    "//components/security_interstitials/content:security_interstitial_page",
    "//components/security_interstitials/core",
    "//components/security_interstitials/core:unsafe_resource",
    "//components/sessions",
    "//components/signin/public/identity_manager",
    "//components/unified_consent",
    "//components/version_info",
    "//content/public/browser:browser",
    "//content/public/common",
    "//net",
    "//net:extras",
    "//services/network/public/mojom",
  ]
  if (safe_browsing_mode > 0) {
    sources += [
      "safe_browsing_navigation_observer.cc",
      "safe_browsing_navigation_observer.h",
      "safe_browsing_navigation_observer_manager.cc",
      "safe_browsing_navigation_observer_manager.h",
      "safe_browsing_navigation_observer_manager_util.cc",
      "safe_browsing_navigation_observer_manager_util.h",
    ]

    deps += [
      ":safe_browsing_service",
      "//components/content_settings/core/browser",
      "//components/page_info",
      "//components/sessions",
    ]
  }
}

source_set("unit_tests") {
  testonly = true
  sources = [
    "async_check_tracker_unittest.cc",
    "client_report_util_unittest.cc",
    "client_side_detection_feature_cache_unittest.cc",
    "client_side_phishing_model_unittest.cc",
  ]

  deps = [
    ":client_side_detection_images_cache",
    ":client_side_detection_service",
    "//base:base",
    "//base/test:test_support",
    "//components/optimization_guide/core:model_executor",
    "//components/optimization_guide/core:test_support",
    "//components/optimization_guide/proto:optimization_guide_proto",
    "//components/safe_browsing:buildflags",
    "//components/safe_browsing/content/browser:browser",
    "//components/safe_browsing/core/browser:browser",
    "//components/safe_browsing/core/browser/db:test_database_manager",
    "//components/safe_browsing/core/browser/db:v4_protocol_manager_util",
    "//components/safe_browsing/core/common",
    "//components/safe_browsing/core/common:safe_browsing_prefs",
    "//components/safe_browsing/core/common/fbs:client_model",
    "//components/safe_browsing/core/common/proto:client_model_proto",
    "//components/safe_browsing/core/common/proto:csd_proto",
    "//components/security_interstitials/core:unsafe_resource",
    "//components/unified_consent",
    "//components/variations",
    "//components/version_info",
    "//content/test:test_support",
    "//services/network:test_support",
    "//testing/gmock",
    "//testing/gtest",
  ]

  if (safe_browsing_mode > 0) {
    sources += [
      "browser_url_loader_throttle_unittest.cc",
      "ui_manager_unittest.cc",
    ]
    deps += [
      "//components/prefs",
      "//components/prefs:test_support",
      "//components/safe_browsing/content/browser:safe_browsing_blocking_page",
      "//components/safe_browsing/core/browser/realtime:test_support",
      "//components/safe_browsing/core/common/hashprefix_realtime:hash_realtime_utils",
      "//components/security_interstitials/content:security_interstitial_page",
      "//components/security_interstitials/core",
      "//net/traffic_annotation:test_support",
    ]
  }

  # TODO(sgurun): enable tests for safe_browsing==2.
  if (safe_browsing_mode == 1) {
    sources += [
      "safe_browsing_navigation_observer_manager_util_unittest.cc",
      "safe_browsing_navigation_observer_unittest.cc",
    ]
  }

  deps += [
    "//components/content_settings/core/browser",
    "//components/sessions",
    "//components/sync_preferences:test_support",
  ]
}

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

  deps = [
    ":client_side_detection_service",
    "//components/safe_browsing/core/common/fbs:client_model",
    "//components/safe_browsing/core/common/proto:csd_proto",
    "//content/public/browser",
  ]
}

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

  deps = [
    "//components/optimization_guide/core:core",
    "//components/optimization_guide/proto:optimization_guide_proto",
    "//components/prefs",
    "//components/safe_browsing/content/browser/web_ui:web_ui",
    "//components/safe_browsing/content/common:interfaces",
    "//components/safe_browsing/core/common",
    "//components/safe_browsing/core/common:safe_browsing_prefs",
    "//components/safe_browsing/core/common/fbs:client_model",
    "//components/safe_browsing/core/common/proto:client_model_proto",
    "//components/safe_browsing/core/common/proto:csd_proto",
    "//content/public/browser",
    "//google_apis:google_apis",
    "//net:net",
    "//net/traffic_annotation:traffic_annotation",
    "//services/network/public/cpp",
    "//url:url",
  ]
}

source_set("client_side_detection") {
  sources = [
    "client_side_detection_host.cc",
    "client_side_detection_host.h",
    "safe_browsing_tab_observer.cc",
    "safe_browsing_tab_observer.h",
  ]

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

  deps = [
    ":client_side_detection_images_cache",
    ":client_side_detection_service",
    "//base:base",
    "//components/permissions:permissions",
    "//components/prefs",
    "//components/safe_browsing:buildflags",
    "//components/safe_browsing/content/browser",
    "//components/safe_browsing/content/common:interfaces",
    "//components/safe_browsing/core/browser:token_fetcher",
    "//components/safe_browsing/core/browser:verdict_cache_manager",
    "//components/safe_browsing/core/browser/db:allowlist_checker_client",
    "//components/safe_browsing/core/browser/db:database_manager",
    "//components/safe_browsing/core/browser/db:v4_protocol_manager_util",
    "//components/safe_browsing/core/browser/sync:sync",
    "//components/safe_browsing/core/common",
    "//components/safe_browsing/core/common:safe_browsing_prefs",
    "//components/safe_browsing/core/common/fbs:client_model",
    "//components/safe_browsing/core/common/proto:csd_proto",
    "//components/security_interstitials/content:security_interstitial_page",
    "//components/variations",
    "//components/zoom:zoom",
    "//content/public/browser",
    "//mojo/public/mojom/base:protobuf_support",
  ]

  if (safe_browsing_mode != 0) {
    deps += [ "//components/safe_browsing/content/common:visual_utils" ]
  }

  if (is_android) {
    deps += [ "//ui/android" ]
  }
}