#include "third_party/blink/renderer/core/loader/frame_fetch_context.h"
#include <algorithm>
#include <memory>
#include <optional>
#include "base/feature_list.h"
#include "base/memory/scoped_refptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "build/build_config.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "net/http/structured_headers.h"
#include "services/network/public/cpp/client_hints.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/mojom/web_client_hints_types.mojom-blink.h"
#include "services/network/public/mojom/web_client_hints_types.mojom-shared.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/blink/public/common/client_hints/client_hints.h"
#include "third_party/blink/public/common/device_memory/approximated_device_memory.h"
#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom-blink.h"
#include "third_party/blink/public/mojom/loader/request_context_frame_type.mojom-blink.h"
#include "third_party/blink/public/mojom/permissions_policy/permissions_policy.mojom-blink.h"
#include "third_party/blink/public/platform/modules/service_worker/web_service_worker_network_provider.h"
#include "third_party/blink/public/platform/scheduler/web_scoped_virtual_time_pauser.h"
#include "third_party/blink/public/platform/web_content_settings_client.h"
#include "third_party/blink/public/platform/web_effective_connection_type.h"
#include "third_party/blink/public/platform/websocket_handshake_throttle.h"
#include "third_party/blink/public/web/web_frame.h"
#include "third_party/blink/public/web/web_local_frame.h"
#include "third_party/blink/public/web/web_local_frame_client.h"
#include "third_party/blink/renderer/bindings/core/v8/script_controller.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/core/css/media_values.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/fileapi/public_url_manager.h"
#include "third_party/blink/renderer/core/frame/ad_tracker.h"
#include "third_party/blink/renderer/core/frame/attribution_src_loader.h"
#include "third_party/blink/renderer/core/frame/csp/content_security_policy.h"
#include "third_party/blink/renderer/core/frame/deprecation/deprecation.h"
#include "third_party/blink/renderer/core/frame/frame_console.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_client.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/navigator.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/html/html_frame_owner_element.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/inspector/inspector_audits_issue.h"
#include "third_party/blink/renderer/core/inspector/inspector_trace_events.h"
#include "third_party/blink/renderer/core/lcp_critical_path_predictor/lcp_critical_path_predictor.h"
#include "third_party/blink/renderer/core/loader/back_forward_cache_loader_helper_impl.h"
#include "third_party/blink/renderer/core/loader/document_loader.h"
#include "third_party/blink/renderer/core/loader/frame_loader.h"
#include "third_party/blink/renderer/core/loader/frame_resource_fetcher_properties.h"
#include "third_party/blink/renderer/core/loader/idleness_detector.h"
#include "third_party/blink/renderer/core/loader/interactive_detector.h"
#include "third_party/blink/renderer/core/loader/loader_factory_for_frame.h"
#include "third_party/blink/renderer/core/loader/mixed_content_checker.h"
#include "third_party/blink/renderer/core/loader/resource/image_resource.h"
#include "third_party/blink/renderer/core/loader/resource_load_observer_for_frame.h"
#include "third_party/blink/renderer/core/loader/subresource_filter.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/paint/timing/first_meaningful_paint_detector.h"
#include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/core/svg/graphics/svg_image_chrome_client.h"
#include "third_party/blink/renderer/core/timing/dom_window_performance.h"
#include "third_party/blink/renderer/core/timing/performance.h"
#include "third_party/blink/renderer/core/timing/window_performance.h"
#include "third_party/blink/renderer/core/url/url_search_params.h"
#include "third_party/blink/renderer/platform/bindings/script_forbidden_scope.h"
#include "third_party/blink/renderer/platform/exported/wrapped_resource_request.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/traced_value.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/loader/fetch/client_hints_preferences.h"
#include "third_party/blink/renderer/platform/loader/fetch/detachable_use_counter.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_load_priority.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_loader_options.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_loading_log.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_timing_utils.h"
#include "third_party/blink/renderer/platform/loader/fetch/unique_identifier.h"
#include "third_party/blink/renderer/platform/mhtml/mhtml_archive.h"
#include "third_party/blink/renderer/platform/network/http_names.h"
#include "third_party/blink/renderer/platform/network/network_state_notifier.h"
#include "third_party/blink/renderer/platform/network/network_utils.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/weborigin/scheme_registry.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
#include "third_party/blink/renderer/platform/wtf/text/atomic_string.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
namespace blink {
namespace {
const AtomicString SerializeStringHeader(const std::string& str) { … }
AtomicString GenerateBoolHeaderValue(bool value) { … }
const AtomicString SerializeBoolHeader(const bool value) { … }
mojom::FetchCacheMode DetermineFrameCacheMode(Frame* frame) { … }
bool ShouldSendClientHint(const PermissionsPolicy& policy,
const url::Origin& resource_origin,
bool is_1p_origin,
network::mojom::blink::WebClientHintsType type,
const ClientHintsPreferences& hints_preferences) { … }
}
struct FrameFetchContext::FrozenState final : GarbageCollected<FrozenState> { … };
ResourceFetcher* FrameFetchContext::CreateFetcherForCommittedDocument(
DocumentLoader& loader,
Document& document) { … }
FrameFetchContext::FrameFetchContext(
DocumentLoader& document_loader,
Document& document,
const DetachableResourceFetcherProperties& properties)
: … { … }
net::SiteForCookies FrameFetchContext::GetSiteForCookies() const { … }
scoped_refptr<const SecurityOrigin> FrameFetchContext::GetTopFrameOrigin()
const { … }
const Vector<KURL>& FrameFetchContext::GetPotentiallyUnusedPreloads() const { … }
void FrameFetchContext::AddLcpPredictedCallback(base::OnceClosure callback) { … }
SubresourceFilter* FrameFetchContext::GetSubresourceFilter() const { … }
LocalFrame* FrameFetchContext::GetFrame() const { … }
LocalFrameClient* FrameFetchContext::GetLocalFrameClient() const { … }
mojom::FetchCacheMode FrameFetchContext::ResourceRequestCachePolicy(
const ResourceRequest& request,
ResourceType type,
FetchParameters::DeferOption defer) const { … }
void FrameFetchContext::PrepareRequest(
ResourceRequest& request,
ResourceLoaderOptions& options,
WebScopedVirtualTimePauser& virtual_time_pauser,
ResourceType resource_type) { … }
void FrameFetchContext::AddResourceTiming(
mojom::blink::ResourceTimingInfoPtr info,
const AtomicString& initiator_type) { … }
bool FrameFetchContext::AllowImage() const { … }
void FrameFetchContext::ModifyRequestForCSP(ResourceRequest& resource_request) { … }
void FrameFetchContext::AddClientHintsIfNecessary(
const std::optional<float> resource_width,
ResourceRequest& request) { … }
void FrameFetchContext::AddReducedAcceptLanguageIfNecessary(
ResourceRequest& request) { … }
void FrameFetchContext::WillSendRequest(ResourceRequest& resource_request) { … }
void FrameFetchContext::PopulateResourceRequestBeforeCacheAccess(
const ResourceLoaderOptions& options,
ResourceRequest& request) { … }
void FrameFetchContext::UpgradeResourceRequestForLoader(
ResourceType type,
const std::optional<float> resource_width,
ResourceRequest& request,
const ResourceLoaderOptions& options) { … }
bool FrameFetchContext::IsPrerendering() const { … }
bool FrameFetchContext::DoesLCPPHaveAnyHintData() { … }
bool FrameFetchContext::DoesLCPPHaveLcpElementLocatorHintData() { … }
void FrameFetchContext::SetFirstPartyCookie(ResourceRequest& request) { … }
bool FrameFetchContext::AllowScript() const { … }
bool FrameFetchContext::IsFirstPartyOrigin(
const SecurityOrigin* resource_origin) const { … }
bool FrameFetchContext::ShouldBlockRequestByInspector(const KURL& url) const { … }
void FrameFetchContext::DispatchDidBlockRequest(
const ResourceRequest& resource_request,
const ResourceLoaderOptions& options,
ResourceRequestBlockedReason blocked_reason,
ResourceType resource_type) const { … }
ContentSecurityPolicy* FrameFetchContext::GetContentSecurityPolicyForWorld(
const DOMWrapperWorld* world) const { … }
bool FrameFetchContext::IsIsolatedSVGChromeClient() const { … }
void FrameFetchContext::CountUsage(WebFeature feature) const { … }
void FrameFetchContext::CountDeprecation(WebFeature feature) const { … }
bool FrameFetchContext::ShouldBlockWebSocketByMixedContentCheck(
const KURL& url) const { … }
std::unique_ptr<WebSocketHandshakeThrottle>
FrameFetchContext::CreateWebSocketHandshakeThrottle() { … }
bool FrameFetchContext::ShouldBlockFetchByMixedContentCheck(
mojom::blink::RequestContextType request_context,
network::mojom::blink::IPAddressSpace target_address_space,
base::optional_ref<const ResourceRequest::RedirectInfo> redirect_info,
const KURL& url,
ReportingDisposition reporting_disposition,
const String& devtools_id) const { … }
bool FrameFetchContext::ShouldBlockFetchAsCredentialedSubresource(
const ResourceRequest& resource_request,
const KURL& url) const { … }
const KURL& FrameFetchContext::Url() const { … }
ContentSecurityPolicy* FrameFetchContext::GetContentSecurityPolicy() const { … }
WebContentSettingsClient* FrameFetchContext::GetContentSettingsClient() const { … }
Settings* FrameFetchContext::GetSettings() const { … }
String FrameFetchContext::GetUserAgent() const { … }
std::optional<UserAgentMetadata> FrameFetchContext::GetUserAgentMetadata()
const { … }
const PermissionsPolicy* FrameFetchContext::GetPermissionsPolicy() const { … }
const ClientHintsPreferences FrameFetchContext::GetClientHintsPreferences()
const { … }
String FrameFetchContext::GetReducedAcceptLanguage() const { … }
float FrameFetchContext::GetDevicePixelRatio() const { … }
FetchContext* FrameFetchContext::Detach() { … }
void FrameFetchContext::Trace(Visitor* visitor) const { … }
bool FrameFetchContext::CalculateIfAdSubresource(
const ResourceRequestHead& resource_request,
base::optional_ref<const KURL> alias_url,
ResourceType type,
const FetchInitiatorInfo& initiator_info) { … }
void FrameFetchContext::DidObserveLoadingBehavior(
LoadingBehaviorFlag behavior) { … }
std::unique_ptr<ResourceLoadInfoNotifierWrapper>
FrameFetchContext::CreateResourceLoadInfoNotifierWrapper() { … }
mojom::blink::ContentSecurityNotifier&
FrameFetchContext::GetContentSecurityNotifier() const { … }
ExecutionContext* FrameFetchContext::GetExecutionContext() const { … }
std::optional<ResourceRequestBlockedReason> FrameFetchContext::CanRequest(
ResourceType type,
const ResourceRequest& resource_request,
const KURL& url,
const ResourceLoaderOptions& options,
ReportingDisposition reporting_disposition,
base::optional_ref<const ResourceRequest::RedirectInfo> redirect_info)
const { … }
CoreProbeSink* FrameFetchContext::Probe() const { … }
void FrameFetchContext::UpdateSubresourceLoadMetrics(
const SubresourceLoadMetrics& subresource_load_metrics) { … }
}