chromium/content/browser/renderer_host/frame_tree_node.cc

// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/browser/renderer_host/frame_tree_node.h"

#include <math.h>
#include <queue>
#include <unordered_map>
#include <utility>

#include "base/debug/crash_logging.h"
#include "base/feature_list.h"
#include "base/lazy_instance.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/observer_list.h"
#include "base/strings/strcat.h"
#include "base/strings/string_util.h"
#include "base/timer/elapsed_timer.h"
#include "content/browser/devtools/devtools_instrumentation.h"
#include "content/browser/fenced_frame/fenced_frame.h"
#include "content/browser/network/cross_origin_embedder_policy_reporter.h"
#include "content/browser/renderer_host/frame_tree.h"
#include "content/browser/renderer_host/navigation_controller_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/render_frame_host_impl.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/browser/webauth/authenticator_environment.h"
#include "content/common/navigation_params_utils.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/site_isolation_policy.h"
#include "content/public/common/content_features.h"
#include "services/network/public/cpp/web_sandbox_flags.h"
#include "services/network/public/mojom/web_sandbox_flags.mojom-shared.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/frame/fenced_frame_sandbox_flags.h"
#include "third_party/blink/public/common/loader/loader_constants.h"
#include "third_party/blink/public/mojom/frame/user_activation_update_types.mojom.h"
#include "third_party/blink/public/mojom/security_context/insecure_request_policy.mojom.h"

namespace content {

namespace {

// This is a global map between frame_tree_node_ids and pointers to
// FrameTreeNodes.
FrameTreeNodeIdMap;

base::LazyInstance<FrameTreeNodeIdMap>::DestructorAtExit
    g_frame_tree_node_id_map =;

FencedFrame* FindFencedFrame(const FrameTreeNode* frame_tree_node) {}

}  // namespace

// This observer watches the opener of its owner FrameTreeNode and clears the
// owner's opener if the opener is destroyed or swaps BrowsingInstance.
class FrameTreeNode::OpenerDestroyedObserver : public FrameTreeNode::Observer {};

const int FrameTreeNode::kFrameTreeNodeInvalidId =;

static_assert;

int FrameTreeNode::next_frame_tree_node_id_ =;

// static
FrameTreeNode* FrameTreeNode::GloballyFindByID(int frame_tree_node_id) {}

// static
FrameTreeNode* FrameTreeNode::From(RenderFrameHost* rfh) {}

FrameTreeNode::FencedFrameStatus ComputeFencedFrameStatus(
    const FrameTree& frame_tree,
    RenderFrameHostImpl* parent,
    const blink::FramePolicy& frame_policy) {}

FrameTreeNode::FrameTreeNode(
    FrameTree& frame_tree,
    RenderFrameHostImpl* parent,
    blink::mojom::TreeScopeType tree_scope_type,
    bool is_created_by_script,
    const blink::mojom::FrameOwnerProperties& frame_owner_properties,
    blink::FrameOwnerElementType owner_type,
    const blink::FramePolicy& frame_policy)
    :{}

void FrameTreeNode::DestroyInnerFrameTreeIfExists() {}

FrameTreeNode::~FrameTreeNode() {}

void FrameTreeNode::AddObserver(Observer* observer) {}

void FrameTreeNode::RemoveObserver(Observer* observer) {}

bool FrameTreeNode::IsMainFrame() const {}

Navigator& FrameTreeNode::navigator() {}

bool FrameTreeNode::IsOutermostMainFrame() const {}

RenderFrameHostImpl* FrameTreeNode::GetParentOrOuterDocument() const {}

RenderFrameHostImpl* FrameTreeNode::GetParentOrOuterDocumentOrEmbedder() {}

RenderFrameHostImpl* FrameTreeNode::GetParentOrOuterDocumentHelper(
    bool escape_guest_view,
    bool include_prospective) const {}

FrameType FrameTreeNode::GetFrameType() const {}

void FrameTreeNode::SetOpener(FrameTreeNode* opener) {}

void FrameTreeNode::SetOpenerDevtoolsFrameToken(
    base::UnguessableToken opener_devtools_frame_token) {}

void FrameTreeNode::SetOriginalOpener(FrameTreeNode* opener) {}

void FrameTreeNode::SetCollapsed(bool collapsed) {}

void FrameTreeNode::SetFrameTree(FrameTree& frame_tree) {}

void FrameTreeNode::SetPendingFramePolicy(blink::FramePolicy frame_policy) {}

void FrameTreeNode::SetAttributes(
    blink::mojom::IframeAttributesPtr attributes) {}

bool FrameTreeNode::IsLoading() const {}

LoadingState FrameTreeNode::GetLoadingState() const {}

bool FrameTreeNode::HasPendingCrossDocumentNavigation() const {}

void FrameTreeNode::TransferNavigationRequestOwnership(
    RenderFrameHostImpl* render_frame_host) {}

void FrameTreeNode::TakeNavigationRequest(
    std::unique_ptr<NavigationRequest> navigation_request) {}

void FrameTreeNode::ResetNavigationRequest(NavigationDiscardReason reason) {}

void FrameTreeNode::ResetNavigationRequestButKeepState(
    NavigationDiscardReason reason) {}

void FrameTreeNode::DidStartLoading(
    LoadingState previous_frame_tree_loading_state) {}

void FrameTreeNode::DidStopLoading() {}

void FrameTreeNode::DidChangeLoadProgress(double load_progress) {}

bool FrameTreeNode::StopLoading() {}

void FrameTreeNode::DidFocus() {}

void FrameTreeNode::BeforeUnloadCanceled() {}

bool FrameTreeNode::NotifyUserActivationStickyOnly() {}

bool FrameTreeNode::NotifyUserActivation(
    blink::mojom::UserActivationNotificationType notification_type,
    bool sticky_only) {}

bool FrameTreeNode::ConsumeTransientUserActivation() {}

bool FrameTreeNode::ClearUserActivation() {}

bool FrameTreeNode::VerifyUserActivation() {}

bool FrameTreeNode::UpdateUserActivationState(
    blink::mojom::UserActivationUpdateType update_type,
    blink::mojom::UserActivationNotificationType notification_type) {}

void FrameTreeNode::DidConsumeHistoryUserActivation() {}

void FrameTreeNode::DidOpenDocumentInputStream() {}

void FrameTreeNode::PruneChildFrameNavigationEntries(
    NavigationEntryImpl* entry) {}

void FrameTreeNode::SetInitialPopupURL(const GURL& initial_popup_url) {}

void FrameTreeNode::SetPopupCreatorOrigin(
    const url::Origin& popup_creator_origin) {}

void FrameTreeNode::WriteIntoTrace(
    perfetto::TracedProto<TraceProto> proto) const {}

bool FrameTreeNode::HasNavigation() {}

bool FrameTreeNode::HasPendingCommitNavigation() {}

bool FrameTreeNode::IsFencedFrameRoot() const {}

bool FrameTreeNode::IsInFencedFrameTree() const {}

FrameTreeNode* FrameTreeNode::GetClosestAncestorWithFencedFrameProperties() {}

std::optional<FencedFrameProperties>& FrameTreeNode::GetFencedFrameProperties(
    FencedFramePropertiesNodeSource node_source) {}

size_t FrameTreeNode::GetFencedFrameDepth(
    size_t& shared_storage_fenced_frame_root_count) {}

std::optional<base::UnguessableToken> FrameTreeNode::GetFencedFrameNonce() {}

void FrameTreeNode::SetFencedFramePropertiesIfNeeded() {}

blink::FencedFrame::DeprecatedFencedFrameMode
FrameTreeNode::GetDeprecatedFencedFrameMode() {}

bool FrameTreeNode::IsErrorPageIsolationEnabled() const {}

void FrameTreeNode::SetSrcdocValue(const std::string& srcdoc_value) {}

std::vector<const SharedStorageBudgetMetadata*>
FrameTreeNode::FindSharedStorageBudgetMetadata() {}

std::optional<std::u16string>
FrameTreeNode::GetEmbedderSharedStorageContextIfAllowed() {}

const scoped_refptr<BrowsingContextState>&
FrameTreeNode::GetBrowsingContextStateForSubframe() const {}

void FrameTreeNode::ClearOpenerReferences() {}

bool FrameTreeNode::AncestorOrSelfHasCSPEE() const {}

void FrameTreeNode::ResetAllNavigationsForFrameDetach() {}

void FrameTreeNode::RestartNavigationAsCrossDocument(
    std::unique_ptr<NavigationRequest> navigation_request) {}

bool FrameTreeNode::Reload() {}

Navigator& FrameTreeNode::GetCurrentNavigator() {}

RenderFrameHostManager& FrameTreeNode::GetRenderFrameHostManager() {}

FrameTreeNode* FrameTreeNode::GetOpener() const {}

void FrameTreeNode::SetFocusedFrame(SiteInstanceGroup* source) {}

void FrameTreeNode::DidChangeReferrerPolicy(
    network::mojom::ReferrerPolicy referrer_policy) {}

std::unique_ptr<NavigationRequest>
FrameTreeNode::CreateNavigationRequestForSynchronousRendererCommit(
    RenderFrameHostImpl* render_frame_host,
    bool is_same_document,
    const GURL& url,
    const url::Origin& origin,
    const std::optional<GURL>& initiator_base_url,
    const net::IsolationInfo& isolation_info_for_subresources,
    blink::mojom::ReferrerPtr referrer,
    const ui::PageTransition& transition,
    bool should_replace_current_entry,
    const std::string& method,
    bool has_transient_activation,
    bool is_overriding_user_agent,
    const std::vector<GURL>& redirects,
    const GURL& original_url,
    std::unique_ptr<CrossOriginEmbedderPolicyReporter> coep_reporter,
    int http_response_code) {}

void FrameTreeNode::CancelNavigation(NavigationDiscardReason reason) {}

bool FrameTreeNode::Credentialless() const {}

#if !BUILDFLAG(IS_ANDROID)
void FrameTreeNode::GetVirtualAuthenticatorManager(
    mojo::PendingReceiver<blink::test::mojom::VirtualAuthenticatorManager>
        receiver) {}
#endif  // !BUILDFLAG(IS_ANDROID)

void FrameTreeNode::RestartBackForwardCachedNavigationAsync(int nav_entry_id) {}

void FrameTreeNode::RestartBackForwardCachedNavigationImpl(int nav_entry_id) {}

void FrameTreeNode::CancelRestartingBackForwardCacheNavigation() {}

}  // namespace content