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_LOCAL_FRAME_HOST_INTERCEPTOR_H_ 6 #define CONTENT_PUBLIC_TEST_LOCAL_FRAME_HOST_INTERCEPTOR_H_ 7 8 #include "mojo/public/cpp/bindings/associated_receiver.h" 9 #include "mojo/public/cpp/bindings/associated_remote.h" 10 #include "third_party/blink/public/mojom/frame/frame.mojom-test-utils.h" 11 #include "third_party/blink/public/mojom/frame/frame.mojom.h" 12 13 namespace blink { 14 class AssociatedInterfaceProvider; 15 } // namespace blink 16 17 namespace content { 18 19 // This class can be used to intercept mojo LocalFrameHost IPC messages being 20 // sent to the browser on the renderer side before they are sent to the browser. 21 class LocalFrameHostInterceptor 22 : public blink::mojom::LocalFrameHostInterceptorForTesting { 23 public: 24 explicit LocalFrameHostInterceptor(blink::AssociatedInterfaceProvider*); 25 ~LocalFrameHostInterceptor() override; 26 27 blink::mojom::LocalFrameHost* GetForwardingInterface() override; 28 29 private: 30 void BindFrameHostReceiver(mojo::ScopedInterfaceEndpointHandle handle); 31 32 mojo::AssociatedReceiver<blink::mojom::LocalFrameHost> receiver_{this}; 33 mojo::AssociatedRemote<blink::mojom::LocalFrameHost> local_frame_host_remote_; 34 }; 35 36 } // namespace content 37 38 #endif // CONTENT_PUBLIC_TEST_LOCAL_FRAME_HOST_INTERCEPTOR_H_ 39