chromium/url/mojom/BUILD.gn

# 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("//build/config/chromeos/ui_mode.gni")
import("//mojo/public/tools/bindings/mojom.gni")

mojom("url_mojom_gurl") {
  generate_java = true
  sources = [ "url.mojom" ]

  cpp_typemaps = [
    {
      types = [
        {
          mojom = "url.mojom.Url"
          cpp = "::GURL"
        },
      ]
      traits_headers = [ "//url/mojom/url_gurl_mojom_traits.h" ]
      traits_public_deps = [
        ":mojom_traits",
        "//url",
      ]
    },
  ]

  blink_cpp_typemaps = [
    {
      types = [
        {
          mojom = "url.mojom.Url"
          cpp = "::blink::KURL"
          force_serialize = true
        },
      ]
      traits_headers = [
        "//third_party/blink/renderer/platform/mojo/kurl_mojom_traits.h",
        "//third_party/blink/renderer/platform/weborigin/kurl_hash.h",
      ]
      traits_public_deps = [ "//url" ]
    },
  ]

  webui_module_path = "chrome://resources/mojo/url/mojom"

  # Used by Closure compiler targets in ash/webui/help_app_ui/, so this needs
  # to generate WebUI bindings in JavaScript on Ash.
  if (is_chromeos_ash) {
    generate_webui_js_bindings = true
  }

  # Legacy JS bindings are needed for Blink regardless of platform.
  generate_legacy_js_bindings = true
}

mojom("url_mojom_origin") {
  generate_java = true
  sources = [ "origin.mojom" ]

  public_deps = [
    ":url_mojom_gurl",
    "//mojo/public/mojom/base",
  ]

  check_includes_blink = false

  cpp_typemaps = [
    {
      types = [
        {
          mojom = "url.mojom.Origin"
          cpp = "::url::Origin"
        },
      ]
      traits_headers = [ "//url/mojom/origin_mojom_traits.h" ]
      traits_public_deps = [
        ":mojom_traits",
        "//url",
      ]
    },
  ]

  blink_cpp_typemaps = [
    {
      types = [
        {
          mojom = "url.mojom.Origin"
          cpp = "::scoped_refptr<const ::blink::SecurityOrigin>"
          nullable_is_same_type = true
        },
      ]
      traits_headers = [ "//third_party/blink/renderer/platform/mojo/security_origin_mojom_traits.h" ]
      traits_public_deps = [ "//url" ]
    },
  ]

  webui_module_path = "chrome://resources/mojo/url/mojom"
  generate_legacy_js_bindings = true
}

mojom("url_mojom_scheme_host_port") {
  generate_java = true
  sources = [ "scheme_host_port.mojom" ]

  cpp_typemaps = [
    {
      types = [
        {
          mojom = "url.mojom.SchemeHostPort"
          cpp = "::url::SchemeHostPort"
        },
      ]
      traits_headers = [ "//url/mojom/scheme_host_port_mojom_traits.h" ]
      traits_public_deps = [ "//url" ]
    },
  ]

  blink_cpp_typemaps = cpp_typemaps
}

mojom("test_url_mojom_gurl") {
  sources = [ "url_test.mojom" ]

  public_deps = [
    ":url_mojom_gurl",
    ":url_mojom_origin",
    ":url_mojom_scheme_host_port",
  ]
}

component("mojom_traits") {
  output_name = "url_mojom_traits"

  sources = [
    "origin_mojom_traits.cc",
    "origin_mojom_traits.h",
    "scheme_host_port_mojom_traits.cc",
    "scheme_host_port_mojom_traits.h",
    "url_gurl_mojom_traits.cc",
    "url_gurl_mojom_traits.h",
  ]

  defines = [ "IS_URL_MOJOM_TRAITS_IMPL" ]

  public_deps = [
    ":url_mojom_gurl_shared",
    ":url_mojom_origin_shared",
    ":url_mojom_scheme_host_port",
    "//base",
    "//mojo/public/cpp/base:shared_typemap_traits",
    "//url",
  ]

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