chromium/components/browsing_topics/BUILD.gn

# Copyright 2022 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//components/optimization_guide/features.gni")
import("//testing/libfuzzer/fuzzer_test.gni")

source_set("browsing_topics") {
  sources = [
    "annotator.cc",
    "annotator.h",
    "browsing_topics_calculator.cc",
    "browsing_topics_calculator.h",
    "browsing_topics_page_load_data_tracker.cc",
    "browsing_topics_page_load_data_tracker.h",
    "browsing_topics_redirect_observer.cc",
    "browsing_topics_redirect_observer.h",
    "browsing_topics_service.h",
    "browsing_topics_service_impl.cc",
    "browsing_topics_service_impl.h",
    "browsing_topics_state.cc",
    "browsing_topics_state.h",
    "candidate_topic.cc",
    "candidate_topic.h",
    "epoch_topics.cc",
    "epoch_topics.h",
    "topic_and_domains.cc",
    "topic_and_domains.h",
    "util.cc",
    "util.h",
  ]

  if (build_with_tflite_lib) {
    sources += [
      "annotator_impl.cc",
      "annotator_impl.h",
    ]
  } else {
    sources += [
      "annotator_noop.cc",
      "annotator_noop.h",
    ]
  }

  deps = [
    "//base",
    "//components/browsing_topics/common:common",
    "//components/browsing_topics/mojom:mojo_bindings",
    "//components/history/content/browser",
    "//components/history/core/browser",
    "//components/keyed_service/core",
    "//components/optimization_guide/core",
    "//components/optimization_guide/proto:optimization_guide_proto",
    "//components/privacy_sandbox",
    "//content/public/browser",
    "//content/public/common:common",
    "//crypto",
    "//net/base/registry_controlled_domains",
    "//services/metrics/public/cpp:metrics_cpp",
    "//services/metrics/public/cpp:ukm_builders",
    "//third_party/blink/public/common",
  ]
}

source_set("test_support") {
  testonly = true
  sources = [
    "test_util.cc",
    "test_util.h",
  ]

  public_deps = [ "//base" ]

  deps = [
    ":browsing_topics",
    "//base/test:test_support",
    "//components/browsing_topics/mojom:mojo_bindings",
    "//components/history/core/browser:browser",
    "//components/ukm:test_support",
    "//services/metrics/public/cpp:ukm_builders",
    "//third_party/blink/public/common",
  ]
}

source_set("unit_tests") {
  testonly = true
  sources = [
    "browsing_topics_calculator_unittest.cc",
    "browsing_topics_page_load_data_tracker_unittest.cc",
    "browsing_topics_redirect_observer_unittest.cc",
    "browsing_topics_service_impl_unittest.cc",
    "browsing_topics_state_unittest.cc",
    "epoch_topics_unittest.cc",
    "topic_and_domains_unittest.cc",
  ]

  if (build_with_tflite_lib) {
    sources += [ "annotator_impl_unittest.cc" ]
  }

  deps = [
    ":browsing_topics",
    ":test_support",
    "//base",
    "//base/test:test_support",
    "//components/content_settings/browser:browser",
    "//components/content_settings/browser:test_support",
    "//components/content_settings/core/test:test_support",
    "//components/history/content/browser:browser",
    "//components/history/core/browser:browser",
    "//components/history/core/test",
    "//components/optimization_guide/core:core",
    "//components/optimization_guide/core:features",
    "//components/optimization_guide/core:test_support",
    "//components/optimization_guide/proto:optimization_guide_proto",
    "//components/prefs:test_support",
    "//components/privacy_sandbox:privacy_sandbox",
    "//components/privacy_sandbox:privacy_sandbox_prefs",
    "//components/privacy_sandbox:test_support",
    "//components/privacy_sandbox:tracking_protection_settings",
    "//components/privacy_sandbox/privacy_sandbox_attestations",
    "//components/privacy_sandbox/privacy_sandbox_attestations:test_support",
    "//components/sync_preferences:test_support",
    "//components/ukm:test_support",
    "//content/test:test_support",
    "//testing/gtest",
    "//third_party/blink/public/common",
    "//third_party/zlib/google:compression_utils",
  ]
}

fuzzer_test("browsing_topics_annotator_fuzzer") {
  sources = [ "annotator_fuzzer.cc" ]
  deps = [
    ":browsing_topics",
    "//base:base",
    "//base/test:test_support",
    "//components/optimization_guide/core:core",
    "//components/optimization_guide/core:features",
    "//components/optimization_guide/core:test_support",
    "//components/optimization_guide/proto:optimization_guide_proto",
  ]
}