mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Linux: Don't pass NULL CefBrowser to PrintHandler::GetPdfPaperSize (issue #2199)
This commit is contained in:
@ -33,7 +33,7 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=ed78ca41d62dfc0cdb52828dcf795617c4e231a7$
|
// $hash=897f5b1ec6ed7430fff156f47b4ce6371d5db6f2$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_PRINT_HANDLER_CAPI_H_
|
#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)(
|
cef_size_t(CEF_CALLBACK* get_pdf_paper_size)(
|
||||||
struct _cef_print_handler_t* self,
|
struct _cef_print_handler_t* self,
|
||||||
struct _cef_browser_t* browser,
|
|
||||||
int device_units_per_inch);
|
int device_units_per_inch);
|
||||||
} cef_print_handler_t;
|
} cef_print_handler_t;
|
||||||
|
|
||||||
|
@ -133,8 +133,7 @@ class CefPrintHandler : public virtual CefBaseRefCounted {
|
|||||||
// CefBrowserHost::PrintToPDF().
|
// CefBrowserHost::PrintToPDF().
|
||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual CefSize GetPdfPaperSize(CefRefPtr<CefBrowser> browser,
|
virtual CefSize GetPdfPaperSize(int device_units_per_inch) {
|
||||||
int device_units_per_inch) {
|
|
||||||
return CefSize();
|
return CefSize();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -113,12 +113,9 @@ gfx::Size CefPrintDialogLinux::GetPdfPaperSize(
|
|||||||
if (browser_handler.get()) {
|
if (browser_handler.get()) {
|
||||||
CefRefPtr<CefPrintHandler> handler = browser_handler->GetPrintHandler();
|
CefRefPtr<CefPrintHandler> handler = browser_handler->GetPrintHandler();
|
||||||
if (handler.get()) {
|
if (handler.get()) {
|
||||||
CefRefPtr<CefBrowserHostImpl> browser =
|
|
||||||
extensions::GetOwnerBrowserForFrame(
|
|
||||||
context->render_process_id(), context->render_frame_id(), NULL);
|
|
||||||
const printing::PrintSettings& settings = context->settings();
|
const printing::PrintSettings& settings = context->settings();
|
||||||
CefSize cef_size = handler->GetPdfPaperSize(
|
CefSize cef_size =
|
||||||
browser.get(), settings.device_units_per_inch());
|
handler->GetPdfPaperSize(settings.device_units_per_inch());
|
||||||
size.SetSize(cef_size.width, cef_size.height);
|
size.SetSize(cef_size.width, cef_size.height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// implementations. See the translator.README.txt file in the tools directory
|
// implementations. See the translator.README.txt file in the tools directory
|
||||||
// for more information.
|
// for more information.
|
||||||
//
|
//
|
||||||
// $hash=80fc869800987a74f4c6e4eb202f0f5201126a76$
|
// $hash=eba15f068169c3d986c5b44ed55aa472f47a9081$
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "libcef_dll/cpptoc/print_handler_cpptoc.h"
|
#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
|
cef_size_t CEF_CALLBACK
|
||||||
print_handler_get_pdf_paper_size(struct _cef_print_handler_t* self,
|
print_handler_get_pdf_paper_size(struct _cef_print_handler_t* self,
|
||||||
cef_browser_t* browser,
|
|
||||||
int device_units_per_inch) {
|
int device_units_per_inch) {
|
||||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
DCHECK(self);
|
DCHECK(self);
|
||||||
if (!self)
|
if (!self)
|
||||||
return CefSize();
|
return CefSize();
|
||||||
// Verify param: browser; type: refptr_diff
|
|
||||||
DCHECK(browser);
|
|
||||||
if (!browser)
|
|
||||||
return CefSize();
|
|
||||||
|
|
||||||
// Execute
|
// Execute
|
||||||
cef_size_t _retval = CefPrintHandlerCppToC::Get(self)->GetPdfPaperSize(
|
cef_size_t _retval =
|
||||||
CefBrowserCToCpp::Wrap(browser), device_units_per_inch);
|
CefPrintHandlerCppToC::Get(self)->GetPdfPaperSize(device_units_per_inch);
|
||||||
|
|
||||||
// Return type: simple
|
// Return type: simple
|
||||||
return _retval;
|
return _retval;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// implementations. See the translator.README.txt file in the tools directory
|
// implementations. See the translator.README.txt file in the tools directory
|
||||||
// for more information.
|
// for more information.
|
||||||
//
|
//
|
||||||
// $hash=80679bfc067e7564eadb691876081c4176b04c4f$
|
// $hash=81ba68d1a06a25947aa4533d2c50fff945c54fd0$
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "libcef_dll/ctocpp/print_handler_ctocpp.h"
|
#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));
|
_struct->on_print_reset(_struct, CefBrowserCppToC::Wrap(browser));
|
||||||
}
|
}
|
||||||
|
|
||||||
CefSize CefPrintHandlerCToCpp::GetPdfPaperSize(CefRefPtr<CefBrowser> browser,
|
CefSize CefPrintHandlerCToCpp::GetPdfPaperSize(int device_units_per_inch) {
|
||||||
int device_units_per_inch) {
|
|
||||||
cef_print_handler_t* _struct = GetStruct();
|
cef_print_handler_t* _struct = GetStruct();
|
||||||
if (CEF_MEMBER_MISSING(_struct, get_pdf_paper_size))
|
if (CEF_MEMBER_MISSING(_struct, get_pdf_paper_size))
|
||||||
return CefSize();
|
return CefSize();
|
||||||
|
|
||||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
// Verify param: browser; type: refptr_diff
|
|
||||||
DCHECK(browser.get());
|
|
||||||
if (!browser.get())
|
|
||||||
return CefSize();
|
|
||||||
|
|
||||||
// Execute
|
// Execute
|
||||||
cef_size_t _retval = _struct->get_pdf_paper_size(
|
cef_size_t _retval =
|
||||||
_struct, CefBrowserCppToC::Wrap(browser), device_units_per_inch);
|
_struct->get_pdf_paper_size(_struct, device_units_per_inch);
|
||||||
|
|
||||||
// Return type: simple
|
// Return type: simple
|
||||||
return _retval;
|
return _retval;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// implementations. See the translator.README.txt file in the tools directory
|
// implementations. See the translator.README.txt file in the tools directory
|
||||||
// for more information.
|
// for more information.
|
||||||
//
|
//
|
||||||
// $hash=1a2adb6e9cbbe96253cc997312e60ca330dc4de6$
|
// $hash=4a628ee393964285a7ad6f2a6c64cff8a88c3b20$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_LIBCEF_DLL_CTOCPP_PRINT_HANDLER_CTOCPP_H_
|
#ifndef CEF_LIBCEF_DLL_CTOCPP_PRINT_HANDLER_CTOCPP_H_
|
||||||
@ -45,8 +45,7 @@ class CefPrintHandlerCToCpp : public CefCToCppRefCounted<CefPrintHandlerCToCpp,
|
|||||||
const CefString& pdf_file_path,
|
const CefString& pdf_file_path,
|
||||||
CefRefPtr<CefPrintJobCallback> callback) override;
|
CefRefPtr<CefPrintJobCallback> callback) override;
|
||||||
void OnPrintReset(CefRefPtr<CefBrowser> browser) override;
|
void OnPrintReset(CefRefPtr<CefBrowser> browser) override;
|
||||||
CefSize GetPdfPaperSize(CefRefPtr<CefBrowser> browser,
|
CefSize GetPdfPaperSize(int device_units_per_inch) override;
|
||||||
int device_units_per_inch) override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CEF_LIBCEF_DLL_CTOCPP_PRINT_HANDLER_CTOCPP_H_
|
#endif // CEF_LIBCEF_DLL_CTOCPP_PRINT_HANDLER_CTOCPP_H_
|
||||||
|
@ -547,6 +547,8 @@ ClientPrintHandlerGtk::~ClientPrintHandlerGtk() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ClientPrintHandlerGtk::OnPrintStart(CefRefPtr<CefBrowser> browser) {
|
void ClientPrintHandlerGtk::OnPrintStart(CefRefPtr<CefBrowser> browser) {
|
||||||
|
CEF_REQUIRE_UI_THREAD();
|
||||||
|
|
||||||
const int browser_id = browser->GetIdentifier();
|
const int browser_id = browser->GetIdentifier();
|
||||||
|
|
||||||
#ifndef _NDEBUG
|
#ifndef _NDEBUG
|
||||||
@ -564,6 +566,8 @@ void ClientPrintHandlerGtk::OnPrintSettings(
|
|||||||
CefRefPtr<CefBrowser> browser,
|
CefRefPtr<CefBrowser> browser,
|
||||||
CefRefPtr<CefPrintSettings> settings,
|
CefRefPtr<CefPrintSettings> settings,
|
||||||
bool get_defaults) {
|
bool get_defaults) {
|
||||||
|
CEF_REQUIRE_UI_THREAD();
|
||||||
|
|
||||||
GetPrintHandler(browser)->OnPrintSettings(settings, get_defaults);
|
GetPrintHandler(browser)->OnPrintSettings(settings, get_defaults);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -571,6 +575,8 @@ bool ClientPrintHandlerGtk::OnPrintDialog(
|
|||||||
CefRefPtr<CefBrowser> browser,
|
CefRefPtr<CefBrowser> browser,
|
||||||
bool has_selection,
|
bool has_selection,
|
||||||
CefRefPtr<CefPrintDialogCallback> callback) {
|
CefRefPtr<CefPrintDialogCallback> callback) {
|
||||||
|
CEF_REQUIRE_UI_THREAD();
|
||||||
|
|
||||||
return GetPrintHandler(browser)->OnPrintDialog(has_selection, callback);
|
return GetPrintHandler(browser)->OnPrintDialog(has_selection, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -579,11 +585,15 @@ bool ClientPrintHandlerGtk::OnPrintJob(
|
|||||||
const CefString& document_name,
|
const CefString& document_name,
|
||||||
const CefString& pdf_file_path,
|
const CefString& pdf_file_path,
|
||||||
CefRefPtr<CefPrintJobCallback> callback) {
|
CefRefPtr<CefPrintJobCallback> callback) {
|
||||||
|
CEF_REQUIRE_UI_THREAD();
|
||||||
|
|
||||||
return GetPrintHandler(browser)->OnPrintJob(document_name, pdf_file_path,
|
return GetPrintHandler(browser)->OnPrintJob(document_name, pdf_file_path,
|
||||||
callback);
|
callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientPrintHandlerGtk::OnPrintReset(CefRefPtr<CefBrowser> browser) {
|
void ClientPrintHandlerGtk::OnPrintReset(CefRefPtr<CefBrowser> browser) {
|
||||||
|
CEF_REQUIRE_UI_THREAD();
|
||||||
|
|
||||||
// Delete the print handler.
|
// Delete the print handler.
|
||||||
PrintHandlerMap::iterator it =
|
PrintHandlerMap::iterator it =
|
||||||
print_handler_map_.find(browser->GetIdentifier());
|
print_handler_map_.find(browser->GetIdentifier());
|
||||||
@ -592,8 +602,9 @@ void ClientPrintHandlerGtk::OnPrintReset(CefRefPtr<CefBrowser> browser) {
|
|||||||
print_handler_map_.erase(it);
|
print_handler_map_.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
CefSize ClientPrintHandlerGtk::GetPdfPaperSize(CefRefPtr<CefBrowser> browser,
|
CefSize ClientPrintHandlerGtk::GetPdfPaperSize(int device_units_per_inch) {
|
||||||
int device_units_per_inch) {
|
CEF_REQUIRE_UI_THREAD();
|
||||||
|
|
||||||
GtkPageSetup* page_setup = gtk_page_setup_new();
|
GtkPageSetup* page_setup = gtk_page_setup_new();
|
||||||
|
|
||||||
float width = gtk_page_setup_get_paper_width(page_setup, GTK_UNIT_INCH);
|
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,
|
const CefString& pdf_file_path,
|
||||||
CefRefPtr<CefPrintJobCallback> callback) OVERRIDE;
|
CefRefPtr<CefPrintJobCallback> callback) OVERRIDE;
|
||||||
void OnPrintReset(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
void OnPrintReset(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
||||||
CefSize GetPdfPaperSize(CefRefPtr<CefBrowser> browser,
|
CefSize GetPdfPaperSize(int device_units_per_inch) OVERRIDE;
|
||||||
int device_units_per_inch) OVERRIDE;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Print handler.
|
// Print handler.
|
||||||
|
Reference in New Issue
Block a user