| Index: components/printing/renderer/print_web_view_helper.h
|
| diff --git a/components/printing/renderer/print_web_view_helper.h b/components/printing/renderer/print_web_view_helper.h
|
| index 2dad908dc266d66ddaba8f4a0736e934d3d0ec4f..d07f864c397368d912b4c29d4124385704cf6514 100644
|
| --- a/components/printing/renderer/print_web_view_helper.h
|
| +++ b/components/printing/renderer/print_web_view_helper.h
|
| @@ -42,6 +42,7 @@ struct PrintHostMsg_SetOptionsFromDocument_Params;
|
|
|
| namespace base {
|
| class DictionaryValue;
|
| +class ScopedClosureRunner;
|
| }
|
|
|
| namespace blink {
|
| @@ -72,6 +73,8 @@ class FrameReference {
|
| private:
|
| blink::WebView* view_;
|
| blink::WebLocalFrame* frame_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(FrameReference);
|
| };
|
|
|
| // PrintWebViewHelper handles most of the printing grunt work for RenderView.
|
| @@ -81,6 +84,9 @@ class PrintWebViewHelper
|
| : public content::RenderFrameObserver,
|
| public content::RenderFrameObserverTracker<PrintWebViewHelper> {
|
| public:
|
| + using GetPrintSettingsFromUserCallback = base::Callback<void(
|
| + const PrintMsg_PrintPages_Params& /* print_settings */)>;
|
| +
|
| class Delegate {
|
| public:
|
| virtual ~Delegate() {}
|
| @@ -222,10 +228,20 @@ class PrintWebViewHelper
|
| // Main printing code -------------------------------------------------------
|
|
|
| #if BUILDFLAG(ENABLE_BASIC_PRINTING)
|
| - // |is_scripted| should be true when the call is coming from window.print()
|
| - void Print(blink::WebLocalFrame* frame,
|
| - const blink::WebNode& node,
|
| - bool is_scripted);
|
| + // Start printing with the system dialog. Continues to FinishPrint() below
|
| + // eventually.
|
| + // |is_scripted| should be true when the call is coming from window.print().
|
| + // WARNING: |this| may be gone after this method returns.
|
| + void StartPrint(blink::WebLocalFrame* frame,
|
| + const blink::WebNode& node,
|
| + bool is_scripted,
|
| + bool reset_print_node_in_progress);
|
| +
|
| + // Do the second phase of printing, since showing the system dialog in the
|
| + // middle may require callbacks. Use the saved parameters and do the
|
| + // rendering.
|
| + void FinishPrint(std::unique_ptr<FrameReference> frame_ref,
|
| + const blink::WebNode& node);
|
| #endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
|
|
|
| // Notification when printing is done - signal tear-down/free resources.
|
| @@ -255,15 +271,27 @@ class PrintWebViewHelper
|
| const base::DictionaryValue& passed_job_settings);
|
| #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
|
|
| - // Get final print settings from the user.
|
| - // Return false if the user cancels or on error.
|
| - bool GetPrintSettingsFromUser(blink::WebLocalFrame* frame,
|
| - const blink::WebNode& node,
|
| - int expected_pages_count,
|
| - bool is_scripted);
|
| +#if BUILDFLAG(ENABLE_BASIC_PRINTING)
|
| + // Get final print settings from the user and eventually call
|
| + // OnGetPrintSettingsFromUser().
|
| + // WARNING: |this| may be gone after this method returns.
|
| + void GetPrintSettingsFromUser(
|
| + std::unique_ptr<FrameReference> frame_ref,
|
| + const blink::WebNode& node,
|
| + int expected_pages_count,
|
| + bool is_scripted,
|
| + std::unique_ptr<base::ScopedClosureRunner> on_finish_calback);
|
| +
|
| + // Do the actual printing rendering after Print() gets settings from the
|
| + // system dialog.
|
| + void OnGetPrintSettingsFromUser(
|
| + std::unique_ptr<FrameReference> frame_ref,
|
| + const blink::WebNode& node,
|
| + std::unique_ptr<base::ScopedClosureRunner> on_finish_calback,
|
| + const PrintMsg_PrintPages_Params& print_settings);
|
| +#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
|
|
|
| // Page Printing / Rendering ------------------------------------------------
|
| -
|
| #if BUILDFLAG(ENABLE_BASIC_PRINTING)
|
| void OnFramePreparedForPrintPages();
|
| void PrintPages();
|
| @@ -352,6 +380,8 @@ class PrintWebViewHelper
|
| // Shows scripted print preview when options from plugin are available.
|
| void ShowScriptedPrintPreview();
|
|
|
| + // WARNING: |this| may be gone after this method returns when |type| is
|
| + // PRINT_PREVIEW_SCRIPTED.
|
| void RequestPrintPreview(PrintPreviewRequestType type);
|
|
|
| // Checks whether print preview should continue or not.
|
| @@ -366,6 +396,12 @@ class PrintWebViewHelper
|
| bool PreviewPageRendered(int page_number, PdfMetafileSkia* metafile);
|
| #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
|
|
| + void reset_scripted_preview_delayed() {
|
| + is_scripted_preview_delayed_ = false;
|
| + }
|
| +
|
| + void print_node_in_progress_finished() { print_node_in_progress_ = false; }
|
| +
|
| void SetPrintPagesParams(const PrintMsg_PrintPages_Params& settings);
|
|
|
| // WebView used only to print the selection.
|
|
|