# 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" ]

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

  cpp_typemaps = [
    {
      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" ]
}

# Contains only the data (enum) types needed by Java.
mojom("enum_mojom") {
  generate_java = true
  sources = [ "enum.mojom" ]
}

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