chromium/components/enterprise/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/chromeos/ui_mode.gni")
import("//components/enterprise/buildflags/buildflags.gni")

static_library("enterprise") {
  sources = [
    "browser/reporting/browser_report_generator.cc",
    "browser/reporting/browser_report_generator.h",
    "browser/reporting/chrome_profile_request_generator.cc",
    "browser/reporting/chrome_profile_request_generator.h",
    "browser/reporting/cloud_reporting_frequency_policy_handler.cc",
    "browser/reporting/cloud_reporting_frequency_policy_handler.h",
    "browser/reporting/cloud_reporting_policy_handler.cc",
    "browser/reporting/cloud_reporting_policy_handler.h",
    "browser/reporting/common_pref_names.cc",
    "browser/reporting/common_pref_names.h",
    "browser/reporting/os_report_generator.cc",
    "browser/reporting/os_report_generator.h",
    "browser/reporting/policy_info.cc",
    "browser/reporting/policy_info.h",
    "browser/reporting/profile_report_generator.cc",
    "browser/reporting/profile_report_generator.h",
    "browser/reporting/real_time_report_controller.cc",
    "browser/reporting/real_time_report_controller.h",
    "browser/reporting/real_time_report_generator.cc",
    "browser/reporting/real_time_report_generator.h",
    "browser/reporting/real_time_report_type.h",
    "browser/reporting/real_time_uploader.cc",
    "browser/reporting/real_time_uploader.h",
    "browser/reporting/report_generator.cc",
    "browser/reporting/report_generator.h",
    "browser/reporting/report_request.cc",
    "browser/reporting/report_request.h",
    "browser/reporting/report_request_queue_generator.cc",
    "browser/reporting/report_request_queue_generator.h",
    "browser/reporting/report_scheduler.cc",
    "browser/reporting/report_scheduler.h",
    "browser/reporting/report_type.h",
    "browser/reporting/report_uploader.cc",
    "browser/reporting/report_uploader.h",
    "browser/reporting/report_util.cc",
    "browser/reporting/report_util.h",
    "browser/reporting/reporting_delegate_factory.h",
  ]

  if (!is_chromeos_ash) {
    sources += [
      "browser/controller/browser_dm_token_storage.cc",
      "browser/controller/browser_dm_token_storage.h",
      "browser/controller/chrome_browser_cloud_management_helper.cc",
      "browser/controller/chrome_browser_cloud_management_helper.h",
      "browser/enterprise_switches.cc",
      "browser/enterprise_switches.h",
    ]
  }

  if (!is_ios) {
    sources += [
      "browser/reporting/cloud_profile_reporting_policy_handler.cc",
      "browser/reporting/cloud_profile_reporting_policy_handler.h",
    ]
  }

  deps = [
    "//base",
    "//build:chromeos_buildflags",
    "//components/policy/core/browser",
    "//components/policy/core/common",
    "//components/policy/proto",
    "//components/prefs",
    "//components/reporting/client:report_queue_provider",
    "//components/strings",
    "//components/version_info",
    "//crypto",
    "//net",
    "//services/network/public/cpp",
  ]

  # Include certain intermediate targets as public deps so consumers
  # can start using them as needed.
  public_deps = [
    "//components/reporting/client:report_queue_configuration",
    "//components/reporting/util:status",
  ]

  if (!is_chromeos_ash) {
    sources += [
      "browser/controller/chrome_browser_cloud_management_controller.cc",
      "browser/controller/chrome_browser_cloud_management_controller.h",
      "browser/device_trust/device_trust_key_manager.h",
    ]

    deps += [ "//third_party/abseil-cpp:absl" ]
  }
}

static_library("test_support") {
  testonly = true

  if (!is_chromeos_ash) {
    sources = [
      "browser/controller/fake_browser_dm_token_storage.cc",
      "browser/controller/fake_browser_dm_token_storage.h",
    ]
    deps = [
      ":enterprise",
      "//base",
    ]
  }
}

static_library("reporting_test_support") {
  testonly = true

  sources = [
    "browser/reporting/fake_browser_report_generator_delegate.cc",
    "browser/reporting/fake_browser_report_generator_delegate.h",
  ]

  deps = [
    ":enterprise",
    "//base",
    "//components/policy/core/common:test_support",
    "//components/policy/proto",
    "//components/version_info",
  ]
}

source_set("unit_tests") {
  testonly = true

  sources = [
    "browser/identifiers/profile_id_service_unittest.cc",
    "browser/reporting/chrome_profile_request_generator_unittest.cc",
    "browser/reporting/report_uploader_unittest.cc",
    "common/proto/connectors_unittest.cc",
  ]

  deps = [
    ":enterprise",
    ":reporting_test_support",
    "common/proto:connectors_proto",
    "//base/test:test_support",
    "//build:chromeos_buildflags",
    "//components/enterprise/browser/identifiers",
    "//components/enterprise/browser/identifiers:test_support",
    "//components/policy/core/common:test_support",
    "//components/prefs:test_support",
    "//components/version_info",
    "//testing/gmock",
    "//testing/gtest",
    "//third_party/content_analysis_sdk:liblcasdk",
  ]

  if (!is_chromeos_ash) {
    sources += [
      "browser/controller/browser_dm_token_storage_unittest.cc",
      "browser/reporting/cloud_reporting_policy_handler_unittest.cc",
    ]

    deps += [
      ":test_support",
      "//base",
      "//components/policy/core/browser:test_support",
    ]
  }

  if (!is_android && !is_ios) {
    sources += [ "browser/reporting/real_time_uploader_unittest.cc" ]
    deps += [
      "//base",
      "//components/enterprise/common/proto:extensions_workflow_events_proto",
      "//components/reporting/client:mock_report_queue_provider",
      "//components/reporting/client:test_support",
    ]
  }

  if (enterprise_client_certificates) {
    deps += [ "//components/enterprise/client_certificates:unit_tests" ]
  }
}