chromium/components/content_settings/core/common/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/features.gni")
import("//mojo/public/tools/bindings/mojom.gni")
import("//testing/libfuzzer/fuzzer_test.gni")

static_library("common") {
  sources = [
    "content_settings.cc",
    "content_settings.h",
    "content_settings_constraints.cc",
    "content_settings_constraints.h",
    "content_settings_metadata.cc",
    "content_settings_metadata.h",
    "content_settings_param_traits.cc",
    "content_settings_param_traits.h",
    "content_settings_partition_key.cc",
    "content_settings_partition_key.h",
    "content_settings_pattern.cc",
    "content_settings_pattern.h",
    "content_settings_pattern_parser.cc",
    "content_settings_pattern_parser.h",
    "content_settings_rules.cc",
    "content_settings_rules.h",
    "content_settings_types.h",
    "content_settings_utils.cc",
    "content_settings_utils.h",
    "cookie_blocking_3pcd_status.h",
    "cookie_controls_enforcement.h",
    "cookie_settings_base.cc",
    "cookie_settings_base.h",
    "host_indexed_content_settings.cc",
    "host_indexed_content_settings.h",
    "pref_names.h",
    "third_party_site_data_access_type.h",
    "tracking_protection_feature.h",
  ]

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

  public_deps = [
    ":content_settings_enums",
    ":content_settings_types",
    ":features",
    "//base",
  ]

  deps = [
    "//build:blink_buildflags",
    "//components/privacy_sandbox:features",
    "//ipc",
    "//mojo/public/cpp/base",
    "//mojo/public/cpp/bindings:struct_traits",
    "//net",
    "//url",
  ]
}

source_set("unit_tests") {
  testonly = true
  sources = [
    "content_settings_constraints_unittest.cc",
    "content_settings_metadata_unittest.cc",
    "content_settings_mojom_traits_unittest.cc",
    "content_settings_partition_key_unittest.cc",
    "content_settings_pattern_parser_unittest.cc",
    "content_settings_pattern_unittest.cc",
    "content_settings_utils_unittest.cc",
    "cookie_settings_base_unittest.cc",
    "host_indexed_content_settings_unittest.cc",
  ]

  deps = [
    ":common",
    ":mojo_bindings",
    "//base",
    "//base/test:test_support",
    "//mojo/public/cpp/test_support:test_utils",
    "//net",
    "//testing/gmock",
    "//testing/gtest",
    "//url",
  ]
}

mojom("content_settings_types") {
  generate_java = true
  sources = [ "content_settings_types.mojom" ]

  public_deps = [ "//mojo/public/mojom/base" ]

  webui_module_path = "/"
  generate_legacy_js_bindings = true
}

mojom("content_settings_enums") {
  generate_java = true
  sources = [ "content_settings_enums.mojom" ]

  public_deps = [ "//mojo/public/mojom/base" ]

  webui_module_path = "/"
  generate_legacy_js_bindings = true
}

mojom("mojo_bindings") {
  generate_java = true
  sources = [ "content_settings.mojom" ]

  public_deps = [
    ":content_settings_enums",
    ":content_settings_types",
    "//mojo/public/mojom/base",
  ]

  webui_module_path = "/"
  generate_legacy_js_bindings = true

  cpp_typemaps = [
    {
      types = [
        {
          mojom = "content_settings.mojom.PatternParts"
          cpp = "::ContentSettingsPattern::PatternParts"
        },
        {
          mojom = "content_settings.mojom.ContentSettingsPattern"
          cpp = "::ContentSettingsPattern"
        },
        {
          mojom = "content_settings.mojom.ContentSetting"
          cpp = "::ContentSetting"
        },
        {
          mojom = "content_settings.mojom.ContentSettingPatternSource"
          cpp = "::ContentSettingPatternSource"
        },
        {
          mojom = "content_settings.mojom.RendererContentSettingRules"
          cpp = "::RendererContentSettingRules"
        },
        {
          mojom = "content_settings.mojom.RuleMetaData"
          cpp = "::content_settings::RuleMetaData"
        },
      ]
      traits_headers = [ "content_settings_mojom_traits.h" ]
      traits_private_headers = [ "content_settings_param_traits.h" ]
      traits_sources = [ "content_settings_mojom_traits.cc" ]
      traits_public_deps = [ ":common" ]
    },
  ]
}

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

  defines = [ "IS_CONTENT_SETTINGS_FEATURES_IMPL" ]

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

  deps = [ "//base" ]
}

fuzzer_test("content_settings_pattern_parser_fuzzer") {
  sources = [ "content_settings_pattern_parser_fuzzer.cc" ]
  deps = [
    ":common",
    "//base",
    "//base:i18n",
    "//third_party/icu",
    "//third_party/icu/fuzzers:fuzzer_support",
  ]
  dict = "content_settings_pattern_parser_fuzzer.dict"
}