bool IsDocumentEdited();
void CapturePage(mate::Arguments* args);
void Print(mate::Arguments* args);
- void PrintToPDF(mate::Arguments* args);
void SetProgressBar(double progress);
void SetOverlayIcon(const gfx::Image& overlay,
const std::string& description);
PrintPreviewMessageHandler::~PrintPreviewMessageHandler() {
}
-void PrintPreviewMessageHandler::OnDidGetPreviewPageCount(
- const PrintHostMsg_DidGetPreviewPageCount_Params& params) {
- if (params.page_count <= 0) {
- NOTREACHED();
- return;
- }
-}
-
-void PrintPreviewMessageHandler::OnDidPreviewPage(
- const PrintHostMsg_DidPreviewPage_Params& params) {
- int page_number = params.page_number;
- if (page_number < FIRST_PAGE_INDEX || !params.data_size)
- return;
-}
-
void PrintPreviewMessageHandler::OnMetafileReadyForPrinting(
const PrintHostMsg_DidPreviewDocument_Params& params) {
// Always try to stop the worker.
const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(PrintPreviewMessageHandler, message)
- IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetPreviewPageCount,
- OnDidGetPreviewPageCount)
- IPC_MESSAGE_HANDLER(PrintHostMsg_DidPreviewPage,
- OnDidPreviewPage)
IPC_MESSAGE_HANDLER(PrintHostMsg_MetafileReadyForPrinting,
OnMetafileReadyForPrinting)
IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewFailed,
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
-struct PrintHostMsg_DidGetPreviewPageCount_Params;
struct PrintHostMsg_DidPreviewDocument_Params;
-struct PrintHostMsg_DidPreviewPage_Params;
namespace content {
class WebContents;
}
-namespace mate {
-class Dictionary;
-}
-
-namespace gfx {
-class Rect;
-}
-
namespace printing {
struct PageSizeMargins;
friend class content::WebContentsUserData<PrintPreviewMessageHandler>;
// Message handlers.
- void OnDidGetPreviewPageCount(
- const PrintHostMsg_DidGetPreviewPageCount_Params& params);
- void OnDidPreviewPage(const PrintHostMsg_DidPreviewPage_Params& params);
void OnMetafileReadyForPrinting(
const PrintHostMsg_DidPreviewDocument_Params& params);
void OnPrintPreviewFailed(int document_cookie, int request_id);
IPC_STRUCT_MEMBER(printing::MarginType, margin_type)
IPC_STRUCT_END()
-// Parameters to describe a rendered preview page.
-IPC_STRUCT_BEGIN(PrintHostMsg_DidPreviewPage_Params)
- // A shared memory handle to metafile data for a draft document of the page.
- IPC_STRUCT_MEMBER(base::SharedMemoryHandle, metafile_data_handle)
-
- // Size of metafile data.
- IPC_STRUCT_MEMBER(uint32, data_size)
-
- // |page_number| is zero-based and can be |printing::INVALID_PAGE_INDEX| if it
- // is just a check.
- IPC_STRUCT_MEMBER(int, page_number)
-
- // The id of the preview request.
- IPC_STRUCT_MEMBER(int, preview_request_id)
-IPC_STRUCT_END()
-
-// Parameters sent along with the page count.
-IPC_STRUCT_BEGIN(PrintHostMsg_DidGetPreviewPageCount_Params)
- // Cookie for the document to ensure correctness.
- IPC_STRUCT_MEMBER(int, document_cookie)
-
- // Total page count.
- IPC_STRUCT_MEMBER(int, page_count)
-
- // Indicates whether the previewed document is modifiable.
- IPC_STRUCT_MEMBER(bool, is_modifiable)
-
- // The id of the preview request.
- IPC_STRUCT_MEMBER(int, preview_request_id)
-
- // Indicates whether the existing preview data needs to be cleared or not.
- IPC_STRUCT_MEMBER(bool, clear_preview_data)
-IPC_STRUCT_END()
-
// Parameters to describe a rendered document.
IPC_STRUCT_BEGIN(PrintHostMsg_DidPreviewDocument_Params)
// A shared memory handle to metafile data.
IPC_MESSAGE_ROUTED1(PrintHostMsg_PrintingFailed,
int /* document cookie */)
-// Notify the browser a print preview page has been rendered.
-IPC_MESSAGE_ROUTED1(PrintHostMsg_DidPreviewPage,
- PrintHostMsg_DidPreviewPage_Params /* params */)
-
// Sends back to the browser the complete rendered document (non-draft mode,
// used for printing) that was requested by a PrintMsg_PrintPreview message.
// The memory handle in this message is already valid in the browser process.
IPC_MESSAGE_ROUTED1(PrintHostMsg_MetafileReadyForPrinting,
PrintHostMsg_DidPreviewDocument_Params /* params */)
-// Notify the browser the number of pages in the print preview document.
-IPC_MESSAGE_ROUTED1(PrintHostMsg_DidGetPreviewPageCount,
- PrintHostMsg_DidGetPreviewPageCount_Params /* params */)
-
IPC_MESSAGE_ROUTED2(PrintHostMsg_PrintPreviewFailed,
int /* document cookie */,
int /* request_id */);
return false;
}
- PageSizeMargins default_page_layout;
- ComputePageLayoutInPointsForCss(print_preview_context_.prepared_frame(), 0,
- print_params, ignore_css_margins_, NULL,
- &default_page_layout);
-
- //bool has_page_size_style =
- //PrintingFrameHasPageSizeStyle(print_preview_context_.prepared_frame(),
- //print_preview_context_.total_page_count());
- int dpi = GetDPI(&print_params);
-
- gfx::Rect printable_area_in_points(
- ConvertUnit(print_params.printable_area.x(), dpi, kPointsPerInch),
- ConvertUnit(print_params.printable_area.y(), dpi, kPointsPerInch),
- ConvertUnit(print_params.printable_area.width(), dpi, kPointsPerInch),
- ConvertUnit(print_params.printable_area.height(), dpi, kPointsPerInch));
-
-
- PrintHostMsg_DidGetPreviewPageCount_Params params;
- params.page_count = print_preview_context_.total_page_count();
- params.is_modifiable = print_preview_context_.IsModifiable();
- params.document_cookie = print_params.document_cookie;
- params.preview_request_id = print_params.preview_request_id;
- params.clear_preview_data = print_preview_context_.generate_draft_pages();
- Send(new PrintHostMsg_DidGetPreviewPageCount(routing_id(), params));
-
while (!print_preview_context_.IsFinalPageRendered()) {
int page_number = print_preview_context_.GetNextPageNumber();
DCHECK_GE(page_number, 0);
return false;
}
- PrintHostMsg_DidPreviewPage_Params preview_page_params;
- // Get the size of the resulting metafile.
- uint32 buf_size = metafile->GetDataSize();
- DCHECK_GT(buf_size, 0u);
- if (!CopyMetafileDataToSharedMem(
- metafile, &(preview_page_params.metafile_data_handle))) {
- LOG(ERROR) << "CopyMetafileDataToSharedMem failed";
- print_preview_context_.set_error(PREVIEW_ERROR_METAFILE_COPY_FAILED);
- return false;
- }
- preview_page_params.data_size = buf_size;
- preview_page_params.page_number = page_number;
- preview_page_params.preview_request_id =
- print_pages_params_->params.preview_request_id;
-
- Send(new PrintHostMsg_DidPreviewPage(routing_id(), preview_page_params));
return true;
}