chromium/chrome/browser/chromeos/extensions/telemetry/api/common/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/config/chromeos/ui_mode.gni")
import("//extensions/buildflags/buildflags.gni")
assert(enable_extensions,
       "Cannot depend on extensions because enable_extensions=false.")

source_set("common") {
  sources = [
    "api_guard_delegate.cc",
    "api_guard_delegate.h",
    "app_ui_observer.cc",
    "app_ui_observer.h",
    "base_telemetry_extension_api_guard_function.cc",
    "base_telemetry_extension_api_guard_function.h",
  ]

  deps = [
    ":hardware_info_delegate",
    ":util",
    "//base",
    "//build:chromeos_buildflags",
    "//chrome/browser/extensions",
    "//chrome/browser/profiles:profile",
    "//chrome/common/chromeos/extensions",
    "//content/public/browser",
    "//extensions/browser",
    "//extensions/common",
    "//third_party/abseil-cpp:absl",
  ]

  if (is_chromeos_ash) {
    deps += [
      "//ash/constants",
      "//chromeos/ash/components/browser_context_helper",
      "//components/account_id",
      "//components/user_manager",
    ]
  }

  if (is_chromeos_lacros) {
    deps += [
      "//chromeos/crosapi/mojom",
      "//chromeos/startup",
      "//components/policy/core/common",
    ]
  }
}

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

  deps = [
    "//chrome/browser/profiles:profile",
    "//chrome/browser/ui",
    "//chrome/common",
    "//chromeos/constants",
    "//components/security_state/content",
    "//components/security_state/core",
    "//extensions/common",
  ]

  if (is_chromeos_ash) {
    deps += [
      "//ash/constants",
      "//ash/webui/shimless_rma/backend",
    ]
  }
}

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

  deps = [
    "//build:chromeos_buildflags",
    "//chromeos/crosapi/mojom",
    "//mojo/public/cpp/bindings",
  ]

  if (is_chromeos_ash) {
    deps += [
      "//chrome/browser/ash/crosapi:crosapi",
      "//chromeos/ash/components/telemetry_extension/telemetry",
    ]
  }

  if (is_chromeos_lacros) {
    deps += [ "//chromeos/lacros" ]
  }
}

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

  deps = [
    ":remote_probe_strategy",
    "//base",
    "//chromeos/crosapi/mojom",
  ]
}

source_set("test_support") {
  testonly = true

  sources = [
    "base_telemetry_extension_browser_test.cc",
    "base_telemetry_extension_browser_test.h",
    "fake_api_guard_delegate.cc",
    "fake_api_guard_delegate.h",
  ]

  deps = [
    ":common",
    ":remote_probe_strategy",
    "//base",
    "//chrome/test:test_support",
    "//chromeos/crosapi/cpp/telemetry:test_support",
    "//content/public/browser",
    "//extensions:test_support",
    "//net",
    "//testing/gtest",
    "//third_party/abseil-cpp:absl",
  ]
}

source_set("browser_tests") {
  testonly = true

  defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]

  sources = [
    "base_telemetry_extension_api_guard_function_browsertest.cc",
    "telemetry_extension_capabilities_browser_test.cc",
  ]

  deps = [
    ":common",
    ":hardware_info_delegate",
    ":remote_probe_strategy",
    ":test_support",
    "//base",
    "//base/test:test_support",
    "//build:chromeos_buildflags",
    "//chrome/common/chromeos/extensions",
    "//chrome/test:test_support_ui",
    "//chromeos/crosapi/cpp/telemetry:test_support",
    "//content/public/browser",
    "//content/test:test_support",
    "//extensions:test_support",
    "//extensions/common",
    "//mojo/public/cpp/bindings",
    "//net",
    "//net:test_support",
    "//testing/gtest",
    "//url",
  ]

  data = [ "//chrome/test/data" ]

  if (is_chromeos_ash) {
    deps += [
      "//chrome/browser/ash/login/users:test_support",
      "//components/user_manager",
    ]
  }

  if (is_chromeos_lacros) {
    deps += [
      "//chromeos/lacros",
      "//chromeos/startup",
      "//components/policy/core/common",
    ]
  }
}

source_set("unit_tests") {
  testonly = true

  sources = [ "api_guard_delegate_unittest.cc" ]

  deps = [
    ":common",
    ":hardware_info_delegate",
    ":remote_probe_strategy",
    ":test_support",
    "//base",
    "//base/test:test_support",
    "//build:chromeos_buildflags",
    "//chrome/browser/extensions:test_support",
    "//chrome/test:test_support",
    "//chromeos/crosapi/cpp/telemetry:test_support",
    "//components/sync_preferences:test_support",
    "//content/public/browser",
    "//extensions/common",
    "//net",
    "//net:test_support",
    "//testing/gtest",
  ]

  if (is_chromeos_ash) {
    deps += [
      "//ash/webui/shimless_rma/backend",
      "//chrome/browser/ash/login/users:test_support",
      "//chrome/common/chromeos/extensions",
      "//chromeos/ash/components/browser_context_helper",
      "//components/user_manager",
    ]
  }

  if (is_chromeos_lacros) {
    deps += [
      "//chromeos/crosapi/mojom",
      "//chromeos/startup",
      "//components/policy/core/common",
    ]
  }
}