chromium/components/plus_addresses/BUILD.gn

# Copyright 2023 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/buildflag_header.gni")
import("//components/plus_addresses/buildflags.gni")
import("//third_party/protobuf/proto_library.gni")

source_set("types") {
  sources = [
    "plus_address_types.cc",
    "plus_address_types.h",
  ]
  public_deps = [
    "//base",
    "//components/affiliations/core/browser:affiliations",
    "//components/autofill/core/browser",
  ]
}

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

  # TODO(b/322147254): The webdata dependency only exists to check if sync
  # support is enabled. Remove when fully launched.
  deps = [ "//components/plus_addresses/webdata" ]
  public_deps = [
    ":types",
    "//base",
    "//services/data_decoder/public/cpp",
  ]
}

source_set("prefs") {
  sources = [
    "plus_address_prefs.cc",
    "plus_address_prefs.h",
  ]
  deps = [
    "//base",
    "//components/prefs",
  ]
}

proto_library("plus_address_blocklist_proto") {
  sources = [ "blocked_facets.proto" ]
}

source_set("blocklist_data") {
  sources = [
    "plus_address_blocklist_data.cc",
    "plus_address_blocklist_data.h",
  ]
  deps = [
    "//base",
    "//third_party/re2",
  ]
  public_deps = [ ":plus_address_blocklist_proto" ]
}

source_set("plus_addresses") {
  sources = [
    "affiliations/plus_address_affiliation_match_helper.cc",
    "affiliations/plus_address_affiliation_match_helper.h",
    "affiliations/plus_address_affiliation_source_adapter.cc",
    "affiliations/plus_address_affiliation_source_adapter.h",
    "plus_address_allocator.h",
    "plus_address_cache.cc",
    "plus_address_cache.h",
    "plus_address_http_client.h",
    "plus_address_http_client_impl.cc",
    "plus_address_http_client_impl.h",
    "plus_address_jit_allocator.cc",
    "plus_address_jit_allocator.h",
    "plus_address_preallocator.cc",
    "plus_address_preallocator.h",
    "plus_address_service.cc",
    "plus_address_service.h",
    "plus_address_ui_utils.cc",
    "plus_address_ui_utils.h",
  ]
  deps = [
    ":blocklist_data",
    ":parsing",
    ":prefs",
    "//components/affiliations/core/browser:affiliations",
    "//components/feature_engagement/public",
    "//components/plus_addresses/metrics",
    "//components/plus_addresses/metrics:submission_logger",
    "//components/plus_addresses/settings",
    "//components/plus_addresses/webdata",
    "//components/signin/public/identity_manager",
    "//components/strings:components_strings_grit",
    "//components/url_formatter",
    "//net",
    "//services/data_decoder/public/cpp",
    "//services/network/public/cpp",
    "//ui/base",
  ]
  public_deps = [
    # While not strictly public by h file inclusion, this is a temporary move
    # of features.h out of sources. Allowing those depending on
    # :plus_addresses to also depend on its features to reduce churn.
    ":features",
    ":types",
    "//base",
    "//components/autofill/core/browser",
    "//components/keyed_service/core",
    "//third_party/abseil-cpp:absl",
    "//url",
  ]
}

component("features") {
  output_name = "plus_addresses_features"
  defines = [ "IS_PLUS_ADDRESSES_FEATURES_IMPL" ]
  sources = [
    "features.cc",
    "features.h",
  ]
  public_deps = [ "//base" ]
}

buildflag_header("plus_addresses_buildflags") {
  header = "plus_addresses_buildflags.h"
  flags = [ "PLUS_ADDRESSES_USE_INTERNAL_ANDROID_RESOURCES=$plus_addresses_use_internal_android_resources" ]
}

source_set("unit_tests") {
  testonly = true
  sources = [
    "affiliations/plus_address_affiliation_match_helper_unittest.cc",
    "affiliations/plus_address_affiliation_source_adapter_unittest.cc",
    "plus_address_blocklist_data_unittest.cc",
    "plus_address_http_client_impl_unittest.cc",
    "plus_address_jit_allocator_unittest.cc",
    "plus_address_parsing_utils_unittest.cc",
    "plus_address_preallocator_unittest.cc",
    "plus_address_service_unittest.cc",
  ]

  deps = [
    ":blocklist_data",
    ":features",
    ":parsing",
    ":plus_addresses",
    ":prefs",
    ":test_support",
    "//base/test:test_support",
    "//components/affiliations/core/browser:affiliations",
    "//components/affiliations/core/browser:test_support",
    "//components/autofill/core/browser:test_support",
    "//components/feature_engagement/public",
    "//components/plus_addresses/metrics",
    "//components/plus_addresses/settings:test_support",
    "//components/plus_addresses/webdata",
    "//components/prefs:test_support",
    "//components/signin/public/identity_manager:test_support",
    "//components/strings:components_strings_grit",
    "//services/data_decoder/public/cpp:test_support",
    "//services/network:test_support",
  ]
}

static_library("test_support") {
  testonly = true
  sources = [
    "fake_plus_address_service.cc",
    "fake_plus_address_service.h",
    "mock_plus_address_http_client.cc",
    "mock_plus_address_http_client.h",
    "plus_address_http_client_impl_test_api.h",
    "plus_address_test_environment.cc",
    "plus_address_test_environment.h",
    "plus_address_test_utils.cc",
    "plus_address_test_utils.h",
  ]
  deps = [
    ":prefs",
    "//base",
    "//base/test:test_support",
    "//components/affiliations/core/browser:test_support",
    "//components/autofill/core/browser",
    "//net:test_support",
    "//testing/gmock",
  ]
  public_deps = [
    ":plus_addresses",
    ":types",
    "//components/affiliations/core/browser:test_support",
    "//components/plus_addresses/settings:test_support",
    "//components/prefs:test_support",
    "//components/signin/public/identity_manager:test_support",
  ]
}