Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(666)

Side by Side Diff: chrome/renderer/print_web_view_helper.h

Issue 8585017: PrintPreview: Honor the print media page size and margin values. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ 5 #ifndef CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_
6 #define CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ 6 #define CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 virtual void PrintPage(WebKit::WebFrame* frame); 110 virtual void PrintPage(WebKit::WebFrame* frame);
111 111
112 // Message handlers --------------------------------------------------------- 112 // Message handlers ---------------------------------------------------------
113 113
114 // Print the document. 114 // Print the document.
115 void OnPrintPages(); 115 void OnPrintPages();
116 116
117 // Print the document with the print preview frame/node. 117 // Print the document with the print preview frame/node.
118 void OnPrintForSystemDialog(); 118 void OnPrintForSystemDialog();
119 119
120 // Update |default_margins_requested_| based on settings.
121 void UpdateDefaultMarginsRequested(const base::DictionaryValue& settings);
122
120 // Initiate print preview. 123 // Initiate print preview.
121 void OnInitiatePrintPreview(); 124 void OnInitiatePrintPreview();
122 125
123 // Start the process of generating a print preview using |settings|. 126 // Start the process of generating a print preview using |settings|.
124 void OnPrintPreview(const base::DictionaryValue& settings); 127 void OnPrintPreview(const base::DictionaryValue& settings);
125 128
126 // Initialize the print preview document. 129 // Initialize the print preview document.
127 bool CreatePreviewDocument(); 130 bool CreatePreviewDocument();
128 131
129 // Renders a print preview page. |page_number| is 0-based. 132 // Renders a print preview page. |page_number| is 0-based.
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 239
237 bool CopyAndPrint(WebKit::WebFrame* web_frame); 240 bool CopyAndPrint(WebKit::WebFrame* web_frame);
238 241
239 bool CopyMetafileDataToSharedMem(printing::Metafile* metafile, 242 bool CopyMetafileDataToSharedMem(printing::Metafile* metafile,
240 base::SharedMemoryHandle* shared_mem_handle); 243 base::SharedMemoryHandle* shared_mem_handle);
241 244
242 static void GetPageSizeAndMarginsInPoints( 245 static void GetPageSizeAndMarginsInPoints(
243 WebKit::WebFrame* frame, 246 WebKit::WebFrame* frame,
244 int page_index, 247 int page_index,
245 const PrintMsg_Print_Params& default_params, 248 const PrintMsg_Print_Params& default_params,
246 printing::PageSizeMargins* page_layout_in_points); 249 printing::PageSizeMargins* page_layout_in_points,
250 bool default_margins_requested);
247 251
248 static void UpdatePrintableSizeInPrintParameters( 252 static void UpdatePrintableSizeInPrintParameters(
249 WebKit::WebFrame* frame, 253 WebKit::WebFrame* frame,
250 const WebKit::WebNode& node, 254 const WebKit::WebNode& node,
251 PrepareFrameAndViewForPrint* prepare, 255 PrepareFrameAndViewForPrint* prepare,
252 PrintMsg_Print_Params* params); 256 PrintMsg_Print_Params* params,
257 bool default_margins_requested);
vandebo (ex-Chrome) 2011/11/17 23:05:23 No need to pass this down, just access the member
kmadhusu 2011/12/01 02:15:42 This is a static function.
kmadhusu 2011/12/01 02:15:42 (as we discussed) I am ignoring this comment.
253 258
254 // Given the |device| and |canvas| to draw on, prints the appropriate headers 259 // Given the |device| and |canvas| to draw on, prints the appropriate headers
255 // and footers using strings from |header_footer_info| on to the canvas. 260 // and footers using strings from |header_footer_info| on to the canvas.
256 static void PrintHeaderAndFooter( 261 static void PrintHeaderAndFooter(
257 WebKit::WebCanvas* canvas, 262 WebKit::WebCanvas* canvas,
258 int page_number, 263 int page_number,
259 int total_pages, 264 int total_pages,
260 float webkit_scale_factor, 265 float webkit_scale_factor,
261 const printing::PageSizeMargins& page_layout_in_points, 266 const printing::PageSizeMargins& page_layout_in_points,
262 const base::DictionaryValue& header_footer_info); 267 const base::DictionaryValue& header_footer_info);
(...skipping 30 matching lines...) Expand all
293 // For a valid |page_number| with modifiable content, 298 // For a valid |page_number| with modifiable content,
294 // |metafile| is the rendered page. Otherwise |metafile| is NULL. 299 // |metafile| is the rendered page. Otherwise |metafile| is NULL.
295 // Returns true if print preview should continue, false on failure. 300 // Returns true if print preview should continue, false on failure.
296 bool PreviewPageRendered(int page_number, printing::Metafile* metafile); 301 bool PreviewPageRendered(int page_number, printing::Metafile* metafile);
297 302
298 WebKit::WebView* print_web_view_; 303 WebKit::WebView* print_web_view_;
299 304
300 scoped_ptr<PrintMsg_PrintPages_Params> print_pages_params_; 305 scoped_ptr<PrintMsg_PrintPages_Params> print_pages_params_;
301 bool is_preview_enabled_; 306 bool is_preview_enabled_;
302 bool is_print_ready_metafile_sent_; 307 bool is_print_ready_metafile_sent_;
308 bool default_margins_requested_;
vandebo (ex-Chrome) 2011/11/17 23:05:23 Should this go in PrintPreviewContext since it's o
kmadhusu 2011/12/01 02:15:42 (as we discussed) I am ignoring this comment.
303 309
304 // Used for scripted initiated printing blocking. 310 // Used for scripted initiated printing blocking.
305 base::Time last_cancelled_script_print_; 311 base::Time last_cancelled_script_print_;
306 int user_cancelled_scripted_print_count_; 312 int user_cancelled_scripted_print_count_;
307 313
308 // Let the browser process know of a printing failure. Only set to false when 314 // Let the browser process know of a printing failure. Only set to false when
309 // the failure came from the browser in the first place. 315 // the failure came from the browser in the first place.
310 bool notify_browser_of_print_failure_; 316 bool notify_browser_of_print_failure_;
311 317
312 scoped_ptr<PrintMsg_PrintPages_Params> old_print_pages_params_; 318 scoped_ptr<PrintMsg_PrintPages_Params> old_print_pages_params_;
(...skipping 24 matching lines...) Expand all
337 // Initializes the print preview context. Need to be called to set 343 // Initializes the print preview context. Need to be called to set
338 // the |web_frame| / |web_node| to generate the print preview for. 344 // the |web_frame| / |web_node| to generate the print preview for.
339 void InitWithFrame(WebKit::WebFrame* web_frame); 345 void InitWithFrame(WebKit::WebFrame* web_frame);
340 void InitWithNode(const WebKit::WebNode& web_node); 346 void InitWithNode(const WebKit::WebNode& web_node);
341 347
342 // Does bookkeeping at the beginning of print preview. 348 // Does bookkeeping at the beginning of print preview.
343 void OnPrintPreview(); 349 void OnPrintPreview();
344 350
345 // Create the print preview document. |pages| is empty to print all pages. 351 // Create the print preview document. |pages| is empty to print all pages.
346 bool CreatePreviewDocument(PrintMsg_Print_Params* params, 352 bool CreatePreviewDocument(PrintMsg_Print_Params* params,
347 const std::vector<int>& pages); 353 const std::vector<int>& pages,
354 bool default_margins_requested);
vandebo (ex-Chrome) 2011/11/17 23:05:23 No need to pass this down, just access the member
kmadhusu 2011/12/01 02:15:42 (as we discussed) I am ignoring this comment.
348 355
349 // Called after a page gets rendered. |page_time| is how long the 356 // Called after a page gets rendered. |page_time| is how long the
350 // rendering took. 357 // rendering took.
351 void RenderedPreviewPage(const base::TimeDelta& page_time); 358 void RenderedPreviewPage(const base::TimeDelta& page_time);
352 359
353 // Updates the print preview context when the required pages are rendered. 360 // Updates the print preview context when the required pages are rendered.
354 void AllPagesRendered(); 361 void AllPagesRendered();
355 362
356 // Finalizes the print ready preview document. 363 // Finalizes the print ready preview document.
357 void FinalizePrintReadyDocument(); 364 void FinalizePrintReadyDocument();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 431
425 State state_; 432 State state_;
426 }; 433 };
427 434
428 PrintPreviewContext print_preview_context_; 435 PrintPreviewContext print_preview_context_;
429 436
430 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); 437 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper);
431 }; 438 };
432 439
433 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ 440 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698