1 // Copyright 2021 The Chromium Embedded Framework 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 CEF_LIBCEF_BROWSER_BROWSER_FRAME_H_ 6 #define CEF_LIBCEF_BROWSER_BROWSER_FRAME_H_ 7 #pragma once 8 9 #include "libcef/browser/frame_host_impl.h" 10 #include "libcef/browser/frame_service_base.h" 11 12 #include "cef/libcef/common/mojom/cef.mojom.h" 13 #include "mojo/public/cpp/bindings/binder_map.h" 14 15 // Implementation of the BrowserFrame mojo interface. 16 // This is implemented separately from CefFrameHostImpl to better manage the 17 // association with the RenderFrameHost (which may be speculative, etc.), and so 18 // that messages are always routed to the most appropriate CefFrameHostImpl 19 // instance. Lifespan is tied to the RFH via FrameServiceBase. 20 class CefBrowserFrame 21 : public content::FrameServiceBase<cef::mojom::BrowserFrame> { 22 public: 23 CefBrowserFrame(content::RenderFrameHost* render_frame_host, 24 mojo::PendingReceiver<cef::mojom::BrowserFrame> receiver); 25 26 CefBrowserFrame(const CefBrowserFrame&) = delete; 27 CefBrowserFrame& operator=(const CefBrowserFrame&) = delete; 28 29 ~CefBrowserFrame() override; 30 31 // Called from the ContentBrowserClient method of the same name. 32 static void RegisterBrowserInterfaceBindersForFrame( 33 content::RenderFrameHost* render_frame_host, 34 mojo::BinderMapWithContext<content::RenderFrameHost*>* map); 35 36 private: 37 // cef::mojom::BrowserFrame methods: 38 void SendMessage(const std::string& name, base::Value arguments) override; 39 void FrameAttached(mojo::PendingRemote<cef::mojom::RenderFrame> render_frame, 40 bool reattached) override; 41 void DidFinishFrameLoad(const GURL& validated_url, 42 int32_t http_status_code) override; 43 void UpdateDraggableRegions( 44 absl::optional<std::vector<cef::mojom::DraggableRegionEntryPtr>> regions) 45 override; 46 47 // FrameServiceBase methods: ShouldCloseOnFinishNavigation()48 bool ShouldCloseOnFinishNavigation() const override { return false; } 49 50 CefRefPtr<CefFrameHostImpl> GetFrameHost( 51 bool prefer_speculative = false) const; 52 }; 53 54 #endif // CEF_LIBCEF_BROWSER_BROWSER_FRAME_H_ 55