Combine mojom::Frame and FrameNavigationControl, delete FrameFactory

The Frame mojom is removed, and FrameNavigationControl inherits its
members and is renamed to Frame.

The FrameFactory is deleted, and we pass a pending Frame receiver to
the renderer when we create the RenderFrame. Likewise, when a child
frame is created in the renderer, we pass a pending Frame remote to the
browser. Then the Frame mojom interface is present in the browser as
long as the RenderFrame is created (aka render_frame_created_ = true).
This means we remove the concept of pending RenderFrames in the
renderer as well.

This was discussed on chromium-dev@ and navigation-dev@ here:
https://groups.google.com/a/chromium.org/g/navigation-dev/c/ROWqf4OSAc8/m/ayWK5o5HAwAJ

RenderFrameCreated() is now solely responsible for setting up the mojom
bindings pulled off the content::mojom::Frame interface, and assumes
that the remote Frame interface has been given to the RenderFrameHost
before-hand. This should be done as at the time of sending or receiving
and IPC to create the renderer-side Frame, the pending remote is
generated or received in the browser process.

[email protected], [email protected]

Bug: 1158869, 859110
Change-Id: Ibbb91855ea5428d21b6bfe2328fa845eaa4794c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2593750
Commit-Queue: danakj <[email protected]>
Reviewed-by: Nasko Oskov <[email protected]>
Reviewed-by: Sergey Volk <[email protected]>
Reviewed-by: Daniel Cheng <[email protected]>
Reviewed-by: Dave Tapuska <[email protected]>
Reviewed-by: Jeremy Roman <[email protected]>
Reviewed-by: Avi Drissman <[email protected]>
Cr-Commit-Position: refs/heads/master@{#845282}
diff --git a/content/common/frame.mojom b/content/common/frame.mojom
index f16acc6..c7ad51a 100644
--- a/content/common/frame.mojom
+++ b/content/common/frame.mojom
@@ -94,44 +94,6 @@
   mojo_base.mojom.TimeDelta timeout;
 };
 
-// Implemented by the frame provider (e.g. renderer processes).
-interface Frame {
-  GetInterfaceProvider(
-      pending_receiver<service_manager.mojom.InterfaceProvider> interfaces);
-  GetCanonicalUrlForSharing() => (url.mojom.Url? canonical_url);
-
-  // Causes all new subresource requests to be blocked (not being started) until
-  // ResumeBlockedRequests is called.
-  BlockRequests();
-
-  // Resumes blocked requests.
-  // It is safe to call this without calling BlockRequests.
-  ResumeBlockedRequests();
-
-  // Samsung Galaxy Note-specific "smart clip" stylus text getter.
-  // Extracts the data at the given rect.
-  [EnableIf=is_android]
-  ExtractSmartClipData(gfx.mojom.Rect rect)
-      => (mojo_base.mojom.String16 text, mojo_base.mojom.String16 html,
-              gfx.mojom.Rect clip_rect);
-
-  // Requests a one-time snapshot of the accessibility tree without enabling
-  // accessibility if it wasn't already enabled.
-  SnapshotAccessibilityTree(SnapshotAccessibilityTreeParams params)
-      => (ax.mojom.AXTreeUpdate snapshot);
-
-  // Get HTML data by serializing the target frame and replacing all resource
-  // links with a path to the local copy passed in the message payload. In order
-  // to report progress to the the browser process, a pending remote is passed
-  // via |callback_remote|, so that direct communication with the SavePackage
-  // object that initiated the process can be established.
-  GetSerializedHtmlWithLocalLinks(
-      map<url.mojom.Url, mojo_base.mojom.FilePath> url_map,
-      map<mojo_base.mojom.UnguessableToken, mojo_base.mojom.FilePath>
-          frame_token_map, bool save_with_empty_url,
-          pending_remote<FrameHTMLSerializerHandler> handler_remote);
-};
-
 // An enumeration specifying the reason of the frame deletion.
 enum FrameDeleteIntention {
   // The frame being deleted isn't a (speculative) main frame.
@@ -146,11 +108,12 @@
   kSpeculativeMainFrameForNavigationCancelled,
 };
 
-// Implemented by the frame provider and currently must be associated with the
-// legacy IPC channel.
+// Implemented by the frame provider, and must be associated with other content
+// mojoms bound to frames, widgets, views, and currently also with the legacy
+// IPC channel.
 // KEEP THE COMMIT FUNCTIONS IN SYNC in content/common/navigation_client.mojom.
-// These will eventually be removed from FrameNavigationControl.
-interface FrameNavigationControl {
+// These will eventually be removed from Frame.
+interface Frame {
   // Tells the renderer that a same-document navigation should be committed.
   // The renderer will return a status value indicating whether the commit
   // could proceed as expected or not. In particular, it might be necessary to
@@ -261,6 +224,42 @@
   // browser process. Committed main frames are owned by the renderer's WebView
   // and can not be deleted directly.
   Delete(FrameDeleteIntention intention);
+
+  // Causes all new subresource requests to be blocked (not being started) until
+  // ResumeBlockedRequests is called.
+  BlockRequests();
+
+  // Resumes blocked requests.
+  // It is safe to call this without calling BlockRequests.
+  ResumeBlockedRequests();
+
+  GetInterfaceProvider(
+      pending_receiver<service_manager.mojom.InterfaceProvider> interfaces);
+
+  GetCanonicalUrlForSharing() => (url.mojom.Url? canonical_url);
+
+  // Samsung Galaxy Note-specific "smart clip" stylus text getter.
+  // Extracts the data at the given rect.
+  [EnableIf=is_android]
+  ExtractSmartClipData(gfx.mojom.Rect rect)
+      => (mojo_base.mojom.String16 text, mojo_base.mojom.String16 html,
+              gfx.mojom.Rect clip_rect);
+
+  // Requests a one-time snapshot of the accessibility tree without enabling
+  // accessibility if it wasn't already enabled.
+  SnapshotAccessibilityTree(SnapshotAccessibilityTreeParams params)
+      => (ax.mojom.AXTreeUpdate snapshot);
+
+  // Get HTML data by serializing the target frame and replacing all resource
+  // links with a path to the local copy passed in the message payload. In order
+  // to report progress to the the browser process, a pending remote is passed
+  // via |callback_remote|, so that direct communication with the SavePackage
+  // object that initiated the process can be established.
+  GetSerializedHtmlWithLocalLinks(
+      map<url.mojom.Url, mojo_base.mojom.FilePath> url_map,
+      map<mojo_base.mojom.UnguessableToken, mojo_base.mojom.FilePath>
+          frame_token_map, bool save_with_empty_url,
+          pending_remote<FrameHTMLSerializerHandler> handler_remote);
 };
 
 // Implemented by the frame (e.g. renderer processes).
@@ -283,12 +282,6 @@
             pending_associated_remote<content.mojom.WebUIHost> remote);
 };
 
-// Implemented by a service that provides implementations of the Frame
-// interface. (e.g. renderer processes).
-interface FrameFactory {
-  CreateFrame(int32 frame_routing_id, pending_receiver<Frame> frame);
-};
-
 struct CreateNewWindowParams {
   // True if ContentRendererClient allows popups.  This is the case only for
   // extensions.
@@ -351,6 +344,9 @@
   // The ID of the main frame hosted in the view.
   int32 main_frame_route_id;
 
+  // The pending mojo connection to the Frame implementation in the renderer.
+  pending_associated_receiver<content.mojom.Frame> frame;
+
   // The unique identifier of the RenderFrameHost
   mojo_base.mojom.UnguessableToken main_frame_frame_token;
 
@@ -488,6 +484,7 @@
   // Each of these messages will have a corresponding mojom::FrameHost::Detach
   // API sent when the frame is detached from the DOM.
   CreateChildFrame(int32 child_routing_id,
+                   pending_associated_remote<content.mojom.Frame> frame,
                    pending_receiver<blink.mojom.BrowserInterfaceBroker>
                      browser_interface_broker,
                    blink.mojom.PolicyContainerBindParams