#include "base/time/time.h"
#include "content/public/renderer/render_view_observer.h"
#include "content/public/renderer/render_view_observer_tracker.h"
-#include "printing/metafile_impl.h"
+#include "printing/pdf_metafile_skia.h"
#include "third_party/WebKit/public/platform/WebCanvas.h"
#include "third_party/WebKit/public/web/WebNode.h"
#include "third_party/WebKit/public/web/WebPrintParams.h"
// Stores reference to frame using WebVew and unique name.
// Workaround to modal dialog issue on Linux. crbug.com/236147.
+// If WebFrame someday supports WeakPtr, we should use it here.
class FrameReference {
public:
- explicit FrameReference(const blink::WebFrame* frame);
+ explicit FrameReference(blink::WebLocalFrame* frame);
FrameReference();
~FrameReference();
- void Reset(const blink::WebFrame* frame);
+ void Reset(blink::WebLocalFrame* frame);
- blink::WebFrame* GetFrame();
+ blink::WebLocalFrame* GetFrame();
blink::WebView* view();
private:
blink::WebView* view_;
- blink::WebString frame_name_;
+ blink::WebLocalFrame* frame_;
};
// PrintWebViewHelper handles most of the printing grunt work for RenderView.
// RenderViewObserver implementation.
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
- virtual void PrintPage(blink::WebFrame* frame, bool user_initiated) OVERRIDE;
+ virtual void PrintPage(blink::WebLocalFrame* frame,
+ bool user_initiated) OVERRIDE;
virtual void DidStartLoading() OVERRIDE;
virtual void DidStopLoading() OVERRIDE;
// Message handlers ---------------------------------------------------------
-
- // Print the document.
void OnPrintPages();
-
- // Print the document with the print preview frame/node.
void OnPrintForSystemDialog();
+ void OnInitiatePrintPreview(bool selection_only);
+ void OnPrintPreview(const base::DictionaryValue& settings);
+ void OnPrintForPrintPreview(const base::DictionaryValue& job_settings);
+ void OnPrintingDone(bool success);
// Get |page_size| and |content_area| information from
// |page_layout_in_points|.
const base::DictionaryValue& job_settings,
const PrintMsg_Print_Params& params);
- // Initiate print preview.
- void OnInitiatePrintPreview(bool selection_only);
-
- // Start the process of generating a print preview using |settings|.
- void OnPrintPreview(const base::DictionaryValue& settings);
-
// Prepare frame for creating preview document.
void PrepareFrameForPreviewDocument();
// Finalize the print ready preview document.
bool FinalizePrintReadyDocument();
- // Print / preview the node under the context menu.
- void OnPrintNodeUnderContextMenu();
-
- // Print the pages for print preview. Do not display the native print dialog
- // for user settings. |job_settings| has new print job settings values.
- void OnPrintForPrintPreview(const base::DictionaryValue& job_settings);
-
- void OnPrintingDone(bool success);
-
// Enable/Disable window.print calls. If |blocked| is true window.print
// calls will silently fail. Call with |blocked| set to false to reenable.
void SetScriptedPrintBlocked(bool blocked);
// Main printing code -------------------------------------------------------
- void Print(blink::WebFrame* frame, const blink::WebNode& node);
+ void Print(blink::WebLocalFrame* frame, const blink::WebNode& node);
// Notification when printing is done - signal tear-down/free resources.
void DidFinishPrinting(PrintingResult result);
bool InitPrintSettings(bool fit_to_paper_size);
// Calculate number of pages in source document.
- bool CalculateNumberOfPages(blink::WebFrame* frame,
+ bool CalculateNumberOfPages(blink::WebLocalFrame* frame,
const blink::WebNode& node,
int* number_of_pages);
// Update the current print settings with new |passed_job_settings|.
// |passed_job_settings| dictionary contains print job details such as printer
// name, number of copies, page range, etc.
- bool UpdatePrintSettings(blink::WebFrame* frame,
+ bool UpdatePrintSettings(blink::WebLocalFrame* frame,
const blink::WebNode& node,
const base::DictionaryValue& passed_job_settings);
void PrintPageInternal(const PrintMsg_PrintPage_Params& params,
const gfx::Size& canvas_size,
blink::WebFrame* frame,
- Metafile* metafile);
+ PdfMetafileSkia* metafile);
#else
void PrintPageInternal(const PrintMsg_PrintPage_Params& params,
const gfx::Size& canvas_size,
#endif
// Render the frame for printing.
- bool RenderPagesForPrint(blink::WebFrame* frame,
+ bool RenderPagesForPrint(blink::WebLocalFrame* frame,
const blink::WebNode& node);
// Platform specific helper function for rendering page(s) to |metafile|.
int page_number,
blink::WebFrame* frame,
bool is_preview,
- Metafile* metafile,
+ PdfMetafileSkia* metafile,
double* scale_factor,
gfx::Size* page_size_in_dpi,
gfx::Rect* content_area_in_dpi);
int page_number,
blink::WebFrame* frame,
bool is_preview,
- Metafile* metafile,
+ PdfMetafileSkia* metafile,
gfx::Size* page_size,
gfx::Rect* content_rect);
#endif // defined(OS_WIN)
// Helper methods -----------------------------------------------------------
- bool CopyMetafileDataToSharedMem(Metafile* metafile,
+ bool CopyMetafileDataToSharedMem(PdfMetafileSkia* metafile,
base::SharedMemoryHandle* shared_mem_handle);
// Helper method to get page layout in points and fit to page if needed.
const base::DictionaryValue& header_footer_info,
const PrintMsg_Print_Params& params);
- bool GetPrintFrame(blink::WebFrame** frame);
+ bool GetPrintFrame(blink::WebLocalFrame** frame);
// Script Initiated Printing ------------------------------------------------
// For a valid |page_number| with modifiable content,
// |metafile| is the rendered page. Otherwise |metafile| is NULL.
// Returns true if print preview should continue, false on failure.
- bool PreviewPageRendered(int page_number, Metafile* metafile);
+ bool PreviewPageRendered(int page_number, PdfMetafileSkia* metafile);
// WebView used only to print the selection.
scoped_ptr<PrepareFrameAndViewForPrint> prep_frame_view_;
// Initializes the print preview context. Need to be called to set
// the |web_frame| / |web_node| to generate the print preview for.
- void InitWithFrame(blink::WebFrame* web_frame);
+ void InitWithFrame(blink::WebLocalFrame* web_frame);
void InitWithNode(const blink::WebNode& web_node);
// Does bookkeeping at the beginning of print preview.
// Getters
// Original frame for which preview was requested.
- blink::WebFrame* source_frame();
+ blink::WebLocalFrame* source_frame();
// Original node for which preview was requested.
const blink::WebNode& source_node() const;
// Frame to be use to render preview. May be the same as source_frame(), or
// generated from it, e.g. copy of selected block.
- blink::WebFrame* prepared_frame();
+ blink::WebLocalFrame* prepared_frame();
// Node to be use to render preview. May be the same as source_node(), or
// generated from it, e.g. copy of selected block.
const blink::WebNode& prepared_node() const;
int total_page_count() const;
bool generate_draft_pages() const;
- PreviewMetafile* metafile();
+ PdfMetafileSkia* metafile();
gfx::Size GetPrintCanvasSize() const;
int last_error() const;
blink::WebNode source_node_;
scoped_ptr<PrepareFrameAndViewForPrint> prep_frame_view_;
- scoped_ptr<PreviewMetafile> metafile_;
+ scoped_ptr<PdfMetafileSkia> metafile_;
// Total page count in the renderer.
int total_page_count_;