1 // Copyright 2015 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be found 3 // in the LICENSE file. 4 5 #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_REMOTE_FRAME_OWNER_H_ 6 #define THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_REMOTE_FRAME_OWNER_H_ 7 8 #include "third_party/blink/public/common/frame/frame_policy.h" 9 #include "third_party/blink/public/mojom/frame/frame_owner_element_type.mojom-blink.h" 10 #include "third_party/blink/public/mojom/scroll/scrollbar_mode.mojom-blink.h" 11 #include "third_party/blink/public/web/web_frame_owner_properties.h" 12 #include "third_party/blink/renderer/core/core_export.h" 13 #include "third_party/blink/renderer/core/frame/frame_owner.h" 14 #include "third_party/blink/renderer/core/scroll/scroll_types.h" 15 #include "third_party/blink/renderer/platform/wtf/casting.h" 16 17 namespace blink { 18 19 // Helper class to bridge communication for a frame with a remote parent. 20 // Currently, it serves two purposes: 21 // 1. Allows the local frame's loader to retrieve sandbox flags associated with 22 // its owner element in another process. 23 // 2. Trigger a load event on its owner element once it finishes a load. 24 class CORE_EXPORT RemoteFrameOwner final 25 : public GarbageCollected<RemoteFrameOwner>, 26 public FrameOwner { 27 public: 28 RemoteFrameOwner( 29 const FramePolicy&, 30 const WebFrameOwnerProperties&, 31 mojom::blink::FrameOwnerElementType frame_owner_element_type); 32 33 // FrameOwner overrides: ContentFrame()34 Frame* ContentFrame() const override { return frame_.Get(); } 35 void SetContentFrame(Frame&) override; 36 void ClearContentFrame() override; GetFramePolicy()37 const FramePolicy& GetFramePolicy() const override { return frame_policy_; } 38 void AddResourceTiming(const ResourceTimingInfo&) override; 39 void DispatchLoad() override; CanRenderFallbackContent()40 bool CanRenderFallbackContent() const override { 41 return frame_owner_element_type_ == 42 mojom::blink::FrameOwnerElementType::kObject; 43 } 44 void RenderFallbackContent(Frame*) override; 45 void IntrinsicSizingInfoChanged() override; 46 void SetNeedsOcclusionTracking(bool) override; 47 BrowsingContextContainerName()48 AtomicString BrowsingContextContainerName() const override { 49 return browsing_context_container_name_; 50 } ScrollbarMode()51 mojom::blink::ScrollbarMode ScrollbarMode() const override { 52 return scrollbar_; 53 } MarginWidth()54 int MarginWidth() const override { return margin_width_; } MarginHeight()55 int MarginHeight() const override { return margin_height_; } AllowFullscreen()56 bool AllowFullscreen() const override { return allow_fullscreen_; } AllowPaymentRequest()57 bool AllowPaymentRequest() const override { return allow_payment_request_; } IsDisplayNone()58 bool IsDisplayNone() const override { return is_display_none_; } GetColorScheme()59 mojom::ColorScheme GetColorScheme() const override { return color_scheme_; } RequiredCsp()60 AtomicString RequiredCsp() const override { return required_csp_; } 61 bool ShouldLazyLoadChildren() const final; 62 SetFramePolicy(const FramePolicy & frame_policy)63 void SetFramePolicy(const FramePolicy& frame_policy) { 64 frame_policy_ = frame_policy; 65 } SetBrowsingContextContainerName(const WebString & name)66 void SetBrowsingContextContainerName(const WebString& name) { 67 browsing_context_container_name_ = name; 68 } 69 void SetScrollbarMode(mojom::blink::ScrollbarMode); SetMarginWidth(int margin_width)70 void SetMarginWidth(int margin_width) { margin_width_ = margin_width; } SetMarginHeight(int margin_height)71 void SetMarginHeight(int margin_height) { margin_height_ = margin_height; } SetAllowFullscreen(bool allow_fullscreen)72 void SetAllowFullscreen(bool allow_fullscreen) { 73 allow_fullscreen_ = allow_fullscreen; 74 } SetAllowPaymentRequest(bool allow_payment_request)75 void SetAllowPaymentRequest(bool allow_payment_request) { 76 allow_payment_request_ = allow_payment_request; 77 } SetIsDisplayNone(bool is_display_none)78 void SetIsDisplayNone(bool is_display_none) { 79 is_display_none_ = is_display_none; 80 } SetColorScheme(mojom::ColorScheme color_scheme)81 void SetColorScheme(mojom::ColorScheme color_scheme) { 82 color_scheme_ = color_scheme; 83 } SetRequiredCsp(const WebString & required_csp)84 void SetRequiredCsp(const WebString& required_csp) { 85 required_csp_ = required_csp; 86 } 87 88 void Trace(Visitor*) const override; 89 90 private: 91 // Intentionally private to prevent redundant checks when the type is 92 // already HTMLFrameOwnerElement. IsLocal()93 bool IsLocal() const override { return false; } IsRemote()94 bool IsRemote() const override { return true; } 95 96 Member<Frame> frame_; 97 FramePolicy frame_policy_; 98 AtomicString browsing_context_container_name_; 99 mojom::blink::ScrollbarMode scrollbar_; 100 int margin_width_; 101 int margin_height_; 102 bool allow_fullscreen_; 103 bool allow_payment_request_; 104 bool is_display_none_; 105 mojom::ColorScheme color_scheme_; 106 bool needs_occlusion_tracking_; 107 WebString required_csp_; 108 const mojom::blink::FrameOwnerElementType frame_owner_element_type_; 109 }; 110 111 template <> 112 struct DowncastTraits<RemoteFrameOwner> { 113 static bool AllowFrom(const FrameOwner& owner) { return owner.IsRemote(); } 114 }; 115 116 } // namespace blink 117 118 #endif // THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_REMOTE_FRAME_OWNER_H_ 119