mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add CefFrameHandler callbacks for tracking CefFrame lifespan (see issue #2421)
See the new cef_frame_handler.h for complete usage documentation. This change includes the following related enhancements: - The newly added CefBrowser::IsValid method will return false (in the browser process) after CefLifeSpanHandler::OnBeforeClose is called. - CefBrowser::GetMainFrame will return a valid object (in the browser process) until after CefLifeSpanHandler::OnBeforeClose is called. - The main frame object will change during cross-origin navigation or re-navigation after renderer process termination. During that time, GetMainFrame will return the new/pending frame (in the browser process) and any messages that arrive for the new/pending frame will be correctly attributed in OnProcessMessageReceived. - Commands to be executed in the renderer process that may fail during early frame initialization (ExecuteJavaScript, LoadRequest, etc.) will now be queued until after the JavaScript context for the frame has been created. - Logging has been added for any commands that are dropped because they arrived after frame detachment.
This commit is contained in:
@@ -32,20 +32,14 @@ class CefBrowserHostBase;
|
||||
// or retrieved via CefBrowerInfo.
|
||||
class CefFrameHostImpl : public CefFrame, public cef::mojom::BrowserFrame {
|
||||
public:
|
||||
// Create a temporary frame.
|
||||
// Create a temporary sub-frame.
|
||||
CefFrameHostImpl(scoped_refptr<CefBrowserInfo> browser_info,
|
||||
bool is_main_frame,
|
||||
int64_t parent_frame_id);
|
||||
|
||||
// Create a frame backed by a RFH and owned by CefBrowserInfo.
|
||||
CefFrameHostImpl(scoped_refptr<CefBrowserInfo> browser_info,
|
||||
content::RenderFrameHost* render_frame_host);
|
||||
|
||||
// Update an existing main frame object on creation or for same-origin
|
||||
// navigations. A new CefFrameHostImpl will be created for cross-origin
|
||||
// navigations.
|
||||
void SetRenderFrameHost(content::RenderFrameHost* host);
|
||||
|
||||
~CefFrameHostImpl() override;
|
||||
|
||||
// CefFrame methods
|
||||
@@ -80,6 +74,8 @@ class CefFrameHostImpl : public CefFrame, public cef::mojom::BrowserFrame {
|
||||
void SendProcessMessage(CefProcessId target_process,
|
||||
CefRefPtr<CefProcessMessage> message) override;
|
||||
|
||||
bool is_temporary() const { return frame_id_ == kInvalidFrameId; }
|
||||
|
||||
void SetFocused(bool focused);
|
||||
void RefreshAttributes();
|
||||
|
||||
@@ -147,6 +143,7 @@ class CefFrameHostImpl : public CefFrame, public cef::mojom::BrowserFrame {
|
||||
|
||||
private:
|
||||
int64 GetFrameId() const;
|
||||
scoped_refptr<CefBrowserInfo> GetBrowserInfo() const;
|
||||
CefRefPtr<CefBrowserHostBase> GetBrowserHostBase() const;
|
||||
|
||||
// Returns the remote RenderFrame object.
|
||||
@@ -156,7 +153,8 @@ class CefFrameHostImpl : public CefFrame, public cef::mojom::BrowserFrame {
|
||||
// Send an action to the remote RenderFrame. This will queue the action if the
|
||||
// remote frame is not yet attached.
|
||||
using RenderFrameAction = base::OnceCallback<void(const RenderFrameType&)>;
|
||||
void SendToRenderFrame(RenderFrameAction action);
|
||||
void SendToRenderFrame(const std::string& function_name,
|
||||
RenderFrameAction action);
|
||||
|
||||
const bool is_main_frame_;
|
||||
|
||||
@@ -175,7 +173,7 @@ class CefFrameHostImpl : public CefFrame, public cef::mojom::BrowserFrame {
|
||||
|
||||
bool is_attached_ = false;
|
||||
|
||||
std::queue<RenderFrameAction> queued_actions_;
|
||||
std::queue<std::pair<std::string, RenderFrameAction>> queued_actions_;
|
||||
|
||||
mojo::Remote<cef::mojom::RenderFrame> render_frame_;
|
||||
|
||||
|
Reference in New Issue
Block a user