diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index dbd75db286fd..891fd0bcb436 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -52,7 +52,9 @@ class WebContents : public mate::EventEmitter, public content::WebContentsObserver, public content::GpuDataManagerObserver { public: - typedef base::Callback)> PrintToPDFCallback; + // For node.js callback function type: function(error, buffer) + typedef base::Callback, v8::Local)> + PrintToPDFCallback; // Create from an existing WebContents. static mate::Handle CreateFrom( diff --git a/chromium_src/chrome/browser/printing/print_preview_message_handler.cc b/chromium_src/chrome/browser/printing/print_preview_message_handler.cc index 5a6a17034a63..7005b1c24e9d 100644 --- a/chromium_src/chrome/browser/printing/print_preview_message_handler.cc +++ b/chromium_src/chrome/browser/printing/print_preview_message_handler.cc @@ -130,9 +130,12 @@ void PrintPreviewMessageHandler::RunPrintToPDFCallback( v8::Local buffer = node::Buffer::Use( const_cast(reinterpret_cast(data->front())), data->size()); - print_to_pdf_callback_map_[request_id].Run(buffer); + print_to_pdf_callback_map_[request_id].Run(v8::Null(isolate), buffer); } else { - print_to_pdf_callback_map_[request_id].Run(v8::Null(isolate)); + v8::Local error_message = v8::String::NewFromUtf8(isolate, + "Fail to generate PDF"); + print_to_pdf_callback_map_[request_id].Run( + v8::Exception::Error(error_message), v8::Null(isolate)); } print_to_pdf_callback_map_.erase(request_id); }