chromium/third_party/blink/renderer/core/frame/remote_frame.cc

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

#include "third_party/blink/renderer/core/frame/remote_frame.h"

#include "base/types/optional_util.h"
#include "cc/layers/surface_layer.h"
#include "services/network/public/mojom/web_sandbox_flags.mojom-blink.h"
#include "third_party/blink/public/common/fenced_frame/fenced_frame_utils.h"
#include "third_party/blink/public/common/frame/frame_owner_element_type.h"
#include "third_party/blink/public/common/navigation/navigation_policy.h"
#include "third_party/blink/public/common/page/page_zoom.h"
#include "third_party/blink/public/mojom/frame/frame.mojom-blink.h"
#include "third_party/blink/public/mojom/frame/frame_owner_properties.mojom-blink.h"
#include "third_party/blink/public/mojom/frame/frame_replication_state.mojom-blink.h"
#include "third_party/blink/public/mojom/frame/fullscreen.mojom-blink.h"
#include "third_party/blink/public/mojom/frame/intrinsic_sizing_info.mojom-blink.h"
#include "third_party/blink/public/mojom/loader/referrer.mojom-blink.h"
#include "third_party/blink/public/mojom/security_context/insecure_request_policy.mojom-blink.h"
#include "third_party/blink/public/mojom/timing/resource_timing.mojom-blink-forward.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/url_conversion.h"
#include "third_party/blink/public/platform/web_url_request_util.h"
#include "third_party/blink/public/web/web_frame.h"
#include "third_party/blink/public/web/web_view.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_fullscreen_options.h"
#include "third_party/blink/renderer/bindings/core/v8/window_proxy.h"
#include "third_party/blink/renderer/bindings/core/v8/window_proxy_manager.h"
#include "third_party/blink/renderer/core/accessibility/ax_object_cache.h"
#include "third_party/blink/renderer/core/events/message_event.h"
#include "third_party/blink/renderer/core/exported/web_view_impl.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/remote_dom_window.h"
#include "third_party/blink/renderer/core/frame/remote_frame_client.h"
#include "third_party/blink/renderer/core/frame/remote_frame_owner.h"
#include "third_party/blink/renderer/core/frame/remote_frame_view.h"
#include "third_party/blink/renderer/core/frame/user_activation.h"
#include "third_party/blink/renderer/core/fullscreen/fullscreen.h"
#include "third_party/blink/renderer/core/html/fenced_frame/html_fenced_frame_element.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/layout/geometry/physical_rect.h"
#include "third_party/blink/renderer/core/layout/intrinsic_sizing_info.h"
#include "third_party/blink/renderer/core/layout/layout_embedded_content.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/layout/text_autosizer.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/mixed_content_checker.h"
#include "third_party/blink/renderer/core/messaging/blink_transferable_message.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/page/plugin_script_forbidden_scope.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h"
#include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/core/scroll/scroll_into_view_util.h"
#include "third_party/blink/renderer/core/timing/dom_window_performance.h"
#include "third_party/blink/renderer/platform/exported/wrapped_resource_request.h"
#include "third_party/blink/renderer/platform/heap/collection_support/heap_vector.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/loader/fetch/fetch_client_settings_object.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_fetcher_properties.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_request.h"
#include "third_party/blink/renderer/platform/weborigin/security_policy.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"
#include "ui/base/window_open_disposition.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/rect_f.h"

namespace blink {

namespace {

// Maintain a global (statically-allocated) hash map indexed by the the result
// of hashing the |frame_token| passed on creation of a RemoteFrame object.
RemoteFramesByTokenMap;
static RemoteFramesByTokenMap& GetRemoteFramesMap() {}

}  // namespace

// static
RemoteFrame* RemoteFrame::FromFrameToken(const RemoteFrameToken& frame_token) {}

RemoteFrame::RemoteFrame(
    RemoteFrameClient* client,
    Page& page,
    FrameOwner* owner,
    Frame* parent,
    Frame* previous_sibling,
    FrameInsertType insert_type,
    const RemoteFrameToken& frame_token,
    WindowAgentFactory* inheriting_agent_factory,
    WebFrameWidget* ancestor_widget,
    const base::UnguessableToken& devtools_frame_token,
    mojo::PendingAssociatedRemote<mojom::blink::RemoteFrameHost>
        remote_frame_host,
    mojo::PendingAssociatedReceiver<mojom::blink::RemoteFrame> receiver)
    :{}

RemoteFrame::~RemoteFrame() {}

void RemoteFrame::DetachAndDispose() {}

void RemoteFrame::Trace(Visitor* visitor) const {}

void RemoteFrame::Navigate(FrameLoadRequest& frame_request,
                           WebFrameLoadType frame_load_type) {}

bool RemoteFrame::NavigationShouldReplaceCurrentHistoryEntry(
    WebFrameLoadType frame_load_type) const {}

bool RemoteFrame::DetachImpl(FrameDetachType type) {}

const scoped_refptr<cc::Layer>& RemoteFrame::GetCcLayer() {}

void RemoteFrame::SetCcLayer(scoped_refptr<cc::Layer> layer,
                             bool is_surface_layer) {}

SkBitmap* RemoteFrame::GetSadPageBitmap() {}

bool RemoteFrame::DetachDocument() {}

void RemoteFrame::CheckCompleted() {}

const RemoteSecurityContext* RemoteFrame::GetSecurityContext() const {}

bool RemoteFrame::ShouldClose() {}

void RemoteFrame::SetIsInert(bool inert) {}

void RemoteFrame::SetInheritedEffectiveTouchAction(TouchAction touch_action) {}

void RemoteFrame::RenderFallbackContent() {}

void RemoteFrame::AddResourceTimingFromChild(
    mojom::blink::ResourceTimingInfoPtr timing) {}

void RemoteFrame::DidStartLoading() {}

void RemoteFrame::DidStopLoading() {}

void RemoteFrame::DidFocus() {}

void RemoteFrame::SetView(RemoteFrameView* view) {}

void RemoteFrame::CreateView() {}

void RemoteFrame::ForwardPostMessage(
    BlinkTransferableMessage transferable_message,
    LocalFrame* source_frame,
    scoped_refptr<const SecurityOrigin> source_security_origin,
    scoped_refptr<const SecurityOrigin> target_security_origin) {}

bool RemoteFrame::IsRemoteFrameHostRemoteBound() {}

mojom::blink::RemoteFrameHost& RemoteFrame::GetRemoteFrameHostRemote() {}

RemoteFrameClient* RemoteFrame::Client() const {}

void RemoteFrame::DidChangeVisibleToHitTesting() {}

void RemoteFrame::SetReplicatedPermissionsPolicyHeader(
    const ParsedPermissionsPolicy& parsed_header) {}

void RemoteFrame::SetReplicatedSandboxFlags(
    network::mojom::blink::WebSandboxFlags flags) {}

void RemoteFrame::SetInsecureRequestPolicy(
    mojom::blink::InsecureRequestPolicy policy) {}

void RemoteFrame::FrameRectsChanged(const gfx::Size& local_frame_size,
                                    const gfx::Rect& rect_in_local_root) {}

void RemoteFrame::InitializeFrameVisualProperties(
    const FrameVisualProperties& properties) {}

void RemoteFrame::WillEnterFullscreen(
    mojom::blink::FullscreenOptionsPtr request_options) {}

void RemoteFrame::EnforceInsecureNavigationsSet(
    const WTF::Vector<uint32_t>& set) {}

void RemoteFrame::SetFrameOwnerProperties(
    mojom::blink::FrameOwnerPropertiesPtr properties) {}

void RemoteFrame::EnforceInsecureRequestPolicy(
    mojom::blink::InsecureRequestPolicy policy) {}

void RemoteFrame::SetReplicatedOrigin(
    const scoped_refptr<const SecurityOrigin>& origin,
    bool is_potentially_trustworthy_unique_origin) {}

bool RemoteFrame::IsAdFrame() const {}

void RemoteFrame::SetReplicatedIsAdFrame(bool is_ad_frame) {}

void RemoteFrame::SetReplicatedName(const String& name,
                                    const String& unique_name) {}

void RemoteFrame::DispatchLoadEventForFrameOwner() {}

void RemoteFrame::Collapse(bool collapsed) {}

void RemoteFrame::Focus() {}

void RemoteFrame::SetHadStickyUserActivationBeforeNavigation(bool value) {}

void RemoteFrame::SetNeedsOcclusionTracking(bool needs_tracking) {}

void RemoteFrame::BubbleLogicalScroll(mojom::blink::ScrollDirection direction,
                                      ui::ScrollGranularity granularity) {}

void RemoteFrame::UpdateUserActivationState(
    mojom::blink::UserActivationUpdateType update_type,
    mojom::blink::UserActivationNotificationType notification_type) {}

void RemoteFrame::SetEmbeddingToken(
    const base::UnguessableToken& embedding_token) {}

void RemoteFrame::SetPageFocus(bool is_focused) {}

void RemoteFrame::ScrollRectToVisible(
    const gfx::RectF& rect_to_scroll,
    mojom::blink::ScrollIntoViewParamsPtr params) {}

void RemoteFrame::IntrinsicSizingInfoOfChildChanged(
    mojom::blink::IntrinsicSizingInfoPtr info) {}

// Update the proxy's SecurityContext with new sandbox flags or permissions
// policy that were set during navigation. Unlike changes to the FrameOwner,
// which are handled by RemoteFrame::DidUpdateFramePolicy, these changes should
// be considered effective immediately.
//
// These flags / policy are needed on the remote frame's SecurityContext to
// ensure that sandbox flags and permissions policy are inherited properly if
// this proxy ever parents a local frame.
void RemoteFrame::DidSetFramePolicyHeaders(
    network::mojom::blink::WebSandboxFlags sandbox_flags,
    const WTF::Vector<ParsedPermissionsPolicyDeclaration>&
        parsed_permissions_policy) {}

// Update the proxy's FrameOwner with new sandbox flags and container policy
// that were set by its parent in another process.
//
// Normally, when a frame's sandbox attribute is changed dynamically, the
// frame's FrameOwner is updated with the new sandbox flags right away, while
// the frame's SecurityContext is updated when the frame is navigated and the
// new sandbox flags take effect.
//
// Currently, there is no use case for a proxy's pending FrameOwner sandbox
// flags, so there's no message sent to proxies when the sandbox attribute is
// first updated.  Instead, the active flags are updated when they take effect,
// by OnDidSetActiveSandboxFlags. The proxy's FrameOwner flags are updated here
// with the caveat that the FrameOwner won't learn about updates to its flags
// until they take effect.
void RemoteFrame::DidUpdateFramePolicy(const FramePolicy& frame_policy) {}

void RemoteFrame::UpdateOpener(
    const std::optional<blink::FrameToken>& opener_frame_token) {}

gfx::Size RemoteFrame::GetOutermostMainFrameSize() const {}

gfx::Point RemoteFrame::GetOutermostMainFrameScrollPosition() const {}

void RemoteFrame::SetOpener(Frame* opener_frame) {}

void RemoteFrame::UpdateTextAutosizerPageInfo(
    mojom::blink::TextAutosizerPageInfoPtr mojo_remote_page_info) {}

void RemoteFrame::WasAttachedAsRemoteMainFrame(
    mojo::PendingAssociatedReceiver<mojom::blink::RemoteMainFrame> main_frame) {}

const viz::LocalSurfaceId& RemoteFrame::GetLocalSurfaceId() const {}

void RemoteFrame::SetCcLayerForTesting(scoped_refptr<cc::Layer> layer,
                                       bool is_surface_layer) {}

viz::FrameSinkId RemoteFrame::GetFrameSinkId() {}

void RemoteFrame::SetFrameSinkId(const viz::FrameSinkId& frame_sink_id,
                                 bool allow_paint_holding) {}

void RemoteFrame::ChildProcessGone() {}

bool RemoteFrame::IsIgnoredForHitTest() const {}

void RemoteFrame::AdvanceFocus(mojom::blink::FocusType type,
                               LocalFrame* source) {}

bool RemoteFrame::DetachChildren() {}

void RemoteFrame::ApplyReplicatedPermissionsPolicyHeader() {}

bool RemoteFrame::SynchronizeVisualProperties(
    bool propagate,
    ChildFrameCompositingHelper::AllowPaintHolding allow_paint_holding) {}

void RemoteFrame::RecordSentVisualProperties() {}

void RemoteFrame::ResendVisualProperties() {}

void RemoteFrame::ResendVisualPropertiesInternal(
    ChildFrameCompositingHelper::AllowPaintHolding allow_paint_holding) {}

void RemoteFrame::DidUpdateVisualProperties(
    const cc::RenderFrameMetadata& metadata) {}

void RemoteFrame::SetViewportIntersection(
    const mojom::blink::ViewportIntersectionState& intersection_state) {}

void RemoteFrame::UpdateCompositedLayerBounds() {}

void RemoteFrame::DidChangeScreenInfos(
    const display::ScreenInfos& screen_infos) {}

void RemoteFrame::ZoomFactorChanged(double zoom_factor) {}

void RemoteFrame::DidChangeRootViewportSegments(
    const std::vector<gfx::Rect>& root_widget_viewport_segments) {}

void RemoteFrame::PageScaleFactorChanged(float page_scale_factor,
                                         bool is_pinch_gesture_active) {}

void RemoteFrame::DidChangeVisibleViewportSize(
    const gfx::Size& visible_viewport_size) {}

void RemoteFrame::UpdateCaptureSequenceNumber(
    uint32_t capture_sequence_number) {}

void RemoteFrame::CursorAccessibilityScaleFactorChanged(float scale_factor) {}

void RemoteFrame::EnableAutoResize(const gfx::Size& min_size,
                                   const gfx::Size& max_size) {}

void RemoteFrame::DisableAutoResize() {}

void RemoteFrame::CreateRemoteChild(
    const RemoteFrameToken& token,
    const std::optional<FrameToken>& opener_frame_token,
    mojom::blink::TreeScopeType tree_scope_type,
    mojom::blink::FrameReplicationStatePtr replication_state,
    mojom::blink::FrameOwnerPropertiesPtr owner_properties,
    bool is_loading,
    const base::UnguessableToken& devtools_frame_token,
    mojom::blink::RemoteFrameInterfacesFromBrowserPtr remote_frame_interfaces) {}

void RemoteFrame::CreateRemoteChildren(
    Vector<mojom::blink::CreateRemoteChildParamsPtr> params) {}

void RemoteFrame::ForwardFencedFrameEventToEmbedder(
    const WTF::String& event_type) {}

}  // namespace blink