Back-port: "[Android WebView] Synthesize a fake page loading event on page source modification (Re-land)"
Back-port of https://codereview.chromium.org/970883002/ for m40.
[Android WebView] Synthesize a fake page loading event on page source modification (Re-land)
When a script modifies page source of a non-committed page, we need to
notify clients, so they can update the URL bar to avoid confusion.
New logic since the last attempt (https://codereview.chromium.org/924833003/):
distinguish between a "vanilla" WebView state (basically, a newly created
WebView, where no loading attempts have been made) and an "attempted to
navigate" state. In the "vanilla" state, don't fire synthesized page loading
events to avoid confusing clients. This is safe, as WebView is guaranteed to be
on a blank page.
Implementation note: we detect navigation attempts using
didStartProvisionalLoadForFrame WebContentsObserver event on the Java side. As
for popups AwWebContentsObserver gets re-attached from the original popup
WebView to the one provided by the client, notifications issued inbetween can be
missed on the Java side. To work around this, we assume that WebViews opened as
popups can never be in "vanilla" state (as they are anyway opened as a result of
55 files changed