chromium/remoting/host/mojom/remoting_host.mojom

// 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.

module remoting.mojom;

import "mojo/public/mojom/base/values.mojom";
import "remoting/host/mojom/chromoting_host_services.mojom";
import "services/network/public/mojom/ip_endpoint.mojom";

// Provides a set of methods to allow the Daemon process to initialize and
// control the network (a.k.a. host) process.
// The remote for this interface is owned in the high-privilege daemon process
// and the receiver is bound in the low-privilege network process.
interface RemotingHostControl {
  // Provides host configuration details to the network process such as the
  // owner email and robot account to use for authentication to service APIs.
  // This method may be called multiple times as changes are detected in the
  // host configuration file.
  [EnableIf=is_win]
  ApplyHostConfig(mojo_base.mojom.DictionaryValue config);

  // Provides the network process with a set of platform handles which are used
  // for pairing functionality. The network process does not have access to the
  // privileged platform resource so the Daemon process must open it and provide
  // a handle to it. This method must only be called once per network process
  // instance.
  [EnableIf=is_win]
  InitializePairingRegistry(handle<platform> privileged_handle,
                            handle<platform> unprivileged_handle);

  // Requests the network process to bind a pending receiver of
  // ChromotingHostServices coming from a user-launched process. On Windows, the
  // daemon process is responsible for brokering all mojo IPCs, but it doesn't
  // affect where the receivers and remotes are bound. Please see comments on
  // the ChromotingHostServices interface.
  [EnableIf=is_win]
  BindChromotingHostServices(pending_receiver<ChromotingHostServices> receiver,
                             int32 peer_pid);
};

// Provides a set of methods to allow the Daemon process to notify the network
// (a.k.a. host) process of changes in the desktop environment.
// The remote for this interface is owned in the high-privilege daemon process
// and the receiver is bound in the low-privilege network process.
interface DesktopSessionConnectionEvents {
  // Notifies the network process that the daemon has disconnected the desktop
  // session from the associated desktop environment.
  [EnableIf=is_win]
  OnTerminalDisconnected(int32 terminal_id);

  // Notifies the network process that |terminal_id| is now attached to
  // a desktop integration process. |session_id| is the id of the desktop
  // session attached. |desktop_pipe| is the client end of the message pipe
  // which will be used for IPC communication between the desktop process and
  // the network process.
  [EnableIf=is_win]
  OnDesktopSessionAgentAttached(int32 terminal_id, int32 session_id,
                                handle<message_pipe> desktop_pipe);
};

// This enum mirrors the remoting::protocol::TransportRoute::RouteType enum.
enum TransportRouteType {
  kUndefined = 0,
  kDirect = 1,
  kStun = 2,
  kRelay = 3,
};

// This struct mirrors the remoting::protocol::TransportRoute struct.
struct TransportRoute {
  TransportRouteType type;
  network.mojom.IPEndPoint remote_address;
  network.mojom.IPEndPoint local_address;
};

// Provides a set of methods to allow the Network process to notify the Daemon
// process of state. This is typically used for logging and is meant for
// informational purposes only (i.e. these should not trigger any service-level
// events).
// The signaling_id used throughout this interface is a string which represents
// a user in the FTL signaling service which is used for client to host
// messaging (a necessary step in establishing a P2P connection). An example
// ID would be <[email protected]>/chromoting_ftl_<unique_ftl_resource_id>.
// The remote for this interface is owned in the low-privilege network process
// and the receiver is bound in the high-privilege daemon process.
interface HostStatusObserver {
  // Called when an unauthorized user attempts to connect to the host.
  OnClientAccessDenied(string signaling_id);

  // Called when a new client is authenticated.
  OnClientAuthenticated(string signaling_id);

  // Called when all channels for an authenticated client are connected.
  OnClientConnected(string signaling_id);

  // Called when an authenticated client is disconnected.
  OnClientDisconnected(string signaling_id);

  // Called on notification of a P2P route change (e.g. Relay -> Direct).
  // |channel_name| represents an ICE channel name, it is not used for WebRTC
  // connections.
  OnClientRouteChange(string signaling_id, string channel_name,
                      TransportRoute route);

  // Called when the host is started for an account.
  OnHostStarted(string owner_email);

  // Called when the host shuts down.
  OnHostShutdown();
};