# Copyright 2021 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")
import("//remoting/remoting_options.gni")

mojom("mojom") {
  sources = [
    "agent_process_broker.mojom",
    "chromoting_host_services.mojom",
    "common.mojom",
    "remote_security_key.mojom",
    "remote_support.mojom",
    "remote_url_opener.mojom",
    "remoting_host.mojom",
    "webauthn_proxy.mojom",
  ]

  if (remoting_multi_process) {
    sources += [
      "desktop_session.mojom",
      "keyboard_layout.mojom",
      "peer_session.mojom",
      "webrtc_types.mojom",
    ]
    if (is_linux) {
      sources += [ "login_session.mojom" ]
    }
  }

  deps = [
    "//mojo/public/mojom/base",
    "//services/network/public/mojom:mojom_ip_address",
    "//ui/gfx/geometry/mojom",
    "//url/mojom:url_mojom_gurl",
  ]

  mojom_typemap_types = [
    {
      mojom = "remoting.mojom.ProtocolErrorCode"
      cpp = "::remoting::ErrorCode"
    },
    {
      mojom = "remoting.mojom.SourceLocation"
      cpp = "::remoting::SourceLocation"
    },
    {
      mojom = "remoting.mojom.PortRange"
      cpp = "::remoting::PortRange"
    },
    {
      mojom = "remoting.mojom.SessionPolicies"
      cpp = "::remoting::SessionPolicies"
    },
    {
      mojom = "remoting.mojom.SessionOptions"
      cpp = "::remoting::SessionOptions"
    },
  ]
  if (remoting_multi_process) {
    mojom_typemap_types += [
      {
        mojom = "remoting.mojom.AudioSampleInfo"
        cpp = "::remoting::protocol::AudioSampleInfo"
      },
      {
        mojom = "remoting.mojom.AudioPacket"
        cpp = "::std::unique_ptr<::remoting::AudioPacket>"
        move_only = true
      },
      {
        mojom = "remoting.mojom.AudioPacket.BytesPerSample"
        cpp = "::remoting::AudioPacket::BytesPerSample"
      },
      {
        mojom = "remoting.mojom.AudioPacket.Channels"
        cpp = "::remoting::AudioPacket::Channels"
      },
      {
        mojom = "remoting.mojom.AudioPacket.Encoding"
        cpp = "::remoting::AudioPacket::Encoding"
      },
      {
        mojom = "remoting.mojom.AudioPacket.SamplingRate"
        cpp = "::remoting::AudioPacket::SamplingRate"
      },
      {
        mojom = "remoting.mojom.ClipboardEvent"
        cpp = "::remoting::protocol::ClipboardEvent"
      },
      {
        mojom = "remoting.mojom.DesktopCaptureOptions"
        cpp = "::webrtc::DesktopCaptureOptions"
      },
      {
        mojom = "remoting.mojom.DesktopCaptureResult"
        cpp = "::webrtc::DesktopCapturer::Result"
      },
      {
        mojom = "remoting.mojom.DesktopEnvironmentOptions"
        cpp = "::remoting::DesktopEnvironmentOptions"
      },
      {
        mojom = "remoting.mojom.DesktopRect"
        cpp = "::webrtc::DesktopRect"
      },
      {
        mojom = "remoting.mojom.DesktopSize"
        cpp = "::webrtc::DesktopSize"
      },
      {
        mojom = "remoting.mojom.DesktopVector"
        cpp = "::webrtc::DesktopVector"
      },
      {
        mojom = "remoting.mojom.FileTransferError"
        cpp = "::remoting::protocol::FileTransfer_Error"
      },
      {
        mojom = "remoting.mojom.FractionalCoordinate"
        cpp = "::remoting::protocol::FractionalCoordinate"
      },
      {
        mojom = "remoting.mojom.FileTransferError.Type"
        cpp = "::remoting::protocol::FileTransfer_Error_Type"
      },
      {
        mojom = "remoting.mojom.KeyboardLayout"
        cpp = "::remoting::protocol::KeyboardLayout"
      },
      {
        mojom = "remoting.mojom.KeyAction"
        cpp = "::remoting::protocol::KeyboardLayout::KeyAction"
      },
      {
        mojom = "remoting.mojom.KeyBehavior"
        cpp = "::remoting::protocol::KeyboardLayout::KeyBehavior"
      },
      {
        mojom = "remoting.mojom.KeyEvent"
        cpp = "::remoting::protocol::KeyEvent"
      },
      {
        mojom = "remoting.mojom.LayoutKeyFunction"
        cpp = "::remoting::protocol::LayoutKeyFunction"
      },
      {
        mojom = "remoting.mojom.MicrophoneControl"
        cpp = "::remoting::protocol::MicrophoneControl"
      },
      {
        mojom = "remoting.mojom.MouseButton"
        cpp = "::remoting::protocol::MouseEvent::MouseButton"
      },
      {
        mojom = "remoting.mojom.MouseCursor"
        cpp = "::webrtc::MouseCursor"
      },
      {
        mojom = "remoting.mojom.MouseEvent"
        cpp = "::remoting::protocol::MouseEvent"
      },
      {
        mojom = "remoting.mojom.ReadChunkResult"
        cpp = "::remoting::protocol::FileTransferResult<std::vector<uint8_t>>"
      },
      {
        mojom = "remoting.mojom.ScreenResolution"
        cpp = "::remoting::ScreenResolution"
      },
      {
        mojom = "remoting.mojom.TextEvent"
        cpp = "::remoting::protocol::TextEvent"
      },
      {
        mojom = "remoting.mojom.TouchEvent"
        cpp = "::remoting::protocol::TouchEvent"
      },
      {
        mojom = "remoting.mojom.TouchEventPoint"
        cpp = "::remoting::protocol::TouchEventPoint"
      },
      {
        mojom = "remoting.mojom.TouchEventType"
        cpp = "::remoting::protocol::TouchEvent::TouchEventType"
      },
      {
        mojom = "remoting.mojom.TransportRoute"
        cpp = "::remoting::protocol::TransportRoute"
      },
      {
        mojom = "remoting.mojom.TransportRouteType"
        cpp = "::remoting::protocol::TransportRoute::RouteType"
      },
      {
        mojom = "remoting.mojom.VideoLayout"
        cpp = "::remoting::protocol::VideoLayout"
      },
      {
        mojom = "remoting.mojom.VideoLayout.PixelType"
        cpp = "::remoting::protocol::VideoLayout::PixelType"
      },
      {
        mojom = "remoting.mojom.VideoTrackLayout"
        cpp = "::remoting::protocol::VideoTrackLayout"
      },
      {
        mojom = "remoting.mojom.IpcFifoBufferReader"
        cpp = "::std::unique_ptr<::remoting::IpcFifoBufferReader>"
        move_only = true
        nullable_is_same_type = true
      },
      {
        mojom = "remoting.mojom.WebrtcSocketAddress"
        cpp = "::webrtc::SocketAddress"
      },
      {
        mojom = "remoting.mojom.WebrtcIceCandidateType"
        cpp = "::webrtc::IceCandidateType"
      },
      {
        mojom = "remoting.mojom.WebrtcCandidate"
        cpp = "::webrtc::Candidate"
      },
      {
        mojom = "remoting.mojom.SdpType"
        cpp = "::remoting::SessionDescription::Type"
      },
      {
        mojom = "remoting.mojom.SessionDescription"
        cpp = "::remoting::SessionDescription"
      },
      {
        mojom = "remoting.mojom.NamedCandidate"
        cpp = "::remoting::IceTransportInfo::NamedCandidate"
      },
      {
        mojom = "remoting.mojom.JingleTransportInfo"
        cpp = "::remoting::JingleTransportInfo"
      },
      {
        mojom = "remoting.mojom.WebrtcProtocolType"
        cpp = "::webrtc::ProtocolType"
      },
      {
        mojom = "remoting.mojom.WebrtcRelayServerConfig"
        cpp = "::webrtc::RelayServerConfig"
      },
      {
        mojom = "remoting.mojom.IceConfig"
        cpp = "::remoting::protocol::IceConfig"
        move_only = true
      },
      {
        mojom = "remoting.mojom.PairingResponse"
        cpp = "::remoting::protocol::PairingResponse"
        move_only = true
      },
    ]

    if (is_win) {
      mojom_typemap_types += [
        {
          mojom = "remoting.mojom.FileChooserResult"
          cpp = "::remoting::Result<base::FilePath, ::remoting::protocol::FileTransfer_Error>"
        },
      ]
    }
  }

  cpp_typemaps = [
    {
      types = mojom_typemap_types
      traits_headers = [ "remoting_mojom_traits.h" ]
      traits_sources = [ "remoting_mojom_traits.cc" ]
      traits_public_deps = [
        "//mojo/public/cpp/base:shared_typemap_traits",
        "//mojo/public/cpp/bindings",
        "//mojo/public/cpp/bindings:protobuf_support",
        "//remoting/base",
        "//remoting/base:buildflags",
        "//remoting/host/base",
        "//remoting/proto",
        "//remoting/protocol",
        "//remoting/protocol:errors",
        "//remoting/protocol:transport",
        "//remoting/signaling",
        "//services/network/public/cpp:ip_address_mojom_support",
        "//third_party/webrtc_overrides:webrtc_component",
      ]
    },
  ]
}
