chromium/components/js_injection/common/BUILD.gn

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

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

mojom("common_mojom") {
  sources = [
    "interfaces.mojom",
    "origin_matcher.mojom",
  ]

  public_deps = [
    "//mojo/public/mojom/base",
    "//third_party/blink/public/mojom:mojom_core",
  ]

  cpp_typemaps = [
    {
      types = [
        {
          mojom = "js_injection.mojom.OriginMatcher"
          cpp = "::js_injection::OriginMatcher"
        },
        {
          mojom = "js_injection.mojom.OriginMatcherRule"
          cpp = "::std::unique_ptr<::js_injection::OriginMatcherRule>"
          move_only = true
        },
      ]
      traits_headers = [
        "origin_matcher_mojom_traits.h",
        "origin_matcher.h",
      ]
      traits_sources = [ "origin_matcher_mojom_traits.cc" ]
      traits_public_deps = [ ":common" ]
    },
    {
      types = [
        {
          mojom = "js_injection.mojom.JsWebMessage"
          cpp = "::blink::WebMessagePayload"
          move_only = true
        },
      ]
      traits_headers = [ "web_message_mojom_traits.h" ]
      traits_sources = [ "web_message_mojom_traits.cc" ]
      traits_public_deps = [ "//third_party/blink/public/common" ]
    },
  ]
  overridden_deps = [ "//third_party/blink/public/mojom:mojom_core" ]
  component_deps = [ "//third_party/blink/public/common" ]
}

source_set("common") {
  public = [
    "origin_matcher.h",
  ]
  sources = [
    "origin_matcher.cc",
    "origin_matcher_internal.cc",
    "origin_matcher_internal.h",
  ]
  deps = [
    "//base",
    "//net",
    "//url",
  ]

  # origin_matcher_internal is needed by mojom traits and tests.
  friend = [ ":*" ]
}

source_set("unit_tests") {
  testonly = true
  sources = [
    "origin_matcher_unittest.cc",
    "web_message_mojom_traits_unittest.cc",
  ]
  deps = [
    ":common",
    ":common_mojom",
    "//base",
    "//base/test:test_support",
    "//mojo/public/cpp/test_support:test_utils",
    "//url",
  ]
}