0
Files
src/content/browser/renderer_host/loading_state.h
Nate Chapin 470dbc6945 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 <japhet@chromium.org>
Reviewed-by: Rakina Zata Amni <rakina@chromium.org>
Reviewed-by: Francois Pierre Doray <fdoray@chromium.org>
Code-Coverage: Findit <findit-for-me@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#1135263}
2023-04-25 16:34:38 +00:00

29 lines
1.1 KiB
C++

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_RENDERER_HOST_LOADING_STATE_H_
#define CONTENT_BROWSER_RENDERER_HOST_LOADING_STATE_H_
namespace content {
// Used to specify the loading state of a frame, or the frame tree as a whole.
enum class LoadingState {
// Not currently loading.
NONE,
// Loading currently in progress, but no loading UI should be shown. Used
// for most same-document navigations.
LOADING_WITHOUT_UI,
// Loading currently in progress, and loading UI is recommended. This is
// used for cross-document navigations, as well as asynchronous same-document
// navigations from the web-exposed navigation API. Note that even if a
// FrameTreeNode's LoadingState is LOADING_UI_REQUESTED, the FrameTree may
// decide the tree-wide policy is LOADING_WITHOUT_UI if the root frame is not
// loading. Also, the embedder is under no obligation to showing any UI.
LOADING_UI_REQUESTED,
};
} // namespace content
#endif // CONTENT_BROWSER_RENDERER_HOST_LOADING_STATE_H_