Use a 3-value LoadingState enum to represent loading in content/browser/

Doc: https://docs.google.com/document/d/1m3icCIvVQ2_fEJxzSToAmOiJSyhm_THYHee5lw5Ezoo/edit?usp=sharing

Currently, we track whether loading is in progress as a boolean, but
when we start loading. This CL represents loading state internally
as a 3-state enum (NONE, LOADING_WITHOUT_UI, and LOADING_UI_REQUESTED). It also decouples the callbacks provided by the content/public API.
Right now, WebContentsDelegate::LoadingStateChanged() is always paired
with either a WebContentsObserver::DidStartLoading() or a
WebContentsObserver::DidStopLoading(), which means that the decision
to show loading UI can only be made at load start. Now,
LoadingStateChanged() can also be called separately when the internal loading state of the FrameTree changes between LOADING_WITHOUT_UI and
LOADING_UI_REQUESTED.

This fixes an uncommon case where loading UI could be omitted if an
iframe navigated, then the top frame started navigating before the
iframe finished. It will also enable better loading UI integration
for the web-exposed Navigation API in a follow-up CL.

Change-Id: Ic852f4c5400d3cf14422343d9bf35c249e31899a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4408275
Commit-Queue: Nate Chapin <[email protected]>
Reviewed-by: Rakina Zata Amni <[email protected]>
Reviewed-by: Francois Pierre Doray <[email protected]>
Code-Coverage: Findit <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1135263}
diff --git a/content/browser/renderer_host/frame_tree_node.h b/content/browser/renderer_host/frame_tree_node.h
index 3712869..7ebf652 100644
--- a/content/browser/renderer_host/frame_tree_node.h
+++ b/content/browser/renderer_host/frame_tree_node.h
@@ -308,6 +308,7 @@
 
   // Returns true if this node is in a loading state.
   bool IsLoading() const;
+  LoadingState GetLoadingState() const;
 
   // Returns true if this node has a cross-document navigation in progress.
   bool HasPendingCrossDocumentNavigation() const;
@@ -636,8 +637,7 @@
   void ResetAllNavigationsForFrameDetach();
 
   // RenderFrameHostOwner implementation:
-  void DidStartLoading(bool should_show_loading_ui,
-                       bool was_previously_loading) override;
+  void DidStartLoading(LoadingState previous_frame_tree_loading_state) override;
   void DidStopLoading() override;
   void RestartNavigationAsCrossDocument(
       std::unique_ptr<NavigationRequest> navigation_request) override;