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

import("//build/config/features.gni")

assert(!is_ios, "Policy should not be referenced on iOS")

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

source_set("internal") {
  visibility = [ "//components/policy/*" ]
  sources = [
    "browser_policy_connector.cc",
    "browser_policy_connector.h",
    "browser_policy_connector_base.cc",
    "browser_policy_connector_base.h",
    "browser_policy_connector_ios.h",
    "browser_policy_connector_ios.mm",
    "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_error_map.cc",
    "policy_error_map.h",
    "proxy_policy_handler.cc",
    "proxy_policy_handler.h",
    "url_blacklist_manager.cc",
    "url_blacklist_manager.h",
    "url_blacklist_policy_handler.cc",
    "url_blacklist_policy_handler.h",
  ]

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

  public_deps = [
    "//base",
  ]
  deps = [
    "//base/third_party/dynamic_annotations",
    "//components/bookmarks/managed",
    "//components/keyed_service/core",
    "//components/pref_registry",
    "//components/prefs",
    "//components/strings",
    "//components/url_formatter",
    "//components/url_matcher",
    "//net",
    "//ui/base",
  ]

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

  public_deps += [ "//components/policy/core/common:internal" ]
  deps += [
    "//components/proxy_config",
    "//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",
  ]
}

source_set("unit_tests") {
  testonly = true
  sources = [
    "android/android_combined_policy_provider_unittest.cc",
    "android/policy_converter_unittest.cc",
    "browser_policy_connector_unittest.cc",
    "configuration_policy_handler_unittest.cc",
    "configuration_policy_pref_store_unittest.cc",
    "proxy_policy_handler_unittest.cc",
    "url_blacklist_manager_unittest.cc",
    "url_blacklist_policy_handler_unittest.cc",
  ]
  deps = [
    ":test_support",
    "//base",
    "//components/policy:generated",
    "//components/prefs:test_support",
    "//components/proxy_config",
    "//components/url_formatter",
    "//google_apis",
    "//net",
    "//testing/gmock",
    "//testing/gtest",
  ]
}