From 1cd3f8a3afbe800dd4406b69960eb8e1aefa6d77 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Tue, 30 Mar 2021 09:16:51 -0700 Subject: [PATCH] Move GetPrintHandler to CefClient (see issue #2196) This new location is preferred because we now know the associated CefBrowser for all CefPrintHandler callbacks. --- .../capi/cef_browser_process_handler_capi.h | 10 +---- include/capi/cef_client_capi.h | 10 ++++- include/capi/cef_print_handler_capi.h | 3 +- include/cef_api_hash.h | 8 ++-- include/cef_browser_process_handler.h | 8 ---- include/cef_client.h | 8 ++++ include/cef_print_handler.h | 3 +- libcef/browser/printing/print_dialog_linux.cc | 37 +++++++------------ .../cpptoc/browser_process_handler_cpptoc.cc | 21 +---------- libcef_dll/cpptoc/client_cpptoc.cc | 20 +++++++++- libcef_dll/cpptoc/print_handler_cpptoc.cc | 11 ++++-- .../ctocpp/browser_process_handler_ctocpp.cc | 18 +-------- .../ctocpp/browser_process_handler_ctocpp.h | 3 +- libcef_dll/ctocpp/client_ctocpp.cc | 18 ++++++++- libcef_dll/ctocpp/client_ctocpp.h | 3 +- libcef_dll/ctocpp/print_handler_ctocpp.cc | 14 +++++-- libcef_dll/ctocpp/print_handler_ctocpp.h | 5 ++- .../browser/client_app_delegates_browser.cc | 13 ------- tests/cefclient/browser/client_handler.cc | 1 + tests/cefclient/browser/client_handler.h | 5 +++ tests/cefclient/browser/print_handler_gtk.cc | 3 +- tests/cefclient/browser/print_handler_gtk.h | 3 +- tests/ceftests/client_app_delegates.cc | 5 --- tests/shared/browser/client_app_browser.cc | 2 - tests/shared/browser/client_app_browser.h | 9 ----- 25 files changed, 112 insertions(+), 129 deletions(-) diff --git a/include/capi/cef_browser_process_handler_capi.h b/include/capi/cef_browser_process_handler_capi.h index 27e52fb1a..87c405802 100644 --- a/include/capi/cef_browser_process_handler_capi.h +++ b/include/capi/cef_browser_process_handler_capi.h @@ -33,7 +33,7 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // -// $hash=f0cd169568e9ea5bcc8bf2aa891691b76c05356d$ +// $hash=54c5210924095c7e43173a2843bd28729645922b$ // #ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_ @@ -43,7 +43,6 @@ #include "include/capi/cef_base_capi.h" #include "include/capi/cef_client_capi.h" #include "include/capi/cef_command_line_capi.h" -#include "include/capi/cef_print_handler_capi.h" #include "include/capi/cef_values_capi.h" #ifdef __cplusplus @@ -98,13 +97,6 @@ typedef struct _cef_browser_process_handler_t { struct _cef_browser_process_handler_t* self, struct _cef_command_line_t* command_line); - /// - // Return the handler for printing on Linux. If a print handler is not - // provided then printing will not be supported on the Linux platform. - /// - struct _cef_print_handler_t*(CEF_CALLBACK* get_print_handler)( - struct _cef_browser_process_handler_t* self); - /// // Called from any thread when work has been scheduled for the browser process // main (UI) thread. This callback is used in combination with CefSettings. diff --git a/include/capi/cef_client_capi.h b/include/capi/cef_client_capi.h index d30243b07..8351d9ae7 100644 --- a/include/capi/cef_client_capi.h +++ b/include/capi/cef_client_capi.h @@ -33,7 +33,7 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // -// $hash=4cfcac55d2a1dee466a2a0753f30fb34a78ef3b2$ +// $hash=14eca959988209ba8f95037a47192fd50d64f2f1$ // #ifndef CEF_INCLUDE_CAPI_CEF_CLIENT_CAPI_H_ @@ -53,6 +53,7 @@ #include "include/capi/cef_keyboard_handler_capi.h" #include "include/capi/cef_life_span_handler_capi.h" #include "include/capi/cef_load_handler_capi.h" +#include "include/capi/cef_print_handler_capi.h" #include "include/capi/cef_process_message_capi.h" #include "include/capi/cef_render_handler_capi.h" #include "include/capi/cef_request_handler_capi.h" @@ -146,6 +147,13 @@ typedef struct _cef_client_t { struct _cef_load_handler_t*(CEF_CALLBACK* get_load_handler)( struct _cef_client_t* self); + /// + // Return the handler for printing on Linux. If a print handler is not + // provided then printing will not be supported on the Linux platform. + /// + struct _cef_print_handler_t*(CEF_CALLBACK* get_print_handler)( + struct _cef_client_t* self); + /// // Return the handler for off-screen rendering events. /// diff --git a/include/capi/cef_print_handler_capi.h b/include/capi/cef_print_handler_capi.h index 958eb31bc..a3d7d3cf9 100644 --- a/include/capi/cef_print_handler_capi.h +++ b/include/capi/cef_print_handler_capi.h @@ -33,7 +33,7 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // -// $hash=54ed1e16c5c1d133bcd097350c5f5871228efd4f$ +// $hash=84fc58b3898f25476d9cdd260553390ba5e0b30b$ // #ifndef CEF_INCLUDE_CAPI_CEF_PRINT_HANDLER_CAPI_H_ @@ -148,6 +148,7 @@ typedef struct _cef_print_handler_t { /// cef_size_t(CEF_CALLBACK* get_pdf_paper_size)( struct _cef_print_handler_t* self, + struct _cef_browser_t* browser, int device_units_per_inch); } cef_print_handler_t; diff --git a/include/cef_api_hash.h b/include/cef_api_hash.h index dd6592521..708f25457 100644 --- a/include/cef_api_hash.h +++ b/include/cef_api_hash.h @@ -42,13 +42,13 @@ // way that may cause binary incompatibility with other builds. The universal // hash value will change if any platform is affected whereas the platform hash // values will change only if that particular platform is affected. -#define CEF_API_HASH_UNIVERSAL "730ab5758854ad187e677f5fbdce57df8e8f4f5e" +#define CEF_API_HASH_UNIVERSAL "4291ac099ef9b3f618e9343acf4deb7e36bb5508" #if defined(OS_WIN) -#define CEF_API_HASH_PLATFORM "747d77b684a4b579cd2c0420a7323d236f632741" +#define CEF_API_HASH_PLATFORM "0637d7a76f9339dc446c364b3fc7c1a317b0460a" #elif defined(OS_MAC) -#define CEF_API_HASH_PLATFORM "fe46b846c15428ca6b30c817778f710b810fba7b" +#define CEF_API_HASH_PLATFORM "83c4d72b1190a35bac919806c7e9b27b6a1efcf6" #elif defined(OS_LINUX) -#define CEF_API_HASH_PLATFORM "57af9a254cb00b2a3cec85238942ee87fa53ef9d" +#define CEF_API_HASH_PLATFORM "f57499977f5166862b1f39ce22374b8e506b317b" #endif #ifdef __cplusplus diff --git a/include/cef_browser_process_handler.h b/include/cef_browser_process_handler.h index c82b93deb..e55c1430c 100644 --- a/include/cef_browser_process_handler.h +++ b/include/cef_browser_process_handler.h @@ -41,7 +41,6 @@ #include "include/cef_base.h" #include "include/cef_client.h" #include "include/cef_command_line.h" -#include "include/cef_print_handler.h" #include "include/cef_values.h" /// @@ -86,13 +85,6 @@ class CefBrowserProcessHandler : public virtual CefBaseRefCounted { virtual void OnBeforeChildProcessLaunch( CefRefPtr command_line) {} - /// - // Return the handler for printing on Linux. If a print handler is not - // provided then printing will not be supported on the Linux platform. - /// - /*--cef()--*/ - virtual CefRefPtr GetPrintHandler() { return nullptr; } - /// // Called from any thread when work has been scheduled for the browser process // main (UI) thread. This callback is used in combination with CefSettings. diff --git a/include/cef_client.h b/include/cef_client.h index ada7a6a86..20e5ede62 100644 --- a/include/cef_client.h +++ b/include/cef_client.h @@ -51,6 +51,7 @@ #include "include/cef_keyboard_handler.h" #include "include/cef_life_span_handler.h" #include "include/cef_load_handler.h" +#include "include/cef_print_handler.h" #include "include/cef_process_message.h" #include "include/cef_render_handler.h" #include "include/cef_request_handler.h" @@ -139,6 +140,13 @@ class CefClient : public virtual CefBaseRefCounted { /*--cef()--*/ virtual CefRefPtr GetLoadHandler() { return nullptr; } + /// + // Return the handler for printing on Linux. If a print handler is not + // provided then printing will not be supported on the Linux platform. + /// + /*--cef()--*/ + virtual CefRefPtr GetPrintHandler() { return nullptr; } + /// // Return the handler for off-screen rendering events. /// diff --git a/include/cef_print_handler.h b/include/cef_print_handler.h index c668bd4cf..950764acd 100644 --- a/include/cef_print_handler.h +++ b/include/cef_print_handler.h @@ -133,7 +133,8 @@ class CefPrintHandler : public virtual CefBaseRefCounted { // CefBrowserHost::PrintToPDF(). /// /*--cef()--*/ - virtual CefSize GetPdfPaperSize(int device_units_per_inch) { + virtual CefSize GetPdfPaperSize(CefRefPtr browser, + int device_units_per_inch) { return CefSize(); } }; diff --git a/libcef/browser/printing/print_dialog_linux.cc b/libcef/browser/printing/print_dialog_linux.cc index 6ef97ad9f..4e3395285 100644 --- a/libcef/browser/printing/print_dialog_linux.cc +++ b/libcef/browser/printing/print_dialog_linux.cc @@ -105,18 +105,15 @@ gfx::Size CefPrintDialogLinux::GetPdfPaperSize( gfx::Size size; - CefRefPtr app = CefAppManager::Get()->GetApplication(); - if (app.get()) { - CefRefPtr browser_handler = - app->GetBrowserProcessHandler(); - if (browser_handler.get()) { - CefRefPtr handler = browser_handler->GetPrintHandler(); - if (handler.get()) { - const printing::PrintSettings& settings = context->settings(); - CefSize cef_size = - handler->GetPdfPaperSize(settings.device_units_per_inch()); - size.SetSize(cef_size.width, cef_size.height); - } + auto browser = extensions::GetOwnerBrowserForFrameRoute( + context->render_process_id(), context->render_frame_id(), nullptr); + DCHECK(browser); + if (browser && browser->GetClient()) { + if (auto handler = browser->GetClient()->GetPrintHandler()) { + const printing::PrintSettings& settings = context->settings(); + CefSize cef_size = handler->GetPdfPaperSize( + browser.get(), settings.device_units_per_inch()); + size.SetSize(cef_size.width, cef_size.height); } } @@ -131,11 +128,9 @@ gfx::Size CefPrintDialogLinux::GetPdfPaperSize( void CefPrintDialogLinux::OnPrintStart(CefRefPtr browser) { CEF_REQUIRE_UIT(); DCHECK(browser); - if (auto app = CefAppManager::Get()->GetApplication()) { - if (auto browser_handler = app->GetBrowserProcessHandler()) { - if (auto print_handler = browser_handler->GetPrintHandler()) { - print_handler->OnPrintStart(browser.get()); - } + if (browser && browser->GetClient()) { + if (auto handler = browser->GetClient()->GetPrintHandler()) { + handler->OnPrintStart(browser.get()); } } } @@ -235,12 +230,8 @@ void CefPrintDialogLinux::SetHandler() { if (handler_.get()) return; - CefRefPtr app = CefAppManager::Get()->GetApplication(); - if (app.get()) { - CefRefPtr browser_handler = - app->GetBrowserProcessHandler(); - if (browser_handler.get()) - handler_ = browser_handler->GetPrintHandler(); + if (browser_ && browser_->GetClient()) { + handler_ = browser_->GetClient()->GetPrintHandler(); } } diff --git a/libcef_dll/cpptoc/browser_process_handler_cpptoc.cc b/libcef_dll/cpptoc/browser_process_handler_cpptoc.cc index 1e82f1547..26a26e844 100644 --- a/libcef_dll/cpptoc/browser_process_handler_cpptoc.cc +++ b/libcef_dll/cpptoc/browser_process_handler_cpptoc.cc @@ -9,12 +9,11 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=380946147815033eba2f98d612b723ef676ee711$ +// $hash=deb93b82f75f2e3f59cccf3a82ce8e47b400f5c1$ // #include "libcef_dll/cpptoc/browser_process_handler_cpptoc.h" #include "libcef_dll/cpptoc/client_cpptoc.h" -#include "libcef_dll/cpptoc/print_handler_cpptoc.h" #include "libcef_dll/ctocpp/command_line_ctocpp.h" #include "libcef_dll/transfer_util.h" @@ -89,23 +88,6 @@ void CEF_CALLBACK browser_process_handler_on_before_child_process_launch( CefCommandLineCToCpp::Wrap(command_line)); } -struct _cef_print_handler_t* CEF_CALLBACK -browser_process_handler_get_print_handler( - struct _cef_browser_process_handler_t* self) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return NULL; - - // Execute - CefRefPtr _retval = - CefBrowserProcessHandlerCppToC::Get(self)->GetPrintHandler(); - - // Return type: refptr_same - return CefPrintHandlerCppToC::Wrap(_retval); -} - void CEF_CALLBACK browser_process_handler_on_schedule_message_pump_work( struct _cef_browser_process_handler_t* self, int64 delay_ms) { @@ -147,7 +129,6 @@ CefBrowserProcessHandlerCppToC::CefBrowserProcessHandlerCppToC() { browser_process_handler_on_context_initialized; GetStruct()->on_before_child_process_launch = browser_process_handler_on_before_child_process_launch; - GetStruct()->get_print_handler = browser_process_handler_get_print_handler; GetStruct()->on_schedule_message_pump_work = browser_process_handler_on_schedule_message_pump_work; GetStruct()->get_default_client = browser_process_handler_get_default_client; diff --git a/libcef_dll/cpptoc/client_cpptoc.cc b/libcef_dll/cpptoc/client_cpptoc.cc index 7dd2586bc..a8c9c4bed 100644 --- a/libcef_dll/cpptoc/client_cpptoc.cc +++ b/libcef_dll/cpptoc/client_cpptoc.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=59d3b3767f39bd3078bdeeeca09f0f29486b53f6$ +// $hash=bdbe1ed03a5ab0ca22668417c329555a3b0d9cea$ // #include "libcef_dll/cpptoc/client_cpptoc.h" @@ -25,6 +25,7 @@ #include "libcef_dll/cpptoc/keyboard_handler_cpptoc.h" #include "libcef_dll/cpptoc/life_span_handler_cpptoc.h" #include "libcef_dll/cpptoc/load_handler_cpptoc.h" +#include "libcef_dll/cpptoc/print_handler_cpptoc.h" #include "libcef_dll/cpptoc/render_handler_cpptoc.h" #include "libcef_dll/cpptoc/request_handler_cpptoc.h" #include "libcef_dll/ctocpp/browser_ctocpp.h" @@ -227,6 +228,22 @@ client_get_load_handler(struct _cef_client_t* self) { return CefLoadHandlerCppToC::Wrap(_retval); } +struct _cef_print_handler_t* CEF_CALLBACK +client_get_print_handler(struct _cef_client_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = + CefClientCppToC::Get(self)->GetPrintHandler(); + + // Return type: refptr_same + return CefPrintHandlerCppToC::Wrap(_retval); +} + struct _cef_render_handler_t* CEF_CALLBACK client_get_render_handler(struct _cef_client_t* self) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -309,6 +326,7 @@ CefClientCppToC::CefClientCppToC() { GetStruct()->get_keyboard_handler = client_get_keyboard_handler; GetStruct()->get_life_span_handler = client_get_life_span_handler; GetStruct()->get_load_handler = client_get_load_handler; + GetStruct()->get_print_handler = client_get_print_handler; GetStruct()->get_render_handler = client_get_render_handler; GetStruct()->get_request_handler = client_get_request_handler; GetStruct()->on_process_message_received = client_on_process_message_received; diff --git a/libcef_dll/cpptoc/print_handler_cpptoc.cc b/libcef_dll/cpptoc/print_handler_cpptoc.cc index 1788d5433..ebfdcd512 100644 --- a/libcef_dll/cpptoc/print_handler_cpptoc.cc +++ b/libcef_dll/cpptoc/print_handler_cpptoc.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=d07c33f1e14a7d42feac46fa1bf27dbfab50c97f$ +// $hash=15d1e044a5bc40ca25c72f070a9b996907c4c0cb$ // #include "libcef_dll/cpptoc/print_handler_cpptoc.h" @@ -161,6 +161,7 @@ print_handler_on_print_reset(struct _cef_print_handler_t* self, cef_size_t CEF_CALLBACK print_handler_get_pdf_paper_size(struct _cef_print_handler_t* self, + cef_browser_t* browser, int device_units_per_inch) { shutdown_checker::AssertNotShutdown(); @@ -169,10 +170,14 @@ print_handler_get_pdf_paper_size(struct _cef_print_handler_t* self, DCHECK(self); if (!self) return CefSize(); + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return CefSize(); // Execute - cef_size_t _retval = - CefPrintHandlerCppToC::Get(self)->GetPdfPaperSize(device_units_per_inch); + cef_size_t _retval = CefPrintHandlerCppToC::Get(self)->GetPdfPaperSize( + CefBrowserCToCpp::Wrap(browser), device_units_per_inch); // Return type: simple return _retval; diff --git a/libcef_dll/ctocpp/browser_process_handler_ctocpp.cc b/libcef_dll/ctocpp/browser_process_handler_ctocpp.cc index 961ad5a80..d095739c9 100644 --- a/libcef_dll/ctocpp/browser_process_handler_ctocpp.cc +++ b/libcef_dll/ctocpp/browser_process_handler_ctocpp.cc @@ -9,13 +9,12 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=a2e25ad75313e9b264bce1b1525c7766e625ea17$ +// $hash=f70d18a15f7c01ce5171d781577312fa7d2fb93b$ // #include "libcef_dll/ctocpp/browser_process_handler_ctocpp.h" #include "libcef_dll/cpptoc/command_line_cpptoc.h" #include "libcef_dll/ctocpp/client_ctocpp.h" -#include "libcef_dll/ctocpp/print_handler_ctocpp.h" #include "libcef_dll/transfer_util.h" // VIRTUAL METHODS - Body may be edited by hand. @@ -82,21 +81,6 @@ void CefBrowserProcessHandlerCToCpp::OnBeforeChildProcessLaunch( _struct, CefCommandLineCppToC::Wrap(command_line)); } -NO_SANITIZE("cfi-icall") -CefRefPtr CefBrowserProcessHandlerCToCpp::GetPrintHandler() { - cef_browser_process_handler_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, get_print_handler)) - return nullptr; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - cef_print_handler_t* _retval = _struct->get_print_handler(_struct); - - // Return type: refptr_same - return CefPrintHandlerCToCpp::Wrap(_retval); -} - NO_SANITIZE("cfi-icall") void CefBrowserProcessHandlerCToCpp::OnScheduleMessagePumpWork(int64 delay_ms) { cef_browser_process_handler_t* _struct = GetStruct(); diff --git a/libcef_dll/ctocpp/browser_process_handler_ctocpp.h b/libcef_dll/ctocpp/browser_process_handler_ctocpp.h index d72e7c629..a411c0535 100644 --- a/libcef_dll/ctocpp/browser_process_handler_ctocpp.h +++ b/libcef_dll/ctocpp/browser_process_handler_ctocpp.h @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=0c4282bac5261394776306ab376b8839a1690a57$ +// $hash=e6881fab8b5f8b46c08f0b472abdc8508edaed52$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_BROWSER_PROCESS_HANDLER_CTOCPP_H_ @@ -41,7 +41,6 @@ class CefBrowserProcessHandlerCToCpp void OnContextInitialized() override; void OnBeforeChildProcessLaunch( CefRefPtr command_line) override; - CefRefPtr GetPrintHandler() override; void OnScheduleMessagePumpWork(int64 delay_ms) override; CefRefPtr GetDefaultClient() override; }; diff --git a/libcef_dll/ctocpp/client_ctocpp.cc b/libcef_dll/ctocpp/client_ctocpp.cc index 8604a1716..d002e41c9 100644 --- a/libcef_dll/ctocpp/client_ctocpp.cc +++ b/libcef_dll/ctocpp/client_ctocpp.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=e82aefc18c6f1869a4ff61b21e040dc2df69bfc9$ +// $hash=19d21957d8b7f66de8c88b9085abb2a08718582d$ // #include "libcef_dll/ctocpp/client_ctocpp.h" @@ -28,6 +28,7 @@ #include "libcef_dll/ctocpp/keyboard_handler_ctocpp.h" #include "libcef_dll/ctocpp/life_span_handler_ctocpp.h" #include "libcef_dll/ctocpp/load_handler_ctocpp.h" +#include "libcef_dll/ctocpp/print_handler_ctocpp.h" #include "libcef_dll/ctocpp/render_handler_ctocpp.h" #include "libcef_dll/ctocpp/request_handler_ctocpp.h" @@ -214,6 +215,21 @@ CefRefPtr CefClientCToCpp::GetLoadHandler() { return CefLoadHandlerCToCpp::Wrap(_retval); } +NO_SANITIZE("cfi-icall") +CefRefPtr CefClientCToCpp::GetPrintHandler() { + cef_client_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_print_handler)) + return nullptr; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_print_handler_t* _retval = _struct->get_print_handler(_struct); + + // Return type: refptr_same + return CefPrintHandlerCToCpp::Wrap(_retval); +} + NO_SANITIZE("cfi-icall") CefRefPtr CefClientCToCpp::GetRenderHandler() { cef_client_t* _struct = GetStruct(); diff --git a/libcef_dll/ctocpp/client_ctocpp.h b/libcef_dll/ctocpp/client_ctocpp.h index 1f78e391f..1447c181f 100644 --- a/libcef_dll/ctocpp/client_ctocpp.h +++ b/libcef_dll/ctocpp/client_ctocpp.h @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=8395e101ac220a443a9d26dc302258185e6e33ea$ +// $hash=a640d4535140448a46340432470dbd1ef4f90b69$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_CLIENT_CTOCPP_H_ @@ -45,6 +45,7 @@ class CefClientCToCpp CefRefPtr GetKeyboardHandler() override; CefRefPtr GetLifeSpanHandler() override; CefRefPtr GetLoadHandler() override; + CefRefPtr GetPrintHandler() override; CefRefPtr GetRenderHandler() override; CefRefPtr GetRequestHandler() override; bool OnProcessMessageReceived(CefRefPtr browser, diff --git a/libcef_dll/ctocpp/print_handler_ctocpp.cc b/libcef_dll/ctocpp/print_handler_ctocpp.cc index b903f11a5..8f2025964 100644 --- a/libcef_dll/ctocpp/print_handler_ctocpp.cc +++ b/libcef_dll/ctocpp/print_handler_ctocpp.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=af80c710cd11dc6a92ca2ed5923ff4787ee97e86$ +// $hash=5c1f65c2b1b111d248d5b7b27ddcb59b06594923$ // #include "libcef_dll/ctocpp/print_handler_ctocpp.h" @@ -159,7 +159,8 @@ void CefPrintHandlerCToCpp::OnPrintReset(CefRefPtr browser) { } NO_SANITIZE("cfi-icall") -CefSize CefPrintHandlerCToCpp::GetPdfPaperSize(int device_units_per_inch) { +CefSize CefPrintHandlerCToCpp::GetPdfPaperSize(CefRefPtr browser, + int device_units_per_inch) { shutdown_checker::AssertNotShutdown(); cef_print_handler_t* _struct = GetStruct(); @@ -168,9 +169,14 @@ CefSize CefPrintHandlerCToCpp::GetPdfPaperSize(int device_units_per_inch) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return CefSize(); + // Execute - cef_size_t _retval = - _struct->get_pdf_paper_size(_struct, device_units_per_inch); + cef_size_t _retval = _struct->get_pdf_paper_size( + _struct, CefBrowserCppToC::Wrap(browser), device_units_per_inch); // Return type: simple return _retval; diff --git a/libcef_dll/ctocpp/print_handler_ctocpp.h b/libcef_dll/ctocpp/print_handler_ctocpp.h index b238de9f0..204d9e504 100644 --- a/libcef_dll/ctocpp/print_handler_ctocpp.h +++ b/libcef_dll/ctocpp/print_handler_ctocpp.h @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=0ef71e42f869e9eaa0b87f8fd90e2f80c3553e2f$ +// $hash=5592945a1621a79ccff78a053a98e68bf08d9a8b$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_PRINT_HANDLER_CTOCPP_H_ @@ -46,7 +46,8 @@ class CefPrintHandlerCToCpp : public CefCToCppRefCounted callback) override; void OnPrintReset(CefRefPtr browser) override; - CefSize GetPdfPaperSize(int device_units_per_inch) override; + CefSize GetPdfPaperSize(CefRefPtr browser, + int device_units_per_inch) override; }; #endif // CEF_LIBCEF_DLL_CTOCPP_PRINT_HANDLER_CTOCPP_H_ diff --git a/tests/cefclient/browser/client_app_delegates_browser.cc b/tests/cefclient/browser/client_app_delegates_browser.cc index 4594818f8..4a192917d 100644 --- a/tests/cefclient/browser/client_app_delegates_browser.cc +++ b/tests/cefclient/browser/client_app_delegates_browser.cc @@ -6,10 +6,6 @@ #include "tests/cefclient/browser/client_browser.h" -#if defined(OS_LINUX) -#include "tests/cefclient/browser/print_handler_gtk.h" -#endif - namespace client { // static @@ -17,13 +13,4 @@ void ClientAppBrowser::CreateDelegates(DelegateSet& delegates) { browser::CreateDelegates(delegates); } -// static -CefRefPtr ClientAppBrowser::CreatePrintHandler() { -#if defined(OS_LINUX) - return new ClientPrintHandlerGtk(); -#else - return nullptr; -#endif -} - } // namespace client diff --git a/tests/cefclient/browser/client_handler.cc b/tests/cefclient/browser/client_handler.cc index 1916f5529..8828bac51 100644 --- a/tests/cefclient/browser/client_handler.cc +++ b/tests/cefclient/browser/client_handler.cc @@ -259,6 +259,7 @@ ClientHandler::ClientHandler(Delegate* delegate, #if defined(OS_LINUX) // Provide the GTK-based dialog implementation on Linux. dialog_handler_ = new ClientDialogHandlerGtk(); + print_handler_ = new ClientPrintHandlerGtk(); #endif resource_manager_ = new CefResourceManager(); diff --git a/tests/cefclient/browser/client_handler.h b/tests/cefclient/browser/client_handler.h index 1be9c4d5d..35dde3702 100644 --- a/tests/cefclient/browser/client_handler.h +++ b/tests/cefclient/browser/client_handler.h @@ -18,6 +18,7 @@ #if defined(OS_LINUX) #include "tests/cefclient/browser/dialog_handler_gtk.h" +#include "tests/cefclient/browser/print_handler_gtk.h" #endif namespace client { @@ -122,6 +123,9 @@ class ClientHandler : public CefClient, CefRefPtr GetJSDialogHandler() OVERRIDE { return dialog_handler_; } + CefRefPtr GetPrintHandler() OVERRIDE { + return print_handler_; + } #endif // CefContextMenuHandler methods @@ -372,6 +376,7 @@ class ClientHandler : public CefClient, #if defined(OS_LINUX) // Custom dialog handler for GTK. CefRefPtr dialog_handler_; + CefRefPtr print_handler_; #endif // Handles the browser side of query routing. The renderer side is handled diff --git a/tests/cefclient/browser/print_handler_gtk.cc b/tests/cefclient/browser/print_handler_gtk.cc index 2dc7b4732..69f3a0514 100644 --- a/tests/cefclient/browser/print_handler_gtk.cc +++ b/tests/cefclient/browser/print_handler_gtk.cc @@ -637,7 +637,8 @@ void ClientPrintHandlerGtk::OnPrintReset(CefRefPtr browser) { print_handler_map_.erase(it); } -CefSize ClientPrintHandlerGtk::GetPdfPaperSize(int device_units_per_inch) { +CefSize ClientPrintHandlerGtk::GetPdfPaperSize(CefRefPtr browser, + int device_units_per_inch) { CEF_REQUIRE_UI_THREAD(); ScopedGdkThreadsEnter scoped_gdk_threads; diff --git a/tests/cefclient/browser/print_handler_gtk.h b/tests/cefclient/browser/print_handler_gtk.h index 857b8c724..0aa8f85a2 100644 --- a/tests/cefclient/browser/print_handler_gtk.h +++ b/tests/cefclient/browser/print_handler_gtk.h @@ -31,7 +31,8 @@ class ClientPrintHandlerGtk : public CefPrintHandler { const CefString& pdf_file_path, CefRefPtr callback) OVERRIDE; void OnPrintReset(CefRefPtr browser) OVERRIDE; - CefSize GetPdfPaperSize(int device_units_per_inch) OVERRIDE; + CefSize GetPdfPaperSize(CefRefPtr browser, + int device_units_per_inch) OVERRIDE; private: // Print handler. diff --git a/tests/ceftests/client_app_delegates.cc b/tests/ceftests/client_app_delegates.cc index 653d362df..36a55639d 100644 --- a/tests/ceftests/client_app_delegates.cc +++ b/tests/ceftests/client_app_delegates.cc @@ -119,11 +119,6 @@ void ClientAppBrowser::CreateDelegates(DelegateSet& delegates) { ::CreateBrowserDelegates(delegates); } -// static -CefRefPtr ClientAppBrowser::CreatePrintHandler() { - return nullptr; -} - // static void ClientAppRenderer::CreateDelegates(DelegateSet& delegates) { ::CreateRenderDelegates(delegates); diff --git a/tests/shared/browser/client_app_browser.cc b/tests/shared/browser/client_app_browser.cc index 739d42505..9db60ab21 100644 --- a/tests/shared/browser/client_app_browser.cc +++ b/tests/shared/browser/client_app_browser.cc @@ -67,8 +67,6 @@ void ClientAppBrowser::GetCookieableSchemes(std::vector& schemes, } void ClientAppBrowser::OnContextInitialized() { - print_handler_ = CreatePrintHandler(); - DelegateSet::iterator it = delegates_.begin(); for (; it != delegates_.end(); ++it) (*it)->OnContextInitialized(this); diff --git a/tests/shared/browser/client_app_browser.h b/tests/shared/browser/client_app_browser.h index d7329a7e4..79c22c68e 100644 --- a/tests/shared/browser/client_app_browser.h +++ b/tests/shared/browser/client_app_browser.h @@ -40,10 +40,6 @@ class ClientAppBrowser : public ClientApp, public CefBrowserProcessHandler { // client_app_delegates_browser.cc static void CreateDelegates(DelegateSet& delegates); - // Create the Linux print handler. Implemented by cefclient in - // client_app_delegates_browser.cc - static CefRefPtr CreatePrintHandler(); - // CefApp methods. void OnBeforeCommandLineProcessing( const CefString& process_type, @@ -58,16 +54,11 @@ class ClientAppBrowser : public ClientApp, public CefBrowserProcessHandler { void OnContextInitialized() OVERRIDE; void OnBeforeChildProcessLaunch( CefRefPtr command_line) OVERRIDE; - CefRefPtr GetPrintHandler() OVERRIDE { - return print_handler_; - } void OnScheduleMessagePumpWork(int64 delay) OVERRIDE; // Set of supported Delegates. DelegateSet delegates_; - CefRefPtr print_handler_; - IMPLEMENT_REFCOUNTING(ClientAppBrowser); DISALLOW_COPY_AND_ASSIGN(ClientAppBrowser); };