chromium/chrome/browser/chromeos/reporting/websites/BUILD.gn

# Copyright 2024 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/chromeos/ui_mode.gni")

assert(is_chromeos)

static_library("websites") {
  sources = [
    "website_events_observer.cc",
    "website_events_observer.h",
    "website_metrics_retriever_interface.h",
    "website_usage_observer.cc",
    "website_usage_observer.h",
    "website_usage_telemetry_sampler.cc",
    "website_usage_telemetry_sampler.h",
  ]

  if (is_chromeos_ash) {
    sources += [
      "website_metrics_retriever_ash.cc",
      "website_metrics_retriever_ash.h",
      "website_usage_telemetry_periodic_collector_ash.cc",
      "website_usage_telemetry_periodic_collector_ash.h",
    ]
  }

  if (is_chromeos_lacros) {
    sources += [
      "website_metrics_retriever_lacros.cc",
      "website_metrics_retriever_lacros.h",
      "website_usage_telemetry_periodic_collector_lacros.cc",
      "website_usage_telemetry_periodic_collector_lacros.h",
    ]
  }

  deps = [
    "//base",
    "//chrome/browser/apps/app_service",
    "//chrome/browser/chromeos/reporting",
    "//chrome/browser/profiles:profile",
    "//components/prefs",
    "//components/reporting/metrics:metrics_data_collection",
    "//components/reporting/proto:metric_data_proto",
    "//content/public/browser",
    "//third_party/abseil-cpp:absl",
    "//url",
  ]

  if (is_chromeos_ash) {
    deps += [ "//chromeos/ash/components/login/session" ]
  }

  if (is_chromeos_lacros) {
    allow_circular_includes_from = [ "//chrome/browser/chromeos/reporting" ]
  }
}

source_set("unit_tests") {
  testonly = true

  sources = [
    "website_events_observer_unittest.cc",
    "website_usage_observer_unittest.cc",
    "website_usage_telemetry_sampler_unittest.cc",
  ]

  if (is_chromeos_ash) {
    sources += [
      "website_metrics_retriever_ash_unittest.cc",
      "website_usage_telemetry_periodic_collector_ash_unittest.cc",
    ]
  }

  if (is_chromeos_lacros) {
    sources += [
      "website_metrics_retriever_lacros_unittest.cc",
      "website_usage_telemetry_periodic_collector_lacros_unittest.cc",
    ]
  }

  deps = [
    ":websites",
    "//base",
    "//base/test:test_support",
    "//chrome/browser/apps/app_service",
    "//chrome/browser/apps/app_service:test_support",
    "//chrome/browser/chromeos",
    "//chrome/browser/chromeos/reporting",
    "//chrome/browser/profiles:profile",
    "//chrome/test:test_support",
    "//components/content_settings/core/common",
    "//components/prefs",
    "//components/reporting/metrics/fakes:test_support",
    "//components/reporting/proto:metric_data_proto",
    "//content/test:test_support",
    "//testing/gmock",
    "//testing/gtest",
    "//url",
  ]

  if (is_chromeos_ash) {
    deps += [
      "//chromeos/ash/components/dbus/session_manager",
      "//chromeos/ash/components/login/session",
    ]
  }
}

if (is_chromeos_ash) {
  source_set("browser_tests") {
    testonly = true

    defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]

    sources = [
      "website_events_observer_ash_browsertest.cc",
      "website_usage_telemetry_sampler_ash_browsertest.cc",
    ]

    deps = [
      "//base",
      "//chrome/browser",
      "//chrome/browser/ash/login/test:test_support",
      "//chrome/browser/ash/policy/affiliation:test_support",
      "//chrome/browser/ash/policy/core:test_support",
      "//chrome/browser/ash/profiles",
      "//chrome/browser/chromeos",
      "//chrome/browser/chromeos/reporting",
      "//chrome/browser/profiles:profile",
      "//chrome/test:test_support",
      "//chrome/test:test_support_ui",
      "//chromeos/ash/components/login/session",
      "//chromeos/dbus/missive:test_support",
      "//components/content_settings/core/common",
      "//components/policy/core/common",
      "//components/prefs",
      "//components/reporting/proto:metric_data_proto",
      "//components/reporting/proto:record_constants",
      "//components/reporting/proto:record_proto",
      "//components/reporting/util:test_callbacks_support",
      "//content/test:test_support",
      "//testing/gmock",
      "//testing/gtest",
    ]
  }
}