diff --git a/include/capi/cef_print_handler_capi.h b/include/capi/cef_print_handler_capi.h index 497595435..fbafd6e38 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=ed78ca41d62dfc0cdb52828dcf795617c4e231a7$ +// $hash=897f5b1ec6ed7430fff156f47b4ce6371d5db6f2$ // #ifndef CEF_INCLUDE_CAPI_CEF_PRINT_HANDLER_CAPI_H_ @@ -148,7 +148,6 @@ 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_print_handler.h b/include/cef_print_handler.h index 950764acd..c668bd4cf 100644 --- a/include/cef_print_handler.h +++ b/include/cef_print_handler.h @@ -133,8 +133,7 @@ class CefPrintHandler : public virtual CefBaseRefCounted { // CefBrowserHost::PrintToPDF(). /// /*--cef()--*/ - virtual CefSize GetPdfPaperSize(CefRefPtr browser, - int device_units_per_inch) { + virtual CefSize GetPdfPaperSize(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 a9b44fe79..f73ca0efa 100644 --- a/libcef/browser/printing/print_dialog_linux.cc +++ b/libcef/browser/printing/print_dialog_linux.cc @@ -113,12 +113,9 @@ gfx::Size CefPrintDialogLinux::GetPdfPaperSize( if (browser_handler.get()) { CefRefPtr handler = browser_handler->GetPrintHandler(); if (handler.get()) { - CefRefPtr browser = - extensions::GetOwnerBrowserForFrame( - context->render_process_id(), context->render_frame_id(), NULL); const printing::PrintSettings& settings = context->settings(); - CefSize cef_size = handler->GetPdfPaperSize( - browser.get(), settings.device_units_per_inch()); + CefSize cef_size = + handler->GetPdfPaperSize(settings.device_units_per_inch()); size.SetSize(cef_size.width, cef_size.height); } } diff --git a/libcef_dll/cpptoc/print_handler_cpptoc.cc b/libcef_dll/cpptoc/print_handler_cpptoc.cc index f82a03a09..aee68793a 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=80fc869800987a74f4c6e4eb202f0f5201126a76$ +// $hash=eba15f068169c3d986c5b44ed55aa472f47a9081$ // #include "libcef_dll/cpptoc/print_handler_cpptoc.h" @@ -150,21 +150,16 @@ 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) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING 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( - CefBrowserCToCpp::Wrap(browser), device_units_per_inch); + cef_size_t _retval = + CefPrintHandlerCppToC::Get(self)->GetPdfPaperSize(device_units_per_inch); // Return type: simple return _retval; diff --git a/libcef_dll/ctocpp/print_handler_ctocpp.cc b/libcef_dll/ctocpp/print_handler_ctocpp.cc index 9e89d542a..faa0381af 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=80679bfc067e7564eadb691876081c4176b04c4f$ +// $hash=81ba68d1a06a25947aa4533d2c50fff945c54fd0$ // #include "libcef_dll/ctocpp/print_handler_ctocpp.h" @@ -142,22 +142,16 @@ void CefPrintHandlerCToCpp::OnPrintReset(CefRefPtr browser) { _struct->on_print_reset(_struct, CefBrowserCppToC::Wrap(browser)); } -CefSize CefPrintHandlerCToCpp::GetPdfPaperSize(CefRefPtr browser, - int device_units_per_inch) { +CefSize CefPrintHandlerCToCpp::GetPdfPaperSize(int device_units_per_inch) { cef_print_handler_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_pdf_paper_size)) return CefSize(); // 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, CefBrowserCppToC::Wrap(browser), device_units_per_inch); + cef_size_t _retval = + _struct->get_pdf_paper_size(_struct, 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 de792ec04..168e8644f 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=1a2adb6e9cbbe96253cc997312e60ca330dc4de6$ +// $hash=4a628ee393964285a7ad6f2a6c64cff8a88c3b20$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_PRINT_HANDLER_CTOCPP_H_ @@ -45,8 +45,7 @@ class CefPrintHandlerCToCpp : public CefCToCppRefCounted callback) override; void OnPrintReset(CefRefPtr browser) override; - CefSize GetPdfPaperSize(CefRefPtr browser, - int device_units_per_inch) override; + CefSize GetPdfPaperSize(int device_units_per_inch) override; }; #endif // CEF_LIBCEF_DLL_CTOCPP_PRINT_HANDLER_CTOCPP_H_ diff --git a/tests/cefclient/browser/print_handler_gtk.cc b/tests/cefclient/browser/print_handler_gtk.cc index 263e4546a..d00f0431b 100644 --- a/tests/cefclient/browser/print_handler_gtk.cc +++ b/tests/cefclient/browser/print_handler_gtk.cc @@ -547,6 +547,8 @@ ClientPrintHandlerGtk::~ClientPrintHandlerGtk() { } void ClientPrintHandlerGtk::OnPrintStart(CefRefPtr browser) { + CEF_REQUIRE_UI_THREAD(); + const int browser_id = browser->GetIdentifier(); #ifndef _NDEBUG @@ -564,6 +566,8 @@ void ClientPrintHandlerGtk::OnPrintSettings( CefRefPtr browser, CefRefPtr settings, bool get_defaults) { + CEF_REQUIRE_UI_THREAD(); + GetPrintHandler(browser)->OnPrintSettings(settings, get_defaults); } @@ -571,6 +575,8 @@ bool ClientPrintHandlerGtk::OnPrintDialog( CefRefPtr browser, bool has_selection, CefRefPtr callback) { + CEF_REQUIRE_UI_THREAD(); + return GetPrintHandler(browser)->OnPrintDialog(has_selection, callback); } @@ -579,11 +585,15 @@ bool ClientPrintHandlerGtk::OnPrintJob( const CefString& document_name, const CefString& pdf_file_path, CefRefPtr callback) { + CEF_REQUIRE_UI_THREAD(); + return GetPrintHandler(browser)->OnPrintJob(document_name, pdf_file_path, callback); } void ClientPrintHandlerGtk::OnPrintReset(CefRefPtr browser) { + CEF_REQUIRE_UI_THREAD(); + // Delete the print handler. PrintHandlerMap::iterator it = print_handler_map_.find(browser->GetIdentifier()); @@ -592,8 +602,9 @@ void ClientPrintHandlerGtk::OnPrintReset(CefRefPtr browser) { print_handler_map_.erase(it); } -CefSize ClientPrintHandlerGtk::GetPdfPaperSize(CefRefPtr browser, - int device_units_per_inch) { +CefSize ClientPrintHandlerGtk::GetPdfPaperSize(int device_units_per_inch) { + CEF_REQUIRE_UI_THREAD(); + GtkPageSetup* page_setup = gtk_page_setup_new(); float width = gtk_page_setup_get_paper_width(page_setup, GTK_UNIT_INCH); diff --git a/tests/cefclient/browser/print_handler_gtk.h b/tests/cefclient/browser/print_handler_gtk.h index 0aa8f85a2..857b8c724 100644 --- a/tests/cefclient/browser/print_handler_gtk.h +++ b/tests/cefclient/browser/print_handler_gtk.h @@ -31,8 +31,7 @@ class ClientPrintHandlerGtk : public CefPrintHandler { const CefString& pdf_file_path, CefRefPtr callback) OVERRIDE; void OnPrintReset(CefRefPtr browser) OVERRIDE; - CefSize GetPdfPaperSize(CefRefPtr browser, - int device_units_per_inch) OVERRIDE; + CefSize GetPdfPaperSize(int device_units_per_inch) OVERRIDE; private: // Print handler.