cef/libcef_dll/ctocpp/frame_handler_ctocpp.cc

159 lines
4.7 KiB
C++
Raw Normal View History

// Copyright (c) 2024 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=0074492ed580ccc06962a05b6c72bdabae182a51$
//
#include "libcef_dll/ctocpp/frame_handler_ctocpp.h"
#include "libcef_dll/cpptoc/browser_cpptoc.h"
#include "libcef_dll/cpptoc/frame_cpptoc.h"
#include "libcef_dll/shutdown_checker.h"
// VIRTUAL METHODS - Body may be edited by hand.
NO_SANITIZE("cfi-icall")
void CefFrameHandlerCToCpp::OnFrameCreated(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame) {
shutdown_checker::AssertNotShutdown();
cef_frame_handler_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, on_frame_created)) {
return;
}
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: browser; type: refptr_diff
DCHECK(browser.get());
if (!browser.get()) {
return;
}
// Verify param: frame; type: refptr_diff
DCHECK(frame.get());
if (!frame.get()) {
return;
}
// Execute
_struct->on_frame_created(_struct, CefBrowserCppToC::Wrap(browser),
CefFrameCppToC::Wrap(frame));
}
NO_SANITIZE("cfi-icall")
void CefFrameHandlerCToCpp::OnFrameAttached(CefRefPtr<CefBrowser> browser,
Fix draggable region update with BackForwardCache enabled (see issue #2421) When BackForwardCache is enabled and the user navigates the main frame back/forward a new RFH may be created for an existing main frame GlobalId value and CefFrameHostImpl (e.g. an object that was previously Detach()ed after main frame navigation called SetMainFrame, but for which RenderFrameDeleted was not subsequently called due to insertion in the BackForwardCache). In this case we can re-attach the new RFH to the existing main frame CefFrameHostImpl in RenderFrameHostStateChanged and resume processing of messages. Swapping back/forward to an existing (already loaded) renderer does not trigger new notifications for draggable regions (e.g. RenderFrameObserver:: DraggableRegionsChanged is not called by default). We therefore explicitly request an update of draggable regions by sending the DidStopLoading message to the renderer. A new |reattached| parameter is added to CefFrameHandler::OnFrameAttached to support identification of BackForwardCache usage by the client. To test with unit tests: Run `ceftests --gtest_filter=DraggableRegionsTest.DraggableRegionsCrossOrigin --enable-features=BackForwardCache` To test manually: 1. Run `cefclient --enable-features=BackForwardCache --use-views --url=http://tests/draggable`, note that draggable regions work. 2. Load https://www.google.com via the address bar, note that draggable regions are removed. 3. Go back to http://tests/draggable, note that draggable regions work. 4. Go forward to https://www.google.com, note that draggable regions are removed.
2021-09-15 13:40:08 +02:00
CefRefPtr<CefFrame> frame,
bool reattached) {
shutdown_checker::AssertNotShutdown();
cef_frame_handler_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, on_frame_attached)) {
return;
}
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: browser; type: refptr_diff
DCHECK(browser.get());
if (!browser.get()) {
return;
}
// Verify param: frame; type: refptr_diff
DCHECK(frame.get());
if (!frame.get()) {
return;
}
// Execute
_struct->on_frame_attached(_struct, CefBrowserCppToC::Wrap(browser),
Fix draggable region update with BackForwardCache enabled (see issue #2421) When BackForwardCache is enabled and the user navigates the main frame back/forward a new RFH may be created for an existing main frame GlobalId value and CefFrameHostImpl (e.g. an object that was previously Detach()ed after main frame navigation called SetMainFrame, but for which RenderFrameDeleted was not subsequently called due to insertion in the BackForwardCache). In this case we can re-attach the new RFH to the existing main frame CefFrameHostImpl in RenderFrameHostStateChanged and resume processing of messages. Swapping back/forward to an existing (already loaded) renderer does not trigger new notifications for draggable regions (e.g. RenderFrameObserver:: DraggableRegionsChanged is not called by default). We therefore explicitly request an update of draggable regions by sending the DidStopLoading message to the renderer. A new |reattached| parameter is added to CefFrameHandler::OnFrameAttached to support identification of BackForwardCache usage by the client. To test with unit tests: Run `ceftests --gtest_filter=DraggableRegionsTest.DraggableRegionsCrossOrigin --enable-features=BackForwardCache` To test manually: 1. Run `cefclient --enable-features=BackForwardCache --use-views --url=http://tests/draggable`, note that draggable regions work. 2. Load https://www.google.com via the address bar, note that draggable regions are removed. 3. Go back to http://tests/draggable, note that draggable regions work. 4. Go forward to https://www.google.com, note that draggable regions are removed.
2021-09-15 13:40:08 +02:00
CefFrameCppToC::Wrap(frame), reattached);
}
NO_SANITIZE("cfi-icall")
void CefFrameHandlerCToCpp::OnFrameDetached(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame) {
shutdown_checker::AssertNotShutdown();
cef_frame_handler_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, on_frame_detached)) {
return;
}
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: browser; type: refptr_diff
DCHECK(browser.get());
if (!browser.get()) {
return;
}
// Verify param: frame; type: refptr_diff
DCHECK(frame.get());
if (!frame.get()) {
return;
}
// Execute
_struct->on_frame_detached(_struct, CefBrowserCppToC::Wrap(browser),
CefFrameCppToC::Wrap(frame));
}
NO_SANITIZE("cfi-icall")
void CefFrameHandlerCToCpp::OnMainFrameChanged(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> old_frame,
CefRefPtr<CefFrame> new_frame) {
shutdown_checker::AssertNotShutdown();
cef_frame_handler_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, on_main_frame_changed)) {
return;
}
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: browser; type: refptr_diff
DCHECK(browser.get());
if (!browser.get()) {
return;
}
// Unverified params: old_frame, new_frame
// Execute
_struct->on_main_frame_changed(_struct, CefBrowserCppToC::Wrap(browser),
CefFrameCppToC::Wrap(old_frame),
CefFrameCppToC::Wrap(new_frame));
}
// CONSTRUCTOR - Do not edit by hand.
CefFrameHandlerCToCpp::CefFrameHandlerCToCpp() {}
// DESTRUCTOR - Do not edit by hand.
CefFrameHandlerCToCpp::~CefFrameHandlerCToCpp() {
shutdown_checker::AssertNotShutdown();
}
template <>
cef_frame_handler_t*
CefCToCppRefCounted<CefFrameHandlerCToCpp,
CefFrameHandler,
cef_frame_handler_t>::UnwrapDerived(CefWrapperType type,
CefFrameHandler* c) {
DCHECK(false) << "Unexpected class type: " << type;
return nullptr;
}
template <>
CefWrapperType CefCToCppRefCounted<CefFrameHandlerCToCpp,
CefFrameHandler,
cef_frame_handler_t>::kWrapperType =
WT_FRAME_HANDLER;