#include "third_party/blink/renderer/core/frame/local_frame_client_impl.h"
#include <utility>
#include "base/metrics/histogram_functions.h"
#include "base/time/time.h"
#include "base/types/optional_util.h"
#include "components/viz/common/frame_timing_details.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/type_converter.h"
#include "net/storage_access_api/status.h"
#include "third_party/blink/public/common/blob/blob_utils.h"
#include "third_party/blink/public/common/permissions_policy/permissions_policy.h"
#include "third_party/blink/public/common/scheduler/task_attribution_id.h"
#include "third_party/blink/public/common/tokens/tokens.h"
#include "third_party/blink/public/common/user_agent/user_agent_metadata.h"
#include "third_party/blink/public/mojom/frame/user_activation_update_types.mojom-blink-forward.h"
#include "third_party/blink/public/mojom/loader/fetch_later.mojom-blink.h"
#include "third_party/blink/public/platform/modules/service_worker/web_service_worker_provider.h"
#include "third_party/blink/public/platform/modules/service_worker/web_service_worker_provider_client.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/web_background_resource_fetch_assets.h"
#include "third_party/blink/public/platform/web_media_player_source.h"
#include "third_party/blink/public/platform/web_security_origin.h"
#include "third_party/blink/public/platform/web_url.h"
#include "third_party/blink/public/platform/web_url_error.h"
#include "third_party/blink/public/platform/web_vector.h"
#include "third_party/blink/public/web/web_autofill_client.h"
#include "third_party/blink/public/web/web_document.h"
#include "third_party/blink/public/web/web_dom_event.h"
#include "third_party/blink/public/web/web_form_element.h"
#include "third_party/blink/public/web/web_local_frame_client.h"
#include "third_party/blink/public/web/web_manifest_manager.h"
#include "third_party/blink/public/web/web_navigation_params.h"
#include "third_party/blink/public/web/web_node.h"
#include "third_party/blink/public/web/web_plugin.h"
#include "third_party/blink/public/web/web_plugin_params.h"
#include "third_party/blink/public/web/web_view_client.h"
#include "third_party/blink/renderer/bindings/core/v8/capture_source_location.h"
#include "third_party/blink/renderer/core/core_initializer.h"
#include "third_party/blink/renderer/core/events/current_input_event.h"
#include "third_party/blink/renderer/core/events/message_event.h"
#include "third_party/blink/renderer/core/events/mouse_event.h"
#include "third_party/blink/renderer/core/exported/web_dev_tools_agent_impl.h"
#include "third_party/blink/renderer/core/exported/web_plugin_container_impl.h"
#include "third_party/blink/renderer/core/exported/web_view_impl.h"
#include "third_party/blink/renderer/core/fileapi/public_url_manager.h"
#include "third_party/blink/renderer/core/frame/frame.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/frame/web_frame_widget_impl.h"
#include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
#include "third_party/blink/renderer/core/fullscreen/fullscreen.h"
#include "third_party/blink/renderer/core/html/html_frame_element_base.h"
#include "third_party/blink/renderer/core/html/html_plugin_element.h"
#include "third_party/blink/renderer/core/html/media/html_media_element.h"
#include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/core/input/event_handler.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/inspector/dev_tools_emulator.h"
#include "third_party/blink/renderer/core/layout/hit_test_result.h"
#include "third_party/blink/renderer/core/layout/layout_shift_tracker.h"
#include "third_party/blink/renderer/core/loader/document_loader.h"
#include "third_party/blink/renderer/core/loader/frame_load_request.h"
#include "third_party/blink/renderer/core/loader/frame_loader.h"
#include "third_party/blink/renderer/core/loader/history_item.h"
#include "third_party/blink/renderer/core/origin_trials/origin_trial_context.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/page/plugin_data.h"
#include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/core/script/classic_script.h"
#include "third_party/blink/renderer/platform/exported/wrapped_resource_request.h"
#include "third_party/blink/renderer/platform/exported/wrapped_resource_response.h"
#include "third_party/blink/renderer/platform/instrumentation/histogram.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h"
#include "third_party/blink/renderer/platform/network/http_parsers.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "v8/include/v8.h"
namespace blink {
namespace {
Frame* ToCoreFrame(WebFrame* frame) { … }
LocalFrame* GetLocalParentFrame(WebLocalFrameImpl* frame) { … }
bool IsLoadedAsMHTMLArchive(LocalFrame* local_frame) { … }
bool IsBackForwardNavigationInProgress(LocalFrame* local_frame) { … }
void ResetWheelAndTouchEventHandlerProperties(LocalFrame& frame) { … }
bool IsCompositedOutermostMainFrame(WebLocalFrameImpl* web_frame) { … }
}
LocalFrameClientImpl::LocalFrameClientImpl(WebLocalFrameImpl* frame)
: … { … }
LocalFrameClientImpl::~LocalFrameClientImpl() = default;
void LocalFrameClientImpl::Trace(Visitor* visitor) const { … }
WebLocalFrameImpl* LocalFrameClientImpl::GetWebFrame() const { … }
WebContentCaptureClient* LocalFrameClientImpl::GetWebContentCaptureClient()
const { … }
void LocalFrameClientImpl::DidCommitDocumentReplacementNavigation(
DocumentLoader* loader) { … }
void LocalFrameClientImpl::DispatchDidClearWindowObjectInMainWorld(
v8::Isolate* isolate,
v8::MicrotaskQueue* microtask_queue) { … }
void LocalFrameClientImpl::DocumentElementAvailable() { … }
void LocalFrameClientImpl::RunScriptsAtDocumentElementAvailable() { … }
void LocalFrameClientImpl::RunScriptsAtDocumentReady(bool document_is_empty) { … }
void LocalFrameClientImpl::RunScriptsAtDocumentIdle() { … }
void LocalFrameClientImpl::DidCreateScriptContext(
v8::Local<v8::Context> context,
int32_t world_id) { … }
void LocalFrameClientImpl::WillReleaseScriptContext(
v8::Local<v8::Context> context,
int32_t world_id) { … }
bool LocalFrameClientImpl::AllowScriptExtensions() { … }
void LocalFrameClientImpl::DidChangeScrollOffset() { … }
void LocalFrameClientImpl::NotifyCurrentHistoryItemChanged() { … }
void LocalFrameClientImpl::DidUpdateCurrentHistoryItem() { … }
bool LocalFrameClientImpl::AllowContentInitiatedDataUrlNavigations(
const KURL& url) { … }
bool LocalFrameClientImpl::HasWebView() const { … }
bool LocalFrameClientImpl::InShadowTree() const { … }
void LocalFrameClientImpl::WillBeDetached() { … }
void LocalFrameClientImpl::Detached(FrameDetachType type) { … }
void LocalFrameClientImpl::DispatchFinalizeRequest(ResourceRequest& request) { … }
std::optional<KURL> LocalFrameClientImpl::DispatchWillSendRequest(
const KURL& requested_url,
const scoped_refptr<const SecurityOrigin>& requestor_origin,
const net::SiteForCookies& site_for_cookies,
bool has_redirect_info,
const KURL& upstream_url) { … }
void LocalFrameClientImpl::DispatchDidDispatchDOMContentLoadedEvent() { … }
void LocalFrameClientImpl::DispatchDidLoadResourceFromMemoryCache(
const ResourceRequest& request,
const ResourceResponse& response) { … }
void LocalFrameClientImpl::DispatchDidHandleOnloadEvents() { … }
void LocalFrameClientImpl::DidFinishSameDocumentNavigation(
WebHistoryCommitType commit_type,
bool is_synchronously_committed,
mojom::blink::SameDocumentNavigationType same_document_navigation_type,
bool is_client_redirect,
bool is_browser_initiated) { … }
void LocalFrameClientImpl::DidFailAsyncSameDocumentCommit() { … }
void LocalFrameClientImpl::DispatchDidOpenDocumentInputStream(const KURL& url) { … }
void LocalFrameClientImpl::DispatchDidReceiveTitle(const String& title) { … }
void LocalFrameClientImpl::DispatchDidCommitLoad(
HistoryItem* item,
WebHistoryCommitType commit_type,
bool should_reset_browser_interface_broker,
const blink::ParsedPermissionsPolicy& permissions_policy_header,
const blink::DocumentPolicyFeatureState& document_policy_header) { … }
void LocalFrameClientImpl::DispatchDidFailLoad(
const ResourceError& error,
WebHistoryCommitType commit_type) { … }
void LocalFrameClientImpl::DispatchDidFinishLoad() { … }
void LocalFrameClientImpl::DispatchDidFinishLoadForPrinting() { … }
void LocalFrameClientImpl::BeginNavigation(
const ResourceRequest& request,
const KURL& requestor_base_url,
mojom::RequestContextFrameType frame_type,
LocalDOMWindow* origin_window,
DocumentLoader* document_loader,
WebNavigationType type,
NavigationPolicy policy,
WebFrameLoadType frame_load_type,
mojom::blink::ForceHistoryPush force_history_push,
bool is_client_redirect,
bool is_unfenced_top_navigation,
mojom::blink::TriggeringEventInfo triggering_event_info,
HTMLFormElement* form,
network::mojom::CSPDisposition
should_check_main_world_content_security_policy,
mojo::PendingRemote<mojom::blink::BlobURLToken> blob_url_token,
base::TimeTicks input_start_time,
const String& href_translate,
const std::optional<Impression>& impression,
const LocalFrameToken* initiator_frame_token,
std::unique_ptr<SourceLocation> source_location,
mojo::PendingRemote<mojom::blink::NavigationStateKeepAliveHandle>
initiator_navigation_state_keep_alive_handle,
bool is_container_initiated,
bool has_rel_opener) { … }
void LocalFrameClientImpl::DispatchWillSendSubmitEvent(HTMLFormElement* form) { … }
void LocalFrameClientImpl::DidStartLoading() { … }
void LocalFrameClientImpl::DidStopLoading() { … }
bool LocalFrameClientImpl::NavigateBackForward(
int offset,
std::optional<scheduler::TaskAttributionId>
soft_navigation_heuristics_task_id) const { … }
void LocalFrameClientImpl::DidDispatchPingLoader(const KURL& url) { … }
void LocalFrameClientImpl::DidChangePerformanceTiming() { … }
void LocalFrameClientImpl::DidObserveUserInteraction(
base::TimeTicks max_event_start,
base::TimeTicks max_event_queued_main_thread,
base::TimeTicks max_event_commit_finish,
base::TimeTicks max_event_end,
UserInteractionType interaction_type,
uint64_t interaction_offset) { … }
void LocalFrameClientImpl::DidChangeCpuTiming(base::TimeDelta time) { … }
void LocalFrameClientImpl::DidObserveLoadingBehavior(
LoadingBehaviorFlag behavior) { … }
void LocalFrameClientImpl::DidObserveJavaScriptFrameworks(
const JavaScriptFrameworkDetectionResult& result) { … }
void LocalFrameClientImpl::DidObserveSubresourceLoad(
const SubresourceLoadMetrics& subresource_load_metrics) { … }
void LocalFrameClientImpl::DidObserveNewFeatureUsage(
const UseCounterFeature& feature) { … }
void LocalFrameClientImpl::DidObserveSoftNavigation(
SoftNavigationMetrics metrics) { … }
void LocalFrameClientImpl::DidObserveLayoutShift(double score,
bool after_input_or_scroll) { … }
void LocalFrameClientImpl::SelectorMatchChanged(
const Vector<String>& added_selectors,
const Vector<String>& removed_selectors) { … }
void LocalFrameClientImpl::DidCreateDocumentLoader(
DocumentLoader* document_loader) { … }
String LocalFrameClientImpl::UserAgentOverride() { … }
String LocalFrameClientImpl::UserAgent() { … }
std::optional<UserAgentMetadata> LocalFrameClientImpl::UserAgentMetadata() { … }
String LocalFrameClientImpl::DoNotTrackValue() { … }
void LocalFrameClientImpl::TransitionToCommittedForNewPage() { … }
LocalFrame* LocalFrameClientImpl::CreateFrame(
const AtomicString& name,
HTMLFrameOwnerElement* owner_element) { … }
RemoteFrame* LocalFrameClientImpl::CreateFencedFrame(
HTMLFencedFrameElement* fenced_frame,
mojo::PendingAssociatedReceiver<mojom::blink::FencedFrameOwnerHost>
receiver) { … }
WebPluginContainerImpl* LocalFrameClientImpl::CreatePlugin(
HTMLPlugInElement& element,
const KURL& url,
const Vector<String>& param_names,
const Vector<String>& param_values,
const String& mime_type,
bool load_manually) { … }
std::unique_ptr<WebMediaPlayer> LocalFrameClientImpl::CreateWebMediaPlayer(
HTMLMediaElement& html_media_element,
const WebMediaPlayerSource& source,
WebMediaPlayerClient* client) { … }
WebRemotePlaybackClient* LocalFrameClientImpl::CreateWebRemotePlaybackClient(
HTMLMediaElement& html_media_element) { … }
void LocalFrameClientImpl::DidChangeName(const String& name) { … }
std::unique_ptr<WebServiceWorkerProvider>
LocalFrameClientImpl::CreateServiceWorkerProvider() { … }
WebContentSettingsClient* LocalFrameClientImpl::GetContentSettingsClient() { … }
void LocalFrameClientImpl::DispatchDidChangeManifest() { … }
unsigned LocalFrameClientImpl::BackForwardLength() { … }
WebDevToolsAgentImpl* LocalFrameClientImpl::DevToolsAgent(
bool create_if_necessary) { … }
KURL LocalFrameClientImpl::OverrideFlashEmbedWithHTML(const KURL& url) { … }
void LocalFrameClientImpl::NotifyUserActivation() { … }
void LocalFrameClientImpl::AbortClientNavigation() { … }
WebSpellCheckPanelHostClient* LocalFrameClientImpl::SpellCheckPanelHostClient()
const { … }
WebTextCheckClient* LocalFrameClientImpl::GetTextCheckerClient() const { … }
scoped_refptr<network::SharedURLLoaderFactory>
LocalFrameClientImpl::GetURLLoaderFactory() { … }
std::unique_ptr<URLLoader> LocalFrameClientImpl::CreateURLLoaderForTesting() { … }
blink::ChildURLLoaderFactoryBundle*
LocalFrameClientImpl::GetLoaderFactoryBundle() { … }
scoped_refptr<WebBackgroundResourceFetchAssets>
LocalFrameClientImpl::MaybeGetBackgroundResourceFetchAssets() { … }
AssociatedInterfaceProvider*
LocalFrameClientImpl::GetRemoteNavigationAssociatedInterfaces() { … }
base::UnguessableToken LocalFrameClientImpl::GetDevToolsFrameToken() const { … }
String LocalFrameClientImpl::evaluateInInspectorOverlayForTesting(
const String& script) { … }
bool LocalFrameClientImpl::HandleCurrentKeyboardEvent() { … }
void LocalFrameClientImpl::DidChangeSelection(bool is_selection_empty,
blink::SyncCondition force_sync) { … }
void LocalFrameClientImpl::DidChangeContents() { … }
Frame* LocalFrameClientImpl::FindFrame(const AtomicString& name) const { … }
void LocalFrameClientImpl::FocusedElementChanged(Element* element) { … }
void LocalFrameClientImpl::OnMainFrameIntersectionChanged(
const gfx::Rect& main_frame_intersection_rect) { … }
void LocalFrameClientImpl::OnMainFrameViewportRectangleChanged(
const gfx::Rect& main_frame_viewport_rect) { … }
void LocalFrameClientImpl::OnMainFrameImageAdRectangleChanged(
DOMNodeId element_id,
const gfx::Rect& image_ad_rect) { … }
void LocalFrameClientImpl::OnOverlayPopupAdDetected() { … }
void LocalFrameClientImpl::OnLargeStickyAdDetected() { … }
bool LocalFrameClientImpl::IsPluginHandledExternally(
HTMLPlugInElement& plugin_element,
const KURL& resource_url,
const String& suggesed_mime_type) { … }
v8::Local<v8::Object> LocalFrameClientImpl::GetScriptableObject(
HTMLPlugInElement& plugin_element,
v8::Isolate* isolate) { … }
scoped_refptr<WebWorkerFetchContext>
LocalFrameClientImpl::CreateWorkerFetchContext() { … }
scoped_refptr<WebWorkerFetchContext>
LocalFrameClientImpl::CreateWorkerFetchContextForPlzDedicatedWorker(
WebDedicatedWorkerHostFactoryClient* factory_client) { … }
std::unique_ptr<WebContentSettingsClient>
LocalFrameClientImpl::CreateWorkerContentSettingsClient() { … }
void LocalFrameClientImpl::SetMouseCapture(bool capture) { … }
void LocalFrameClientImpl::NotifyAutoscrollForSelectionInMainFrame(
bool autoscroll_selection) { … }
std::unique_ptr<blink::ResourceLoadInfoNotifierWrapper>
LocalFrameClientImpl::CreateResourceLoadInfoNotifierWrapper() { … }
void LocalFrameClientImpl::BindDevToolsAgent(
mojo::PendingAssociatedRemote<mojom::blink::DevToolsAgentHost> host,
mojo::PendingAssociatedReceiver<mojom::blink::DevToolsAgent> receiver) { … }
bool LocalFrameClientImpl::IsDomStorageDisabled() const { … }
}