Linux: Don't pass NULL CefBrowser to PrintHandler::GetPdfPaperSize (issue #2199)
This commit is contained in:
parent
1ebbf3c4da
commit
f95fa26aa9
|
@ -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;
|
||||
|
||||
|
|
|
@ -133,8 +133,7 @@ class CefPrintHandler : public virtual CefBaseRefCounted {
|
|||
// CefBrowserHost::PrintToPDF().
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefSize GetPdfPaperSize(CefRefPtr<CefBrowser> browser,
|
||||
int device_units_per_inch) {
|
||||
virtual CefSize GetPdfPaperSize(int device_units_per_inch) {
|
||||
return CefSize();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -113,12 +113,9 @@ gfx::Size CefPrintDialogLinux::GetPdfPaperSize(
|
|||
if (browser_handler.get()) {
|
||||
CefRefPtr<CefPrintHandler> handler = browser_handler->GetPrintHandler();
|
||||
if (handler.get()) {
|
||||
CefRefPtr<CefBrowserHostImpl> 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<CefBrowser> browser) {
|
|||
_struct->on_print_reset(_struct, CefBrowserCppToC::Wrap(browser));
|
||||
}
|
||||
|
||||
CefSize CefPrintHandlerCToCpp::GetPdfPaperSize(CefRefPtr<CefBrowser> 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;
|
||||
|
|
|
@ -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<CefPrintHandlerCToCpp,
|
|||
const CefString& pdf_file_path,
|
||||
CefRefPtr<CefPrintJobCallback> callback) override;
|
||||
void OnPrintReset(CefRefPtr<CefBrowser> browser) override;
|
||||
CefSize GetPdfPaperSize(CefRefPtr<CefBrowser> browser,
|
||||
int device_units_per_inch) override;
|
||||
CefSize GetPdfPaperSize(int device_units_per_inch) override;
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_DLL_CTOCPP_PRINT_HANDLER_CTOCPP_H_
|
||||
|
|
|
@ -547,6 +547,8 @@ ClientPrintHandlerGtk::~ClientPrintHandlerGtk() {
|
|||
}
|
||||
|
||||
void ClientPrintHandlerGtk::OnPrintStart(CefRefPtr<CefBrowser> browser) {
|
||||
CEF_REQUIRE_UI_THREAD();
|
||||
|
||||
const int browser_id = browser->GetIdentifier();
|
||||
|
||||
#ifndef _NDEBUG
|
||||
|
@ -564,6 +566,8 @@ void ClientPrintHandlerGtk::OnPrintSettings(
|
|||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefPrintSettings> settings,
|
||||
bool get_defaults) {
|
||||
CEF_REQUIRE_UI_THREAD();
|
||||
|
||||
GetPrintHandler(browser)->OnPrintSettings(settings, get_defaults);
|
||||
}
|
||||
|
||||
|
@ -571,6 +575,8 @@ bool ClientPrintHandlerGtk::OnPrintDialog(
|
|||
CefRefPtr<CefBrowser> browser,
|
||||
bool has_selection,
|
||||
CefRefPtr<CefPrintDialogCallback> 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<CefPrintJobCallback> callback) {
|
||||
CEF_REQUIRE_UI_THREAD();
|
||||
|
||||
return GetPrintHandler(browser)->OnPrintJob(document_name, pdf_file_path,
|
||||
callback);
|
||||
}
|
||||
|
||||
void ClientPrintHandlerGtk::OnPrintReset(CefRefPtr<CefBrowser> 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<CefBrowser> browser) {
|
|||
print_handler_map_.erase(it);
|
||||
}
|
||||
|
||||
CefSize ClientPrintHandlerGtk::GetPdfPaperSize(CefRefPtr<CefBrowser> 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);
|
||||
|
|
|
@ -31,8 +31,7 @@ class ClientPrintHandlerGtk : public CefPrintHandler {
|
|||
const CefString& pdf_file_path,
|
||||
CefRefPtr<CefPrintJobCallback> callback) OVERRIDE;
|
||||
void OnPrintReset(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
||||
CefSize GetPdfPaperSize(CefRefPtr<CefBrowser> browser,
|
||||
int device_units_per_inch) OVERRIDE;
|
||||
CefSize GetPdfPaperSize(int device_units_per_inch) OVERRIDE;
|
||||
|
||||
private:
|
||||
// Print handler.
|
||||
|
|
Loading…
Reference in New Issue