chromium/components/policy/core/browser/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/chromeos/ui_mode.gni")
import("//build/config/features.gni")

group("browser") {
  if (is_component_build) {
    public_deps = [ "//components/policy" ]
  } else {
    public_deps = [ ":internal" ]
  }
}

source_set("internal") {
  visibility = [ "//components/policy/*" ]
  sources = [
    "boolean_disabling_policy_handler.cc",
    "boolean_disabling_policy_handler.h",
    "browser_policy_connector.cc",
    "browser_policy_connector.h",
    "browser_policy_connector_base.cc",
    "browser_policy_connector_base.h",
    "cloud/message_util.cc",
    "cloud/message_util.h",
    "configuration_policy_handler.cc",
    "configuration_policy_handler.h",
    "configuration_policy_handler_list.cc",
    "configuration_policy_handler_list.h",
    "configuration_policy_pref_store.cc",
    "configuration_policy_pref_store.h",
    "policy_conversions.cc",
    "policy_conversions.h",
    "policy_conversions_client.cc",
    "policy_conversions_client.h",
    "policy_error_map.cc",
    "policy_error_map.h",
    "remote_commands/user_remote_commands_service_base.cc",
    "remote_commands/user_remote_commands_service_base.h",
    "signin/profile_separation_policies.cc",
    "signin/profile_separation_policies.h",
    "signin/user_cloud_signin_restriction_policy_fetcher.cc",
    "signin/user_cloud_signin_restriction_policy_fetcher.h",
    "url_allowlist_policy_handler.cc",
    "url_allowlist_policy_handler.h",
    "url_blocklist_manager.cc",
    "url_blocklist_manager.h",
    "url_blocklist_policy_handler.cc",
    "url_blocklist_policy_handler.h",
    "url_scheme_list_policy_handler.cc",
    "url_scheme_list_policy_handler.h",
    "webui/json_generation.cc",
    "webui/json_generation.h",
    "webui/machine_level_user_cloud_policy_status_provider.cc",
    "webui/machine_level_user_cloud_policy_status_provider.h",
    "webui/policy_data_utils.cc",
    "webui/policy_data_utils.h",
    "webui/policy_status_provider.cc",
    "webui/policy_status_provider.h",
    "webui/policy_webui_constants.cc",
    "webui/policy_webui_constants.h",
    "webui/statistics_collector.cc",
    "webui/statistics_collector.h",
  ]

  if (!is_chromeos_ash) {
    sources += [
      "cloud/user_policy_signin_service_base.cc",
      "cloud/user_policy_signin_service_base.h",
      "cloud/user_policy_signin_service_util.cc",
      "cloud/user_policy_signin_service_util.h",
    ]
  }

  configs += [ "//components/policy:component_implementation" ]

  public_deps = [ "//base" ]
  deps = [
    "//build:branding_buildflags",
    "//build:chromeos_buildflags",
    "//components/google/core/common",
    "//components/invalidation/impl",
    "//components/keyed_service/core",
    "//components/pref_registry",
    "//components/prefs",
    "//components/reporting/proto:record_proto",
    "//components/signin/public/identity_manager:identity_manager",
    "//components/strings",
    "//components/url_formatter",
    "//components/url_matcher",
    "//components/version_info",
    "//extensions/buildflags",
    "//net",
    "//services/network/public/cpp",
    "//third_party/re2",
    "//ui/base",
    "//url",
  ]

  if (is_android) {
    sources += [
      "android/policy_cache_updater_android.cc",
      "android/policy_cache_updater_android.h",
    ]
    deps += [ "//components/policy/android:jni_headers" ]
  }

  public_deps += [ "//components/policy/core/common:internal" ]
  deps += [
    "//google_apis",
    "//net",
    "//third_party/icu",
  ]
}

static_library("test_support") {
  testonly = true
  sources = [
    "configuration_policy_pref_store_test.cc",
    "configuration_policy_pref_store_test.h",
  ]

  public_deps = [
    ":browser",
    "//base",

    # Explicitly link in the generated policy target into the test support
    # so it will be linked to dependent targets. Otherwise in component
    # build, it will be hidden inside the policy component.
    "//components/policy:generated",
    "//components/policy/core/common:test_support",
  ]
  deps = [ "//testing/gtest" ]
}

# This is separate from the test_support target, so that only the test binaries
# that actually run pref_mapping tests can pull these, but other test binaries
# won't have these unnecessary dependencies.
source_set("pref_mapping_test_support") {
  testonly = true
  sources = [
    "policy_pref_mapping_test.cc",
    "policy_pref_mapping_test.h",
  ]

  public_deps = [ ":test_support" ]

  deps = [
    "//base",
    "//build:branding_buildflags",
    "//components/policy:generated",
    "//components/policy/core/common:test_support",
    "//components/prefs",
    "//printing/buildflags",
    "//testing/gtest",
    "//third_party/abseil-cpp:absl",
    "//url",
  ]

  # The test data is under components/policy/test/data instead of
  # chrome/test/data/ because components/policy/PRESUBMIT.py depends on it.
  # This makes presubmit run when files are modified in that directory.
  data = [ "//components/policy/test/data/pref_mapping/" ]
}

source_set("unit_tests") {
  testonly = true
  sources = [
    "boolean_disabling_policy_handler_unittest.cc",
    "configuration_policy_handler_list_unittest.cc",
    "configuration_policy_handler_unittest.cc",
    "configuration_policy_pref_store_unittest.cc",
    "policy_conversions_client_unittest.cc",
    "policy_error_map_unittest.cc",
    "signin/user_cloud_signin_restriction_policy_fetcher_unittest.cc",
    "url_allowlist_policy_handler_unittest.cc",
    "url_blocklist_manager_unittest.cc",
    "url_blocklist_policy_handler_unittest.cc",
    "url_scheme_list_policy_handler_unittest.cc",
  ]
  deps = [
    ":browser",
    ":test_support",
    "//base",
    "//components/policy:generated",
    "//components/prefs:test_support",
    "//components/signin/public/identity_manager:identity_manager",
    "//components/signin/public/identity_manager:test_support",
    "//components/url_formatter",
    "//components/url_matcher",
    "//google_apis",
    "//net",
    "//services/network:test_support",
    "//testing/gmock",
    "//testing/gtest",
    "//ui/base",
    "//url",
  ]

  if (is_android) {
    sources += [ "android/policy_cache_updater_android_unittest.cc" ]
    deps += [ "//components/policy/android:test_jni_headers" ]
  }
}