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

import("//components/safe_browsing/buildflags.gni")
import("//mojo/public/tools/bindings/mojom.gni")

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

  configs += [ "//build/config/compiler:wexit_time_destructors" ]

  deps = [
    ":features",
    "//components/pref_registry",
    "//components/prefs",
    "//net",
  ]

  public_deps = [ "//base" ]
}

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

  configs += [ "//build/config/compiler:wexit_time_destructors" ]

  deps = [
    ":safe_browsing_prefs",
    "//base",
    "//components/policy:generated",
    "//components/policy/core/browser",
    "//components/prefs",
    "//components/strings:components_strings_grit",
  ]
}

source_set("unit_tests") {
  testonly = true
  sources = [
    "safe_browsing_policy_handler_unittest.cc",
    "safe_browsing_prefs_unittest.cc",
    "scheme_logger_unittest.cc",
    "visual_utils_unittest.cc",
  ]

  deps = [
    ":common",
    ":safe_browsing_policy_handler",
    ":safe_browsing_prefs",
    ":visual_utils",
    "//base",
    "//base/test:test_support",
    "//components/policy/core/browser",
    "//components/policy/core/browser:test_support",
    "//components/prefs:test_support",
    "//testing/gmock",
    "//testing/gtest",
    "//ui/gfx:color_utils",
    "//url",
  ]
  if (is_ios) {
    deps += [ "//components/test:safe_browsing_test_bundle_data" ]
  }
}

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

  configs += [ "//build/config/compiler:wexit_time_destructors" ]

  deps = [
    "//base",
    "//components/safe_browsing:buildflags",
    "//components/safe_browsing/core/common",
    "//components/safe_browsing/core/common/proto:client_model_proto",
    "//components/safe_browsing/core/common/proto:csd_proto",
    "//skia",
    "//ui/gfx",
    "//ui/gfx:color_utils",
  ]
}

source_set("common") {
  sources = [
    "safe_browsing_settings_metrics.cc",
    "safe_browsing_settings_metrics.h",
    "safebrowsing_constants.cc",
    "safebrowsing_constants.h",
    "safebrowsing_referral_methods.h",
    "safebrowsing_switches.cc",
    "safebrowsing_switches.h",
    "scheme_logger.cc",
    "scheme_logger.h",
    "utils.cc",
    "utils.h",
    "web_ui_constants.cc",
    "web_ui_constants.h",
  ]

  configs += [ "//build/config/compiler:wexit_time_destructors" ]

  deps = [
    "//base",
    "//components/policy/core/browser",
    "//components/prefs",
    "//components/safe_browsing:buildflags",
    "//components/safe_browsing/core/browser/db:v4_protocol_manager_util",
    "//components/safe_browsing/core/common/proto:csd_proto",
    "//components/security_interstitials/core:unsafe_resource",
    "//components/variations",
    "//crypto",
    "//ipc",
    "//net",
    "//services/network/public/cpp",
    "//services/network/public/mojom",
    "//url/ipc:url_ipc",
  ]

  public_deps = [
    ":features",
    ":interfaces",
    ":threat_enums",
  ]
}

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

  configs += [ "//build/config/compiler:wexit_time_destructors" ]

  deps = [
    "//base",
    "//components/safe_browsing:buildflags",
  ]
}

mojom("interfaces") {
  sources = [ "safe_browsing_url_checker.mojom" ]

  public_deps = [ "//url/mojom:url_mojom_gurl" ]
}

source_set("threat_enums") {
  sources = [ "threat_enums.h" ]
}
