chromium/components/privacy_sandbox/BUILD.gn

# Copyright 2020 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")

static_library("privacy_sandbox_prefs") {
  sources = [
    "privacy_sandbox_prefs.cc",
    "privacy_sandbox_prefs.h",
  ]

  deps = [
    ":privacy_sandbox_notice_storage",
    ":tracking_protection_prefs",
    "//components/pref_registry:pref_registry",
    "//components/prefs",
  ]

  public_deps = [ "//base" ]
}

component("features") {
  output_name = "privacy_sandbox_features"

  defines = [ "IS_PRIVACY_SANDBOX_FEATURES_IMPL" ]

  sources = [
    "privacy_sandbox_features.cc",
    "privacy_sandbox_features.h",
  ]

  public_deps = [ "//base" ]
}

source_set("privacy_sandbox_notice_constants") {
  sources = [ "privacy_sandbox_notice_constants.h" ]

  public_deps = [ "//base" ]
}

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

  deps = [
    ":features",
    ":privacy_sandbox_prefs",
    "//components/keyed_service/core:core",
    "//components/prefs",
  ]

  public_deps = [ "//base" ]
}

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

  deps = [
    ":features",
    ":tracking_protection_prefs",
    "//components/keyed_service/core:core",
    "//components/pref_registry:pref_registry",
    "//components/prefs",
    "//components/version_info",
  ]

  public_deps = [ "//base" ]
}

source_set("tracking_protection_settings") {
  sources = [
    "tracking_protection_settings.cc",
    "tracking_protection_settings.h",
    "tracking_protection_settings_observer.h",
  ]

  deps = [
    ":features",
    ":privacy_sandbox_prefs",
    ":tracking_protection_onboarding",
    ":tracking_protection_prefs",
    "//components/content_settings/core/browser",
    "//components/content_settings/core/common",
    "//components/keyed_service/core:core",
    "//components/pref_registry:pref_registry",
    "//components/prefs",
    "//url:url",
  ]

  public_deps = [ "//base" ]
}

static_library("tracking_protection_prefs") {
  sources = [
    "tracking_protection_prefs.cc",
    "tracking_protection_prefs.h",
  ]

  deps = [
    "//components/pref_registry:pref_registry",
    "//components/prefs",
  ]

  public_deps = [ "//base" ]
}

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

  deps = [
    ":privacy_sandbox_notice_constants",
    "//components/pref_registry:pref_registry",
    "//components/prefs",
  ]

  public_deps = [ "//base" ]
}

source_set("tpcd") {
  sources = [
    "tpcd_pref_names.cc",
    "tpcd_pref_names.h",
    "tpcd_utils.h",
  ]

  deps = [
    "//components/pref_registry:pref_registry",
    "//components/prefs",
  ]

  public_deps = [ "//base" ]
}

# These sources depend on targets from "//content/browser", which means they can't be
# loaded on ios.
# TOOD(b/301947962): Delete this check after CookieSettings is removed from iOS.
if (use_blink) {
  source_set("privacy_sandbox_settings_headers") {
    sources = [
      "privacy_sandbox_settings.h",
      "privacy_sandbox_settings_impl.h",

      # This file has no dependencies. However, privacy_sandbox_setttings files
      # need it and it is only needed when :privacy_sandbox_settings_headers
      # is needed. Putting it here seemed like a better alternative to creating
      # a new :tpcd_experiment_eligibility target.
      "tpcd_experiment_eligibility.h",
    ]

    deps = [
      ":tracking_protection_settings",
      "//components/browsing_topics/common:common",
      "//components/keyed_service/core:core",
      "//components/pref_registry:pref_registry",
      "//components/prefs",
      "//content/public/browser",
      "//third_party/blink/public/common",
      "//url:url",
    ]

    public_deps = [ "//base" ]
  }

  source_set("privacy_sandbox") {
    sources = [
      "canonical_topic.cc",
      "canonical_topic.h",
      "privacy_sandbox_settings_impl.cc",
    ]

    deps = [
      ":privacy_sandbox_prefs",
      ":privacy_sandbox_survey_service",
      ":tracking_protection_settings",
      "//components/browsing_topics/common:common",
      "//components/content_settings/core/browser",
      "//components/content_settings/core/browser:cookie_settings",
      "//components/content_settings/core/common",
      "//components/keyed_service/core:core",
      "//components/pref_registry:pref_registry",
      "//components/prefs",
      "//components/privacy_sandbox/privacy_sandbox_attestations",
      "//components/strings:components_strings_grit",
      "//content/public/browser",
      "//net:net",
      "//third_party/blink/public/common",
      "//ui/base:base",
      "//url:url",
    ]

    public_deps = [
      ":features",
      ":privacy_sandbox_settings_headers",
    ]
  }

  source_set("test_support") {
    testonly = true
    sources = [
      "mock_privacy_sandbox_settings.cc",
      "mock_privacy_sandbox_settings.h",
      "privacy_sandbox_test_util.cc",
      "privacy_sandbox_test_util.h",
    ]
    deps = [
      ":privacy_sandbox",
      ":privacy_sandbox_prefs",
      "//base/test:test_support",
      "//components/browsing_topics:test_support",
      "//components/content_settings/core/browser:browser",
      "//components/content_settings/core/common:common",
      "//components/content_settings/core/test:test_support",
      "//components/prefs:test_support",
      "//components/privacy_sandbox/privacy_sandbox_attestations",
      "//components/privacy_sandbox/privacy_sandbox_attestations:test_support",
      "//components/sync_preferences:test_support",
      "//content/test:test_support",
      "//testing/gmock",
      "//testing/gtest:gtest",
      "//ui/base:base",
      "//url:url",
    ]
  }
}

source_set("unit_tests") {
  testonly = true
  sources = [
    "privacy_sandbox_notice_storage_unittest.cc",
    "privacy_sandbox_survey_service_unittest.cc",
    "tracking_protection_onboarding_unittest.cc",
  ]

  data = [ "//tools/metrics/histograms/metadata/privacy/histograms.xml" ]

  deps = [
    ":features",
    ":privacy_sandbox_notice_constants",
    ":privacy_sandbox_notice_storage",
    ":privacy_sandbox_prefs",
    ":privacy_sandbox_survey_service",
    ":tracking_protection_onboarding",
    ":tracking_protection_prefs",
    ":tracking_protection_settings",
    "//base/test:test_support",
    "//components/content_settings/core/common",
    "//components/prefs:test_support",
    "//components/sync_preferences:test_support",
    "//components/version_info",
    "//testing/gtest",
  ]

  if (use_blink) {
    sources += [
      "canonical_topic_unittest.cc",
      "privacy_sandbox_settings_impl_unittest.cc",
      "privacy_sandbox_test_util_unittest.cc",
      "tpcd_experiment_eligibility_unittest.cc",
      "tracking_protection_settings_unittest.cc",
    ]

    deps += [
      ":privacy_sandbox",
      ":test_support",
      "//components/browsing_topics:test_support",
      "//components/content_settings/core/browser:browser",
      "//components/content_settings/core/test:test_support",
      "//components/privacy_sandbox/privacy_sandbox_attestations",
      "//components/privacy_sandbox/privacy_sandbox_attestations:test_support",
      "//components/strings:components_strings_grit",
      "//content/public/browser",
      "//content/test:test_support",
      "//net",
    ]
  }
}