PlzNavigate: fix timing issue in app window creation

This CL fixes a timing bug in which a newly created app window would try to
register a ScriptContext before being told to commit a navigation. This would
result in an incorrect frame url being passed to the ScriptContextSet, and a
wrong ContextType to be computed from it. With this CL, when browser-side
navigation is enabled, sending the response to the app.window.create is
deferred until the navigation in the newly created frame is ready to commit.

BUG=504347

Review URL: https://codereview.chromium.org/1340163002

Cr-Commit-Position: refs/heads/master@{#349290}
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 7d03dc1..78689f2 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -2796,6 +2796,12 @@
                     DidRedirectNavigation(navigation_handle));
 }
 
+void WebContentsImpl::ReadyToCommitNavigation(
+    NavigationHandle* navigation_handle) {
+  FOR_EACH_OBSERVER(WebContentsObserver, observers_,
+                    ReadyToCommitNavigation(navigation_handle));
+}
+
 void WebContentsImpl::DidCommitNavigation(NavigationHandle* navigation_handle) {
   FOR_EACH_OBSERVER(WebContentsObserver, observers_,
                     DidCommitNavigation(navigation_handle));