module electron.mojom;

import "mojo/public/mojom/base/string16.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom";
import "third_party/blink/public/mojom/messaging/cloneable_message.mojom";
import "third_party/blink/public/mojom/messaging/transferable_message.mojom";

interface ElectronRenderer {
  Message(
      bool internal,
      string channel,
      blink.mojom.CloneableMessage arguments,
      int32 sender_id);

  ReceivePostMessage(string channel, blink.mojom.TransferableMessage message);

  TakeHeapSnapshot(handle file) => (bool success);
};

interface ElectronAutofillAgent {
  AcceptDataListSuggestion(mojo_base.mojom.String16 value);
};

interface ElectronAutofillDriver {
  ShowAutofillPopup(gfx.mojom.RectF bounds, array<mojo_base.mojom.String16> values, array<mojo_base.mojom.String16> labels);
  HideAutofillPopup();
};

struct DraggableRegion {
  bool draggable;
  gfx.mojom.Rect bounds;
};

interface ElectronWebContentsUtility {
  // Informs underlying WebContents that first non-empty layout was performed
  // by compositor.
  OnFirstNonEmptyLayout();

  UpdateDraggableRegions(
    array<DraggableRegion> regions);

  SetTemporaryZoomLevel(double zoom_level);

  [Sync]
  DoGetZoomLevel() => (double result);
};

interface ElectronApiIPC {
  // Emits an event on |channel| from the ipcMain JavaScript object in the main
  // process.
  Message(
      bool internal,
      string channel,
      blink.mojom.CloneableMessage arguments);

  // Emits an event on |channel| from the ipcMain JavaScript object in the main
  // process, and returns the response.
  Invoke(
      bool internal,
      string channel,
      blink.mojom.CloneableMessage arguments) => (blink.mojom.CloneableMessage result);

  ReceivePostMessage(string channel, blink.mojom.TransferableMessage message);

  // Emits an event on |channel| from the ipcMain JavaScript object in the main
  // process, and waits synchronously for a response.
  [Sync]
  MessageSync(
    bool internal,
    string channel,
    blink.mojom.CloneableMessage arguments) => (blink.mojom.CloneableMessage result);

  // Emits an event from the |ipcRenderer| JavaScript object in the target
  // WebContents's main frame, specified by |web_contents_id|.
  MessageTo(
    int32 web_contents_id,
    string channel,
    blink.mojom.CloneableMessage arguments);

  MessageHost(
    string channel,
    blink.mojom.CloneableMessage arguments);
};
