| Index: headless/lib/browser/headless_print_manager.h
|
| diff --git a/headless/lib/browser/headless_print_manager.h b/headless/lib/browser/headless_print_manager.h
|
| index 6d35bfae461d890d9a9d3d529c413c6b3ec82aa7..b5474a0887bd03594cce225d10fed2cd441d39d6 100644
|
| --- a/headless/lib/browser/headless_print_manager.h
|
| +++ b/headless/lib/browser/headless_print_manager.h
|
| @@ -11,11 +11,47 @@
|
| #include "components/printing/browser/print_manager.h"
|
| #include "content/public/browser/render_frame_host.h"
|
| #include "content/public/browser/web_contents_user_data.h"
|
| +#include "printing/print_settings.h"
|
|
|
| struct PrintHostMsg_DidPrintPage_Params;
|
| +struct PrintHostMsg_ScriptedPrint_Params;
|
| +struct PrintMsg_PrintPages_Params;
|
|
|
| namespace printing {
|
|
|
| +struct HeadlessPrintSettings {
|
| + enum PaperType {
|
| + LETTER,
|
| + LEGAL,
|
| + A4,
|
| + A3,
|
| + };
|
| +
|
| + HeadlessPrintSettings();
|
| + HeadlessPrintSettings(const HeadlessPrintSettings& obj);
|
| + ~HeadlessPrintSettings();
|
| +
|
| + int GetDPI();
|
| + gfx::Size PaperSizeInPixel();
|
| + PageMargins MarginInPoints();
|
| +
|
| + int dpi;
|
| + PaperType paper_type;
|
| +
|
| + MarginType margin_type;
|
| + double margin_top_in_inch;
|
| + double margin_bottom_in_inch;
|
| + double margin_left_in_inch;
|
| + double margin_right_in_inch;
|
| +
|
| + bool landscape;
|
| + bool display_header_footer;
|
| + bool should_print_backgrounds;
|
| + double scale;
|
| +
|
| + PageRanges page_ranges;
|
| +};
|
| +
|
| class HeadlessPrintManager
|
| : public PrintManager,
|
| public content::WebContentsUserData<HeadlessPrintManager> {
|
| @@ -30,6 +66,7 @@ class HeadlessPrintManager
|
| METAFILE_INVALID_HEADER,
|
| METAFILE_GET_DATA_ERROR,
|
| SIMULTANEOUS_PRINT_ACTIVE,
|
| + EXCEED_PAGE_LIMIT,
|
| };
|
|
|
| using GetPDFCallback = base::Callback<void(PrintResult, const std::string&)>;
|
| @@ -45,20 +82,26 @@ class HeadlessPrintManager
|
| // this function, and |callback| will always get called when printing
|
| // finishes.
|
| void GetPDFContents(content::RenderFrameHost* rfh,
|
| + HeadlessPrintSettings settings,
|
| const GetPDFCallback& callback);
|
|
|
| private:
|
| explicit HeadlessPrintManager(content::WebContents* web_contents);
|
| friend class content::WebContentsUserData<HeadlessPrintManager>;
|
|
|
| + std::unique_ptr<PrintMsg_PrintPages_Params> PrintParams(
|
| + HeadlessPrintSettings settings);
|
| // content::WebContentsObserver implementation.
|
| bool OnMessageReceived(const IPC::Message& message,
|
| content::RenderFrameHost* render_frame_host) override;
|
|
|
| // IPC Message handlers.
|
| void OnGetDefaultPrintSettings(IPC::Message* reply_msg);
|
| + void OnScriptedPrint(const PrintHostMsg_ScriptedPrint_Params& params,
|
| + IPC::Message* reply_msg);
|
| void OnShowInvalidPrinterSettingsError();
|
| void OnPrintingFailed(int cookie) override;
|
| + void OnDidGetPrintedPagesCount(int cookie, int number_pages) override;
|
| void OnDidPrintPage(const PrintHostMsg_DidPrintPage_Params& params);
|
|
|
| void Reset();
|
| @@ -66,6 +109,7 @@ class HeadlessPrintManager
|
|
|
| content::RenderFrameHost* printing_rfh_;
|
| GetPDFCallback callback_;
|
| + std::unique_ptr<PrintMsg_PrintPages_Params> print_params_;
|
| std::string data_;
|
|
|
| // Set to true when OnDidPrintPage() should be expecting the first page.
|
|
|