chromium/ui/webui/examples/browser/ui/web/browser.mojom

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module webui_examples.mojom;

import "mojo/public/mojom/base/values.mojom";
import "url/mojom/url.mojom";

// Used by the WebUI page to bootstrap communication to the browser process.
interface PageHandlerFactory {
  // The WebUI calls this method when the page is first initialized.
  CreatePageHandler(pending_receiver<PageHandler> handler);
};

// Browser-side handler for requests from WebUI page.
interface PageHandler {
  // Creates the GuestView from `create_params` and returns the created guest's
  // ID on success.
  CreateGuestView(mojo_base.mojom.DictionaryValue create_params)
      => (int32 guest_instance_id);

  // Navigates the WebView with `guest_instance_id` to `src`.
  Navigate(int32 guest_instance_id, url.mojom.Url src);

  // Navigates the WebView with `guest_instance_id` to back in the nav stack.
  GoBack(int32 guest_instance_id);

  // Navigates the WebView with `guest_instance_id` to forward in the nav stack.
  GoForward(int32 guest_instance_id);
};