chromium/chrome/browser/enterprise/connectors/device_trust/key_management/core/persistence/BUILD.gn

# Copyright 2021 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

source_set("persistence") {
  public = [
    "key_persistence_delegate.h",
    "key_persistence_delegate_factory.h",
    "metrics_utils.h",
  ]

  sources = [
    "key_persistence_delegate.cc",
    "key_persistence_delegate_factory.cc",
    "metrics_utils.cc",
  ]

  deps = [ "//base" ]

  public_deps = [
    "//chrome/browser/enterprise/connectors/device_trust/key_management/common",
    "//chrome/browser/enterprise/connectors/device_trust/key_management/core",
    "//components/policy/proto",
    "//crypto",
    "//third_party/abseil-cpp:absl",
  ]

  if (is_win) {
    sources += [
      "win_key_persistence_delegate.cc",
      "win_key_persistence_delegate.h",
    ]
    deps += [ "//chrome/installer/util:with_no_strings" ]

    friend = [ ":unit_tests" ]
  }

  if (is_mac) {
    sources += [
      "mac_key_persistence_delegate.cc",
      "mac_key_persistence_delegate.h",
    ]
    deps += [
      "//chrome/browser/enterprise/connectors/device_trust/key_management/core:constants",
      "//chrome/browser/enterprise/connectors/device_trust/key_management/core/mac",
    ]
    friend = [ ":unit_tests" ]
  }

  if (is_linux) {
    sources += [
      "linux_key_persistence_delegate.cc",
      "linux_key_persistence_delegate.h",
    ]
    deps += [
      "//build:branding_buildflags",
      "//chrome/browser/enterprise/connectors/device_trust/key_management/core:constants",
      "//components/policy/core/common:policy_path_constants",
    ]

    friend = [ ":unit_tests" ]
  }
}

source_set("test_support") {
  testonly = true
  public = [
    "mock_key_persistence_delegate.h",
    "scoped_key_persistence_delegate_factory.h",
  ]

  sources = [
    "mock_key_persistence_delegate.cc",
    "scoped_key_persistence_delegate_factory.cc",
  ]

  public_deps = [
    ":persistence",
    "//crypto:test_support",
    "//testing/gmock",
    "//testing/gtest",
  ]

  deps = [
    "//base",
    "//chrome/browser/enterprise/connectors/device_trust/key_management/core",
    "//crypto",
  ]
}

source_set("unit_tests") {
  testonly = true

  deps = [
    ":persistence",
    "//base",
    "//chrome/browser/enterprise/connectors/device_trust/key_management/core",
    "//components/policy/proto",
    "//testing/gtest",
  ]

  if (is_win) {
    sources = [ "win_key_persistence_delegate_unittest.cc" ]

    deps += [
      "//base/test:test_support",
      "//chrome/install_static:install_static_util",
      "//chrome/installer/util:with_no_strings",
      "//crypto:test_support",
    ]
  }

  if (is_linux) {
    sources = [ "linux_key_persistence_delegate_unittest.cc" ]
    deps += [ "//base/test:test_support" ]
  }

  if (is_mac) {
    sources = [ "mac_key_persistence_delegate_unittest.mm" ]

    deps += [
      "//chrome/browser/enterprise/connectors/device_trust/key_management/core:constants",
      "//chrome/browser/enterprise/connectors/device_trust/key_management/core/mac",
      "//chrome/browser/enterprise/connectors/device_trust/key_management/core/mac:test_support",
    ]

    frameworks = [
      "Foundation.framework",
      "Security.framework",
    ]
  }
}