1// Copyright 2018 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5module extensions.mojom;
6
7import "content/public/common/transferrable_url_loader.mojom";
8import "extensions/common/api/mime_handler.mojom";
9import "ui/gfx/geometry/mojom/geometry.mojom";
10import "url/mojom/url.mojom";
11
12interface GuestView {
13  // Tells the browser to create a mime handler guest view for a plugin.
14  // This method is only called when the network service is enabled, and only
15  // for plugins added using the embedded/object tag.
16  CreateEmbeddedMimeHandlerViewGuest(
17      int32 render_frame_id,
18      int32 tab_id,
19      url.mojom.Url original_url,
20      int32 element_instance_id,
21      gfx.mojom.Size element_size,
22      content.mojom.TransferrableURLLoader transferrable_url_loader);
23
24  // Tells the browser to create a mime handler guest view for a plugin.
25  // This method is called for full-frame plugins or for all plugins when the
26  // network service is disabled.
27  CreateMimeHandlerViewGuest(
28      int32 render_frame_id,
29      string view_id,
30      int32 element_instance_id,
31      gfx.mojom.Size element_size,
32      pending_remote<extensions.mime_handler.BeforeUnloadControl>?
33          before_unload_control);
34
35  // Notifies the browser whether or not now is a good time to start loading the
36  // MimeHandlerView. |routing_id| identifies the embedder frame. If |success|
37  // is false, then MimeHandlerViewEmbedder should destroy itself. When
38  // |success| is true the MimeHandlerViewEmbedder should proceed with attaching
39  // the GuestView.
40  ReadyToCreateMimeHandlerView(int32 routing_id, bool success);
41};
42
43// An interface implemented by the renderer which is used for creating a
44// MimeHandlerViewFrameContainer. This interface is exposed on RenderFrame and
45// and is used by the browser to ask the renderer to start the MimeHandlerView
46// creation process (by creating a MimeHandlerViewFrameContainer).
47interface MimeHandlerViewContainerManager {
48  // Sets the expected |internal_id| of the plugin element that will be used
49  // to attach the MimeHandlerViewGuest.
50  SetInternalId(string token_id);
51
52  // Requests the MimeHandlerViewContainerManager to load an empty page as an
53  // HTML string. This is used in cases where MimeHandlerViewEmbedder decides
54  // not to continue with loading the embedding page for the resource at
55  // |resource_url|, e.g., due to sandbox violation.
56  LoadEmptyPage(url.mojom.Url resource_url);
57
58  // Called by the browser to request a BeforeUnloadControl interface pointer
59  // which will later be connected to the request from the extension page to
60  // provide the beforeunload API (to setup beforeunload in the embedder
61  // document). This is only relevant for the non-embedded MimeHandlerView (
62  // e.g., full page navigations to a relevant MIME type).
63  CreateBeforeUnloadControl()
64      => (pending_remote<extensions.mime_handler.BeforeUnloadControl>
65              before_unload_control);
66
67  // Asks the renderer to destroy the MimeHandlerViewFrameContainer associated
68  // with MimeHandlerViewGuest with |element_instance_id|.
69  DestroyFrameContainer(int32 element_instance_id);
70
71  // This is a signal to renderer that the the contents of MimeHandlerViewGuest
72  // finished loading and therefore the renderer can forward the postMessages
73  // to the GuestView (if any). |element_instance_id| is the instance ID for
74  // MimeHandlerViewGuest and the |resource_url| is the original request's URL
75  // that ended up creating the MimeHandlerViewGuest.
76  DidLoad(
77      int32 mime_handler_view_guest_element_instance_id,
78      url.mojom.Url resource_url);
79};
80