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:
@@ -9,7 +9,7 @@
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
// $hash=b573d2840558cbf17908a16d3e92c3196c84b1c7$
|
||||
// $hash=f2b6ec1af9292dc180975a7566296b019c25772f$
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/browser_cpptoc.h"
|
||||
@@ -23,6 +23,22 @@ namespace {
|
||||
|
||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
int CEF_CALLBACK browser_is_valid(struct _cef_browser_t* self) {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
bool _retval = CefBrowserCppToC::Get(self)->IsValid();
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
struct _cef_browser_host_t* CEF_CALLBACK
|
||||
browser_get_host(struct _cef_browser_t* self) {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
@@ -378,6 +394,7 @@ void CEF_CALLBACK browser_get_frame_names(struct _cef_browser_t* self,
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefBrowserCppToC::CefBrowserCppToC() {
|
||||
GetStruct()->is_valid = browser_is_valid;
|
||||
GetStruct()->get_host = browser_get_host;
|
||||
GetStruct()->can_go_back = browser_can_go_back;
|
||||
GetStruct()->go_back = browser_go_back;
|
||||
|
@@ -9,7 +9,7 @@
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
// $hash=bdbe1ed03a5ab0ca22668417c329555a3b0d9cea$
|
||||
// $hash=69e482e4a20c97d54dc21f892f9e70e3d5d80f47$
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/client_cpptoc.h"
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "libcef_dll/cpptoc/drag_handler_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/find_handler_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/focus_handler_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/frame_handler_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/jsdialog_handler_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/keyboard_handler_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/life_span_handler_cpptoc.h"
|
||||
@@ -164,6 +165,22 @@ client_get_focus_handler(struct _cef_client_t* self) {
|
||||
return CefFocusHandlerCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
struct _cef_frame_handler_t* CEF_CALLBACK
|
||||
client_get_frame_handler(struct _cef_client_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefFrameHandler> _retval =
|
||||
CefClientCppToC::Get(self)->GetFrameHandler();
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefFrameHandlerCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
struct _cef_jsdialog_handler_t* CEF_CALLBACK
|
||||
client_get_jsdialog_handler(struct _cef_client_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
@@ -322,6 +339,7 @@ CefClientCppToC::CefClientCppToC() {
|
||||
GetStruct()->get_drag_handler = client_get_drag_handler;
|
||||
GetStruct()->get_find_handler = client_get_find_handler;
|
||||
GetStruct()->get_focus_handler = client_get_focus_handler;
|
||||
GetStruct()->get_frame_handler = client_get_frame_handler;
|
||||
GetStruct()->get_jsdialog_handler = client_get_jsdialog_handler;
|
||||
GetStruct()->get_keyboard_handler = client_get_keyboard_handler;
|
||||
GetStruct()->get_life_span_handler = client_get_life_span_handler;
|
||||
|
154
libcef_dll/cpptoc/frame_handler_cpptoc.cc
Normal file
154
libcef_dll/cpptoc/frame_handler_cpptoc.cc
Normal file
@@ -0,0 +1,154 @@
|
||||
// Copyright (c) 2021 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
// $hash=4d483792f68dc51dbc52722820a15795c4a1baad$
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/frame_handler_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/browser_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/frame_ctocpp.h"
|
||||
#include "libcef_dll/shutdown_checker.h"
|
||||
|
||||
namespace {
|
||||
|
||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
void CEF_CALLBACK
|
||||
frame_handler_on_frame_created(struct _cef_frame_handler_t* self,
|
||||
cef_browser_t* browser,
|
||||
cef_frame_t* frame) {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return;
|
||||
// Verify param: browser; type: refptr_diff
|
||||
DCHECK(browser);
|
||||
if (!browser)
|
||||
return;
|
||||
// Verify param: frame; type: refptr_diff
|
||||
DCHECK(frame);
|
||||
if (!frame)
|
||||
return;
|
||||
|
||||
// Execute
|
||||
CefFrameHandlerCppToC::Get(self)->OnFrameCreated(
|
||||
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame));
|
||||
}
|
||||
|
||||
void CEF_CALLBACK
|
||||
frame_handler_on_frame_attached(struct _cef_frame_handler_t* self,
|
||||
cef_browser_t* browser,
|
||||
cef_frame_t* frame) {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return;
|
||||
// Verify param: browser; type: refptr_diff
|
||||
DCHECK(browser);
|
||||
if (!browser)
|
||||
return;
|
||||
// Verify param: frame; type: refptr_diff
|
||||
DCHECK(frame);
|
||||
if (!frame)
|
||||
return;
|
||||
|
||||
// Execute
|
||||
CefFrameHandlerCppToC::Get(self)->OnFrameAttached(
|
||||
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame));
|
||||
}
|
||||
|
||||
void CEF_CALLBACK
|
||||
frame_handler_on_frame_detached(struct _cef_frame_handler_t* self,
|
||||
cef_browser_t* browser,
|
||||
cef_frame_t* frame) {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return;
|
||||
// Verify param: browser; type: refptr_diff
|
||||
DCHECK(browser);
|
||||
if (!browser)
|
||||
return;
|
||||
// Verify param: frame; type: refptr_diff
|
||||
DCHECK(frame);
|
||||
if (!frame)
|
||||
return;
|
||||
|
||||
// Execute
|
||||
CefFrameHandlerCppToC::Get(self)->OnFrameDetached(
|
||||
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame));
|
||||
}
|
||||
|
||||
void CEF_CALLBACK
|
||||
frame_handler_on_main_frame_changed(struct _cef_frame_handler_t* self,
|
||||
cef_browser_t* browser,
|
||||
cef_frame_t* old_frame,
|
||||
cef_frame_t* new_frame) {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return;
|
||||
// Verify param: browser; type: refptr_diff
|
||||
DCHECK(browser);
|
||||
if (!browser)
|
||||
return;
|
||||
// Unverified params: old_frame, new_frame
|
||||
|
||||
// Execute
|
||||
CefFrameHandlerCppToC::Get(self)->OnMainFrameChanged(
|
||||
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(old_frame),
|
||||
CefFrameCToCpp::Wrap(new_frame));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefFrameHandlerCppToC::CefFrameHandlerCppToC() {
|
||||
GetStruct()->on_frame_created = frame_handler_on_frame_created;
|
||||
GetStruct()->on_frame_attached = frame_handler_on_frame_attached;
|
||||
GetStruct()->on_frame_detached = frame_handler_on_frame_detached;
|
||||
GetStruct()->on_main_frame_changed = frame_handler_on_main_frame_changed;
|
||||
}
|
||||
|
||||
// DESTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefFrameHandlerCppToC::~CefFrameHandlerCppToC() {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
}
|
||||
|
||||
template <>
|
||||
CefRefPtr<CefFrameHandler> CefCppToCRefCounted<
|
||||
CefFrameHandlerCppToC,
|
||||
CefFrameHandler,
|
||||
cef_frame_handler_t>::UnwrapDerived(CefWrapperType type,
|
||||
cef_frame_handler_t* s) {
|
||||
NOTREACHED() << "Unexpected class type: " << type;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
CefWrapperType CefCppToCRefCounted<CefFrameHandlerCppToC,
|
||||
CefFrameHandler,
|
||||
cef_frame_handler_t>::kWrapperType =
|
||||
WT_FRAME_HANDLER;
|
37
libcef_dll/cpptoc/frame_handler_cpptoc.h
Normal file
37
libcef_dll/cpptoc/frame_handler_cpptoc.h
Normal file
@@ -0,0 +1,37 @@
|
||||
// Copyright (c) 2021 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
// $hash=b0c9c0566d85a387088c99a5497069bd1945f3b1$
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CPPTOC_FRAME_HANDLER_CPPTOC_H_
|
||||
#define CEF_LIBCEF_DLL_CPPTOC_FRAME_HANDLER_CPPTOC_H_
|
||||
#pragma once
|
||||
|
||||
#if !defined(WRAPPING_CEF_SHARED)
|
||||
#error This file can be included wrapper-side only
|
||||
#endif
|
||||
|
||||
#include "include/capi/cef_frame_handler_capi.h"
|
||||
#include "include/cef_frame_handler.h"
|
||||
#include "libcef_dll/cpptoc/cpptoc_ref_counted.h"
|
||||
|
||||
// Wrap a C++ class with a C structure.
|
||||
// This class may be instantiated and accessed wrapper-side only.
|
||||
class CefFrameHandlerCppToC : public CefCppToCRefCounted<CefFrameHandlerCppToC,
|
||||
CefFrameHandler,
|
||||
cef_frame_handler_t> {
|
||||
public:
|
||||
CefFrameHandlerCppToC();
|
||||
virtual ~CefFrameHandlerCppToC();
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_DLL_CPPTOC_FRAME_HANDLER_CPPTOC_H_
|
Reference in New Issue
Block a user