#include "content/browser/renderer_host/frame_tree.h"
#include <stddef.h>
#include <queue>
#include <set>
#include <utility>
#include "base/containers/contains.h"
#include "base/debug/dump_without_crashing.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/lazy_instance.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/safe_ref.h"
#include "base/not_fatal_until.h"
#include "base/ranges/algorithm.h"
#include "base/trace_event/optional_trace_event.h"
#include "base/trace_event/typed_macros.h"
#include "base/unguessable_token.h"
#include "content/browser/renderer_host/batched_proxy_ipc_sender.h"
#include "content/browser/renderer_host/navigation_controller_impl.h"
#include "content/browser/renderer_host/navigation_entry_impl.h"
#include "content/browser/renderer_host/navigation_request.h"
#include "content/browser/renderer_host/navigator.h"
#include "content/browser/renderer_host/navigator_delegate.h"
#include "content/browser/renderer_host/page_impl.h"
#include "content/browser/renderer_host/render_frame_host_delegate.h"
#include "content/browser/renderer_host/render_frame_host_factory.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/browser/renderer_host/render_frame_proxy_host.h"
#include "content/browser/renderer_host/render_view_host_delegate.h"
#include "content/browser/renderer_host/render_view_host_factory.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/common/content_navigation_policy.h"
#include "content/common/content_switches_internal.h"
#include "content/common/features.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/frame/frame_owner_element_type.h"
#include "third_party/blink/public/common/frame/frame_policy.h"
#include "third_party/blink/public/common/loader/loader_constants.h"
#include "third_party/blink/public/mojom/frame/frame_owner_properties.mojom.h"
namespace content {
namespace {
ChromeTrackEvent;
std::set<SiteInstanceGroup*> CollectSiteInstanceGroups(FrameTree* tree) { … }
FrameTreeNode* GetInnerTreeMainFrameNode(FrameTreeNode* node) { … }
}
FrameTree::NodeIterator::NodeIterator(const NodeIterator& other) = default;
FrameTree::NodeIterator::~NodeIterator() = default;
FrameTree::NodeIterator& FrameTree::NodeIterator::operator++() { … }
FrameTree::NodeIterator& FrameTree::NodeIterator::AdvanceSkippingChildren() { … }
bool FrameTree::NodeIterator::operator==(const NodeIterator& rhs) const { … }
void FrameTree::NodeIterator::AdvanceNode() { … }
FrameTree::NodeIterator::NodeIterator(
const std::vector<raw_ptr<FrameTreeNode, VectorExperimental>>&
starting_nodes,
const FrameTreeNode* root_of_subtree_to_skip,
bool should_descend_into_inner_trees,
bool include_delegate_nodes_for_inner_frame_trees)
: … { … }
FrameTree::NodeIterator FrameTree::NodeRange::begin() { … }
FrameTree::NodeIterator FrameTree::NodeRange::end() { … }
FrameTree::NodeRange::NodeRange(
const std::vector<raw_ptr<FrameTreeNode, VectorExperimental>>&
starting_nodes,
const FrameTreeNode* root_of_subtree_to_skip,
bool should_descend_into_inner_trees,
bool include_delegate_nodes_for_inner_frame_trees)
: … { … }
FrameTree::NodeRange::NodeRange(const NodeRange&) = default;
FrameTree::NodeRange::~NodeRange() = default;
FrameTree::FrameTree(
BrowserContext* browser_context,
Delegate* delegate,
NavigationControllerDelegate* navigation_controller_delegate,
NavigatorDelegate* navigator_delegate,
RenderFrameHostDelegate* render_frame_delegate,
RenderViewHostDelegate* render_view_delegate,
RenderWidgetHostDelegate* render_widget_delegate,
RenderFrameHostManager::Delegate* manager_delegate,
PageDelegate* page_delegate,
Type type)
: … { … }
FrameTree::~FrameTree() { … }
void FrameTree::ForEachRenderViewHost(
base::FunctionRef<void(RenderViewHostImpl*)> on_host) { … }
void FrameTree::MakeSpeculativeRVHCurrent() { … }
FrameTreeNode* FrameTree::FindByID(int frame_tree_node_id) { … }
FrameTreeNode* FrameTree::FindByRoutingID(int process_id, int routing_id) { … }
FrameTreeNode* FrameTree::FindByName(const std::string& name) { … }
FrameTree::NodeRange FrameTree::Nodes() { … }
FrameTree::NodeRange FrameTree::SubtreeNodes(FrameTreeNode* subtree_root) { … }
FrameTree::NodeRange FrameTree::NodesIncludingInnerTreeNodes() { … }
std::vector<FrameTreeNode*> FrameTree::CollectNodesForIsLoading() { … }
FrameTree::NodeRange FrameTree::SubtreeAndInnerTreeNodes(
RenderFrameHostImpl* parent,
bool include_delegate_nodes_for_inner_frame_trees) { … }
FrameTree::NodeRange FrameTree::NodesExceptSubtree(FrameTreeNode* node) { … }
FrameTree* FrameTree::LoadingTree() { … }
FrameTreeNode* FrameTree::AddFrame(
RenderFrameHostImpl* parent,
int process_id,
int new_routing_id,
mojo::PendingAssociatedRemote<mojom::Frame> frame_remote,
mojo::PendingReceiver<blink::mojom::BrowserInterfaceBroker>
browser_interface_broker_receiver,
blink::mojom::PolicyContainerBindParamsPtr policy_container_bind_params,
mojo::PendingAssociatedReceiver<blink::mojom::AssociatedInterfaceProvider>
associated_interface_provider_receiver,
blink::mojom::TreeScopeType scope,
const std::string& frame_name,
const std::string& frame_unique_name,
bool is_created_by_script,
const blink::LocalFrameToken& frame_token,
const base::UnguessableToken& devtools_frame_token,
const blink::DocumentToken& document_token,
const blink::FramePolicy& frame_policy,
const blink::mojom::FrameOwnerProperties& frame_owner_properties,
bool was_discarded,
blink::FrameOwnerElementType owner_type,
bool is_dummy_frame_for_inner_tree) { … }
void FrameTree::RemoveFrame(FrameTreeNode* child) { … }
void FrameTree::CreateProxiesForSiteInstanceGroup(
FrameTreeNode* source,
SiteInstanceGroup* site_instance_group,
const scoped_refptr<BrowsingContextState>&
source_new_browsing_context_state) { … }
RenderFrameHostImpl* FrameTree::GetMainFrame() const { … }
FrameTreeNode* FrameTree::GetFocusedFrame() { … }
void FrameTree::SetFocusedFrame(FrameTreeNode* node,
SiteInstanceGroup* source) { … }
scoped_refptr<RenderViewHostImpl> FrameTree::CreateRenderViewHost(
SiteInstanceGroup* site_instance_group,
int32_t main_frame_routing_id,
bool renderer_initiated_creation,
scoped_refptr<BrowsingContextState> main_browsing_context_state,
CreateRenderViewHostCase create_case,
std::optional<viz::FrameSinkId> frame_sink_id) { … }
scoped_refptr<RenderViewHostImpl> FrameTree::GetRenderViewHost(
SiteInstanceGroup* group) { … }
FrameTree::RenderViewHostMapId FrameTree::GetRenderViewHostMapId(
SiteInstanceGroup* site_instance_group) const { … }
void FrameTree::RegisterRenderViewHost(RenderViewHostMapId id,
RenderViewHostImpl* rvh) { … }
void FrameTree::UnregisterRenderViewHost(RenderViewHostMapId id,
RenderViewHostImpl* rvh) { … }
void FrameTree::FrameUnloading(FrameTreeNode* frame) { … }
void FrameTree::FrameRemoved(FrameTreeNode* frame) { … }
double FrameTree::GetLoadProgress() { … }
bool FrameTree::IsLoadingIncludingInnerFrameTrees() const { … }
LoadingState FrameTree::GetLoadingState() const { … }
void FrameTree::ReplicatePageFocus(bool is_focused) { … }
void FrameTree::SetPageFocus(SiteInstanceGroup* group, bool is_focused) { … }
void FrameTree::RegisterExistingOriginAsHavingDefaultIsolation(
const url::Origin& previously_visited_origin,
NavigationRequest* navigation_request_to_exclude) { … }
void FrameTree::Init(SiteInstanceImpl* main_frame_site_instance,
bool renderer_initiated_creation,
const std::string& main_frame_name,
RenderFrameHostImpl* opener_for_origin,
const blink::FramePolicy& frame_policy,
const base::UnguessableToken& devtools_frame_token) { … }
void FrameTree::DidAccessInitialMainDocument() { … }
void FrameTree::NodeLoadingStateChanged(
FrameTreeNode& node,
LoadingState previous_frame_tree_loading_state) { … }
void FrameTree::DidCancelLoading() { … }
void FrameTree::StopLoading() { … }
void FrameTree::Shutdown() { … }
base::SafeRef<FrameTree> FrameTree::GetSafeRef() { … }
void FrameTree::FocusOuterFrameTrees() { … }
}