# Copyright 2017 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/jumbo.gni")
import("//testing/test.gni")

jumbo_source_set("common") {
  visibility = [
    "//third_party/blink/*",
    ":*",
  ]

  defines = [ "BLINK_COMMON_IMPLEMENTATION=1" ]

  sources = [
    # NOTE: Please do not add public headers that need to be referenced from
    # outside WebKit, add them in public/common instead.
    "blob/blob_utils.cc",
    "client_hints/client_hints.cc",
    "common_export.h",
    "device_memory/approximated_device_memory.cc",
    "experiments/memory_ablation_experiment.cc",
    "feature_policy/feature_policy.cc",
    "features.cc",
    "frame/frame_policy.cc",
    "frame/user_activation_state.cc",
    "manifest/manifest.cc",
    "manifest/manifest_icon_selector.cc",
    "manifest/manifest_share_target_util.cc",
    "message_port/cloneable_message.cc",
    "message_port/cloneable_message_struct_traits.cc",
    "message_port/cloneable_message_struct_traits.h",
    "message_port/message_port_channel.cc",
    "message_port/string_message_codec.cc",
    "message_port/transferable_message.cc",
    "message_port/transferable_message_struct_traits.cc",
    "message_port/transferable_message_struct_traits.h",
    "mime_util/mime_util.cc",
    "oom_intervention/oom_intervention_types.h",
    "origin_policy/origin_policy.cc",
    "origin_policy/origin_policy_parser.cc",
    "origin_policy/origin_policy_parser.h",
    "origin_trials/trial_token.cc",
    "origin_trials/trial_token_validator.cc",
    "privacy_preferences.cc",
    "service_worker/service_worker_status_code.cc",
    "service_worker/service_worker_type_converters.cc",
    "service_worker/service_worker_utils.cc",
  ]

  public_deps = [
    "//third_party/blink/public/common:headers",
  ]

  deps = [
    "//base",
    "//mojo/public/cpp/system",
    "//net",
    "//services/network/public/cpp:cpp",
  ]

  # iOS doesn't use and must not depend on //media
  if (!is_ios) {
    deps += [ "//media" ]
  }
}

test("blink_common_unittests") {
  visibility = [ "*" ]
  deps = [
    ":common_unittests_sources",
    "//third_party/blink/public/common",
  ]
  if (is_android) {
    deps += [
      "//base:base_java",
      "//media/base/android:media_java",
    ]
  }
}

jumbo_source_set("common_unittests_sources") {
  testonly = true

  sources = [
    "device_memory/approximated_device_memory_unittest.cc",
    "feature_policy/feature_policy_unittest.cc",
    "frame/user_activation_state_unittest.cc",
    "manifest/manifest_icon_selector_unittest.cc",
    "manifest/manifest_share_target_util_unittest.cc",
    "mime_util/mime_util_unittest.cc",
    "origin_policy/origin_policy_unittest.cc",
    "origin_trials/trial_token_unittest.cc",
    "origin_trials/trial_token_validator_unittest.cc",
    "test/run_all_unittests.cc",
  ]

  if (!is_android) {
    # TODO(crbug.com/845384): Enable these tests also on Android. Currently
    # they are excluded as they require V8 environment but V8 snapshot is
    # not available in the current minimum test setting.
    sources += [ "message_port/string_message_codec_unittest.cc" ]
  }

  deps = [
    "//base",
    "//base/test:test_support",
    "//net",
    "//testing/gtest",
    "//third_party/blink/public/common:headers",
    "//third_party/boringssl",
    "//v8",
    "//v8:v8_libplatform",
  ]
}
