chromium/components/services/quarantine/BUILD.gn

# Copyright 2019 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/cast.gni")

if (is_android) {
  import("//build/config/android/rules.gni")
}

static_library("quarantine") {
  sources = [
    "quarantine.cc",
    "quarantine.h",
    "quarantine_impl.cc",
    "quarantine_impl.h",
  ]

  public_deps = [ "//components/services/quarantine/public/mojom" ]

  deps = [
    ":common",
    "//base",
    "//net",
    "//url",
  ]

  if (is_win) {
    sources += [ "quarantine_win.cc" ]
  }

  if (is_mac) {
    sources += [ "quarantine_mac.mm" ]
    frameworks = [
      "Carbon.framework",
      "Foundation.framework",
    ]
  }

  if (is_chromeos) {
    sources += [ "quarantine_chromeos.cc" ]
    deps += [
      "//chromeos/dbus/dlp",
      "//chromeos/dbus/dlp:dlp_proto",
    ]
  }
}

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

  deps = [
    "//base",
    "//url",
  ]

  if (is_win) {
    sources += [
      "common_win.cc",
      "common_win.h",
    ]
  }

  if (is_mac) {
    sources += [
      "common_mac.h",
      "common_mac.mm",
    ]
    frameworks = [
      "Carbon.framework",
      "Foundation.framework",
    ]
  }
}

source_set("test_support") {
  testonly = true

  sources = [
    "test_support.cc",
    "test_support.h",
  ]

  deps = [
    ":common",
    ":quarantine",
    "//base",
    "//url",
  ]

  if (is_win) {
    sources += [ "test_support_win.cc" ]
  }

  if (is_mac) {
    sources += [ "test_support_mac.mm" ]
    frameworks = [
      "Carbon.framework",
      "Foundation.framework",
    ]
  }
}

source_set("unit_tests") {
  testonly = true

  sources = [
    "common_unittests.cc",
    "quarantine_service_unittest.cc",
  ]

  # Chromecasts do not have extended attributes enabled; even if it were
  # enabled, the devices use tmpfs which restricts the extended attributes that
  # can be set such that quarantining still would not work. (The platform
  # specific tests include a runtime guard to skip tests that need xattr.)
  if (!is_castos && !is_cast_android) {
    sources += [ "quarantine_unittest.cc" ]
  }

  deps = [
    ":common",
    ":quarantine",
    ":test_support",
    "//base",
    "//base/test:test_support",
    "//components/services/quarantine/public/mojom",
    "//net",
    "//testing/gmock",
    "//testing/gtest",
    "//url",
  ]

  if (is_win) {
    sources += [ "quarantine_win_unittest.cc" ]
  }

  if (is_mac) {
    sources += [ "quarantine_mac_unittest.mm" ]
    frameworks = [
      "Carbon.framework",
      "Foundation.framework",
    ]
  }
}