Introduce a mojom::Frame::CommitSameDocumentNavigation

This CL introduces a CommitSameDocumentNavigation method in mojom::Frame, along
with a specific path to handle it in FrameLoader. Same document navigations are
handled very differently from different document navigations in the renderer,
and this simplifies the code path for their handling when the same-document
navigation is browser-initiated. This is a preparatory work for introducing
per-navigation Mojo interfaces. These interfaces will only be used for
different document navigations. Same-document navigations will still be handled
by the Frame directly, through the IPC this CL introduces.

This CL also fixes an issue with same-document navigations in out-of-process
iframes. Browser-initiated same-document navigations would see their
FrameLoadType recomputed at commit type, which sometimes caused them to be
wrongly classified as non same-document and dropped. By taking a same-document
path from the start, we ensure that FrameLoader doesn't recompute the
FrameLoadType for same-document navigations.

Bug: 788901,784904
Change-Id: Ie2fbef9afd9c99d22b7bb6d33170eaa5e32de622
Reviewed-on: https://chromium-review.googlesource.com/817296
Reviewed-by: Daniel Cheng <[email protected]>
Reviewed-by: Charlie Reis <[email protected]>
Reviewed-by: Nasko Oskov <[email protected]>
Commit-Queue: Camille Lamy <[email protected]>
Cr-Commit-Position: refs/heads/master@{#534675}
diff --git a/content/common/frame.mojom b/content/common/frame.mojom
index a1524d94..18831c1 100644
--- a/content/common/frame.mojom
+++ b/content/common/frame.mojom
@@ -15,6 +15,7 @@
 import "services/service_manager/public/mojom/interface_provider.mojom";
 import "third_party/WebKit/common/feature_policy/feature_policy.mojom";
 import "third_party/WebKit/public/platform/referrer.mojom";
+import "third_party/WebKit/public/web/commit_result.mojom";
 import "third_party/WebKit/public/web/window_features.mojom";
 import "ui/base/mojo/window_open_disposition.mojom";
 import "url/mojom/url.mojom";
@@ -103,6 +104,16 @@
       string? error_page_content,
       URLLoaderFactoryBundle? subresource_loader_factories);
 
+  // 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
+  // restart the navigation if it is no-longer same-document, which can happen
+  // if the renderer committed another navigation in the meantime.
+  CommitSameDocumentNavigation(
+      CommonNavigationParams common_params,
+      RequestNavigationParams request_params)
+      => (blink.mojom.CommitResult commit_result);
+
   // Asks the renderer to handle a renderer-debug URL.
   HandleRendererDebugURL(url.mojom.Url url);