chromium/content/browser/preloading/prerender/prerender_host.cc

// Copyright 2020 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/preloading/prerender/prerender_host.h"

#include <memory>
#include <optional>

#include "base/debug/alias.h"
#include "base/feature_list.h"
#include "base/notreached.h"
#include "base/observer_list.h"
#include "base/run_loop.h"
#include "base/task/thread_pool.h"
#include "base/time/time.h"
#include "base/trace_event/typed_macros.h"
#include "content/browser/client_hints/client_hints.h"
#include "content/browser/devtools/devtools_instrumentation.h"
#include "content/browser/preloading/prefetch/no_vary_search_helper.h"
#include "content/browser/preloading/preloading_attempt_impl.h"
#include "content/browser/preloading/preloading_trigger_type_impl.h"
#include "content/browser/preloading/prerender/devtools_prerender_attempt.h"
#include "content/browser/preloading/prerender/prerender_features.h"
#include "content/browser/preloading/prerender/prerender_final_status.h"
#include "content/browser/preloading/prerender/prerender_host_registry.h"
#include "content/browser/preloading/prerender/prerender_metrics.h"
#include "content/browser/renderer_host/frame_tree.h"
#include "content/browser/renderer_host/frame_tree_node.h"
#include "content/browser/renderer_host/navigation_controller_impl.h"
#include "content/browser/renderer_host/navigation_entry_restore_context_impl.h"
#include "content/browser/renderer_host/navigation_request.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/preloading_trigger_type.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/common/referrer.h"
#include "net/base/load_flags.h"
#include "net/http/http_request_headers.h"
#include "third_party/blink/public/common/client_hints/enabled_client_hints.h"
#include "third_party/blink/public/common/features.h"
#include "url/origin.h"

namespace content {

namespace {

base::OnceCallback<void(int)>& GetHostCreationCallbackForTesting() {}

}  // namespace

// static
PrerenderHost* PrerenderHost::GetFromFrameTreeNodeIfPrerendering(
    FrameTreeNode& frame_tree_node) {}

// static
PrerenderHost& PrerenderHost::GetFromFrameTreeNode(
    FrameTreeNode& frame_tree_node) {}

// static
bool PrerenderHost::AreHttpRequestHeadersCompatible(
    const std::string& potential_activation_headers_str,
    const std::string& prerender_headers_str,
    PreloadingTriggerType trigger_type,
    const std::string& histogram_suffix,
    PrerenderCancellationReason& reason) {}

// static
void PrerenderHost::SetHostCreationCallbackForTesting(
    base::OnceCallback<void(int host_id)> callback) {}

PrerenderHost::PrerenderHost(
    const PrerenderAttributes& attributes,
    WebContentsImpl& web_contents,
    base::WeakPtr<PreloadingAttempt> attempt,
    std::unique_ptr<DevToolsPrerenderAttempt> devtools_attempt)
    :{}

// static
bool PrerenderHost::IsActivationHeaderMatch(
    const net::HttpRequestHeaders& potential_activation_headers,
    const net::HttpRequestHeaders& prerender_headers,
    PrerenderCancellationReason& reason) {}

PrerenderHost::~PrerenderHost() {}

void PrerenderHost::DidStopLoading() {}

bool PrerenderHost::IsHidden() {}

FrameTree* PrerenderHost::LoadingTree() {}

void PrerenderHost::SetFocusedFrame(FrameTreeNode* node,
                                    SiteInstanceGroup* source) {}

FrameTree* PrerenderHost::GetOwnedPictureInPictureFrameTree() {}

FrameTree* PrerenderHost::GetPictureInPictureOpenerFrameTree() {}

int PrerenderHost::GetOuterDelegateFrameTreeNodeId() {}

RenderFrameHostImpl* PrerenderHost::GetProspectiveOuterDocument() {}

void PrerenderHost::ActivateAndShowRepostFormWarningDialog() {}

bool PrerenderHost::ShouldPreserveAbortedURLs() {}

// TODO(crbug.com/40150744): Inspect diffs from the current
// no-state-prefetch implementation. See PrerenderContents::StartPrerendering()
// for example.
bool PrerenderHost::StartPrerendering() {}

void PrerenderHost::DidStartNavigation(NavigationHandle* navigation_handle) {}

void PrerenderHost::ReadyToCommitNavigation(
    NavigationHandle* navigation_handle) {}

void PrerenderHost::DidFinishNavigation(NavigationHandle* navigation_handle) {}

std::unique_ptr<StoredPage> PrerenderHost::Activate(
    NavigationRequest& navigation_request) {}

// Ensure that the frame policies are compatible between primary main frame and
// prerendering main frame:
// a) primary main frame's pending_frame_policy would normally apply to the new
// document during its creation. However, for prerendering we can't apply it as
// the document is already created.
// b) prerender main frame's pending_frame_policy can't be transferred to the
// primary main frame, we should not activate if it's non-zero.
// c) Existing  document can't change the frame_policy it is affected by, so we
// can't transfer RenderFrameHosts between FrameTreeNodes with different frame
// policies.
//
// Usually frame policy for the main frame is empty as in the most common case a
// parent document sets a policy on the child iframe.
bool PrerenderHost::IsFramePolicyCompatibleWithPrimaryFrameTree() {}

bool PrerenderHost::AreInitialPrerenderNavigationParamsCompatibleWithNavigation(
    NavigationRequest& navigation_request,
    PrerenderCancellationReason& reason) {}

PrerenderHost::ActivationNavigationParamsMatch
PrerenderHost::AreBeginNavigationParamsCompatibleWithNavigation(
    const blink::mojom::BeginNavigationParams& potential_activation,
    bool allow_initiator_and_transition_mismatch,
    PrerenderCancellationReason& reason) {}

PrerenderHost::ActivationNavigationParamsMatch
PrerenderHost::AreCommonNavigationParamsCompatibleWithNavigation(
    const blink::mojom::CommonNavigationParams& potential_activation,
    bool allow_initiator_and_transition_mismatch) {}

RenderFrameHostImpl* PrerenderHost::GetPrerenderedMainFrameHost() {}

FrameTree& PrerenderHost::GetPrerenderFrameTree() {}

void PrerenderHost::RecordFailedFinalStatus(
    base::PassKey<PrerenderHostRegistry>,
    const PrerenderCancellationReason& reason) {}

void PrerenderHost::RecordFailedFinalStatusImpl(
    const PrerenderCancellationReason& reason) {}

void PrerenderHost::RecordActivation(NavigationRequest& navigation_request) {}

PrerenderHost::LoadingOutcome PrerenderHost::WaitForLoadStopForTesting() {}

const GURL& PrerenderHost::GetInitialUrl() const {}

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

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

std::optional<int64_t> PrerenderHost::GetInitialNavigationId() const {}

void PrerenderHost::SetInitialNavigation(NavigationRequest* navigation) {}

void PrerenderHost::SetTriggeringOutcome(PreloadingTriggeringOutcome outcome) {}

void PrerenderHost::SetFailureReason(
    const PrerenderCancellationReason& reason) {}

std::optional<UrlMatchType> PrerenderHost::IsUrlMatch(const GURL& url) const {}

bool PrerenderHost::IsNoVarySearchHintUrlMatch(const GURL& url) const {}

void PrerenderHost::OnAcceptClientHintChanged(
    const url::Origin& origin,
    const std::vector<network::mojom::WebClientHintsType>& client_hints_type) {}

void PrerenderHost::GetAllowedClientHintsOnPage(
    const url::Origin& origin,
    blink::EnabledClientHints* client_hints) const {}

std::string PrerenderHost::GetHistogramSuffix() const {}

void PrerenderHost::Cancel(PrerenderFinalStatus status) {}

void PrerenderHost::MaybeSetNoVarySearch(
    network::mojom::NoVarySearchWithParseError&
        no_vary_search_with_parse_error) {}

bool PrerenderHost::IsInitialNavigation(
    const NavigationRequest& navigation_request) const {}

base::TimeDelta PrerenderHost::WaitUntilHeadTimeout() {}

void PrerenderHost::OnWaitingForHeadersStarted(
    NavigationHandle& navigation_handle,
    WaitingForHeadersStartedReason reason) {}

void PrerenderHost::OnWaitingForHeadersFinished(
    NavigationHandle& navigation_handle,
    WaitingForHeadersFinishedReason reason) {}

}  // namespace content