1 // Copyright 2020 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CONTENT_PUBLIC_TEST_FAKE_REMOTE_FRAME_H_ 6 #define CONTENT_PUBLIC_TEST_FAKE_REMOTE_FRAME_H_ 7 8 #include "mojo/public/cpp/bindings/associated_receiver.h" 9 #include "services/network/public/mojom/content_security_policy.mojom.h" 10 #include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h" 11 #include "third_party/blink/public/mojom/frame/frame.mojom.h" 12 #include "third_party/blink/public/mojom/frame/frame_owner_properties.mojom.h" 13 #include "third_party/blink/public/mojom/frame/fullscreen.mojom.h" 14 #include "third_party/blink/public/mojom/frame/intrinsic_sizing_info.mojom.h" 15 #include "third_party/blink/public/mojom/frame/user_activation_update_types.mojom.h" 16 #include "third_party/blink/public/mojom/scroll/scroll_into_view_params.mojom.h" 17 #include "third_party/blink/public/mojom/security_context/insecure_request_policy.mojom.h" 18 #include "ui/events/types/scroll_types.h" 19 20 namespace base { 21 class UnguessableToken; 22 } 23 24 namespace url { 25 class Origin; 26 } // namespace url 27 28 namespace content { 29 30 // This class implements a RemoteFrame that can be attached to the 31 // AssociatedInterfaceProvider so that it will be called when the browser 32 // normally sends a request to the renderer process. But for a unittest 33 // setup it can be intercepted by this class. 34 class FakeRemoteFrame : public blink::mojom::RemoteFrame { 35 public: 36 FakeRemoteFrame(); 37 ~FakeRemoteFrame() override; 38 39 void Init(blink::AssociatedInterfaceProvider* provider); 40 41 // blink::mojom::RemoteFrame overrides: 42 void WillEnterFullscreen(blink::mojom::FullscreenOptionsPtr) override; 43 void AddReplicatedContentSecurityPolicies( 44 std::vector<network::mojom::ContentSecurityPolicyHeaderPtr> headers) 45 override; 46 void ResetReplicatedContentSecurityPolicy() override; 47 void EnforceInsecureNavigationsSet(const std::vector<uint32_t>& set) override; 48 void SetFrameOwnerProperties( 49 blink::mojom::FrameOwnerPropertiesPtr properties) override; 50 void EnforceInsecureRequestPolicy( 51 blink::mojom::InsecureRequestPolicy policy) override; 52 void SetReplicatedOrigin( 53 const url::Origin& origin, 54 bool is_potentially_trustworthy_unique_origin) override; 55 void SetReplicatedAdFrameType( 56 blink::mojom::AdFrameType ad_frame_type) override; 57 void SetReplicatedName(const std::string& name, 58 const std::string& unique_name) override; 59 void DispatchLoadEventForFrameOwner() override; 60 void Collapse(bool collapsed) final; 61 void Focus() override; 62 void SetHadStickyUserActivationBeforeNavigation(bool value) override; 63 void SetNeedsOcclusionTracking(bool needs_tracking) override; 64 void BubbleLogicalScroll(blink::mojom::ScrollDirection direction, 65 ui::ScrollGranularity granularity) override; 66 void UpdateUserActivationState( 67 blink::mojom::UserActivationUpdateType update_type, 68 blink::mojom::UserActivationNotificationType notification_type) override; 69 void SetEmbeddingToken( 70 const base::UnguessableToken& embedding_token) override; 71 void SetPageFocus(bool is_focused) override; 72 void RenderFallbackContent() override; 73 void AddResourceTimingFromChild( 74 blink::mojom::ResourceTimingInfoPtr timing) override; 75 76 void ScrollRectToVisible( 77 const gfx::Rect& rect, 78 blink::mojom::ScrollIntoViewParamsPtr params) override; 79 void DidStartLoading() override; 80 void DidStopLoading() override; 81 void IntrinsicSizingInfoOfChildChanged( 82 blink::mojom::IntrinsicSizingInfoPtr sizing_info) override; DidSetFramePolicyHeaders(network::mojom::WebSandboxFlags sandbox_flags,const std::vector<blink::ParsedFeaturePolicyDeclaration> & parsed_feature_policy)83 void DidSetFramePolicyHeaders( 84 network::mojom::WebSandboxFlags sandbox_flags, 85 const std::vector<blink::ParsedFeaturePolicyDeclaration>& 86 parsed_feature_policy) override {} DidUpdateFramePolicy(const blink::FramePolicy & frame_policy)87 void DidUpdateFramePolicy(const blink::FramePolicy& frame_policy) override {} 88 void UpdateOpener(const base::Optional<base::UnguessableToken>& 89 opener_frame_token) override; 90 91 private: 92 void BindFrameHostReceiver(mojo::ScopedInterfaceEndpointHandle handle); 93 94 mojo::AssociatedReceiver<blink::mojom::RemoteFrame> receiver_{this}; 95 }; 96 97 } // namespace content 98 99 #endif // CONTENT_PUBLIC_TEST_FAKE_REMOTE_FRAME_H_ 100