chromium/extensions/common/mojom/guest_view.mojom

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

module extensions.mojom;

import "extensions/common/api/mime_handler.mojom";
import "third_party/blink/public/mojom/loader/transferrable_url_loader.mojom";
import "url/mojom/url.mojom";

interface GuestView {
  // Notifies the browser whether or not now is a good time to start loading the
  // MimeHandlerView. If |success| is false, then MimeHandlerViewEmbedder should
  // destroy itself. When |success| is true the MimeHandlerViewEmbedder should
  // proceed with attaching the GuestView.
  ReadyToCreateMimeHandlerView(bool success);

  // Queries whether the associated frame is allowed to inject
  // the script with the provided `script_id`.
  [Sync]
  CanExecuteContentScript(string script_id) => (bool allowed);
};

// An interface implemented by the renderer which is used for creating a
// MimeHandlerViewFrameContainer. This interface is exposed on RenderFrame and
// and is used by the browser to ask the renderer to start the MimeHandlerView
// creation process (by creating a MimeHandlerViewFrameContainer).
interface MimeHandlerViewContainerManager {
  // Sets the expected |internal_id| of the plugin element that will be used
  // to attach the MimeHandlerViewGuest.
  SetInternalId(string token_id);

  // Called by the browser to request a BeforeUnloadControl interface pointer
  // which will later be connected to the request from the extension page to
  // provide the beforeunload API (to setup beforeunload in the embedder
  // document). This is only relevant for the non-embedded MimeHandlerView (
  // e.g., full page navigations to a relevant MIME type).
  CreateBeforeUnloadControl()
      => (pending_remote<extensions.mime_handler.BeforeUnloadControl>
              before_unload_control);

  // Asks the renderer to destroy the MimeHandlerViewFrameContainer associated
  // with MimeHandlerViewGuest with |element_instance_id|.
  DestroyFrameContainer(int32 element_instance_id);

  // This is a signal to renderer that the the contents of MimeHandlerViewGuest
  // finished loading and therefore the renderer can forward the postMessages
  // to the GuestView (if any). |element_instance_id| is the instance ID for
  // MimeHandlerViewGuest and the |resource_url| is the original request's URL
  // that ended up creating the MimeHandlerViewGuest.
  DidLoad(
      int32 mime_handler_view_guest_element_instance_id,
      url.mojom.Url resource_url);
};