[chromecast] Ensures bindings are injected for main frame

Bindings scripts injection change:

1. Removed OnPageLoading() from |ReadyToCommitNavigation|.
2. Now |CastWebContentsImpl| will inject the bindings scripts while
   ReadyToCommitNavigation is invoked. Previously, BindingsManagerCast
   listens on PageState::LOADING and that could fail in corner case.
   (e.g. Multiple same LOADING events are ignored due to CastWebContents's
   lifecycle management logic, thus BindingsManagerCast does not request
   to inject required bindings scripts.)

PageState::LOADED logic change:
To make PageState::LOADED actually means the completion of navigations and
main frame's document resource is fully loaded. This CL does:

1. We only send out PageState::LOADED once and only once for a
   successful page loading.
2. Added an |active_navigation_| member to |CastWebContentsImpl| to
   indicate the main frame has pending navigation.
3. On |DidFinishLoad|, if there is the pending navigation, we will wait
   that being completed first (i.e. waiting another/more DidFinishLoad).

Merge-With: eureka-internal/552843

Bug: Internal b/175623201, b/152813213
Test: CastWebContentsBrowserTest
Change-Id: I304db9b0897ae2fb55aa96f80162571b3e3ed863
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2759810
Commit-Queue: Jiawei Li <[email protected]>
Reviewed-by: Sean Topping <[email protected]>
Cr-Commit-Position: refs/heads/master@{#867356}
diff --git a/chromecast/browser/cast_web_contents.h b/chromecast/browser/cast_web_contents.h
index 0cbb608..0e1d43c 100644
--- a/chromecast/browser/cast_web_contents.h
+++ b/chromecast/browser/cast_web_contents.h
@@ -61,10 +61,10 @@
 // sub-frame errors.
 //
 // We consider the CastWebContents to be in a LOADED state when the content of
-// the main frame is fully loaded and running (all resources fetched, JS is
-// running). Iframes might still be loading in this case, but in general we
-// consider the page to be in a presentable state at this stage, so it is
-// appropriate to display the WebContents to the user.
+// the main frame is fully loaded and running (all resources fetched,
+// redirection finished, JS is running). Iframes might still be loading in this
+// case, but in general we consider the page to be in a presentable state at
+// this stage, so it is appropriate to display the WebContents to the user.
 //
 // During or after the page is loaded, there are multiple error conditions that
 // can occur. The following events will cause the page to enter an ERROR state:
@@ -337,9 +337,6 @@
   virtual on_load_script_injector::OnLoadScriptInjectorHost<std::string>*
   script_injector() = 0;
 
-  // Injects on-load scripts into the WebContents' main frame.
-  virtual void InjectScriptsIntoMainFrame() = 0;
-
   // Posts a message to the frame's onMessage handler.
   //
   // `target_origin` restricts message delivery to the specified origin.