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

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

Issue 12087005: Async frame preparation for Preview with support if selection. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months 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
« no previous file with comments | « chrome/renderer/mock_printer.cc ('k') | chrome/renderer/printing/print_web_view_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_PRINTING_PRINT_WEB_VIEW_HELPER_H_ 5 #ifndef CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_
6 #define CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ 6 #define CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 bool source_is_html, 131 bool source_is_html,
132 const base::DictionaryValue& job_settings, 132 const base::DictionaryValue& job_settings,
133 const PrintMsg_Print_Params& params); 133 const PrintMsg_Print_Params& params);
134 134
135 // Initiate print preview. 135 // Initiate print preview.
136 void OnInitiatePrintPreview(); 136 void OnInitiatePrintPreview();
137 137
138 // Start the process of generating a print preview using |settings|. 138 // Start the process of generating a print preview using |settings|.
139 void OnPrintPreview(const base::DictionaryValue& settings); 139 void OnPrintPreview(const base::DictionaryValue& settings);
140 140
141 // Prepare frame for creating preview document.
142 void PrepareFrameForPreviewDocument();
143
144 // Continue creating preview document.
145 void OnFramePreparedForPreviewDocument();
146
141 // Initialize the print preview document. 147 // Initialize the print preview document.
142 bool CreatePreviewDocument(); 148 bool CreatePreviewDocument();
143 149
144 // Renders a print preview page. |page_number| is 0-based. 150 // Renders a print preview page. |page_number| is 0-based.
145 // Returns true if print preview should continue, false on failure. 151 // Returns true if print preview should continue, false on failure.
146 bool RenderPreviewPage(int page_number, 152 bool RenderPreviewPage(int page_number,
147 const PrintMsg_Print_Params& print_params); 153 const PrintMsg_Print_Params& print_params);
148 154
149 // Finalize the print ready preview document. 155 // Finalize the print ready preview document.
150 bool FinalizePrintReadyDocument(); 156 bool FinalizePrintReadyDocument();
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 // True, when printing from print preview. 337 // True, when printing from print preview.
332 bool print_for_preview_; 338 bool print_for_preview_;
333 339
334 scoped_ptr<PrintMsg_PrintPages_Params> old_print_pages_params_; 340 scoped_ptr<PrintMsg_PrintPages_Params> old_print_pages_params_;
335 341
336 // Strings generated by the browser process to be printed as headers and 342 // Strings generated by the browser process to be printed as headers and
337 // footers if requested by the user. 343 // footers if requested by the user.
338 scoped_ptr<base::DictionaryValue> header_footer_info_; 344 scoped_ptr<base::DictionaryValue> header_footer_info_;
339 345
340 // Keeps track of the state of print preview between messages. 346 // Keeps track of the state of print preview between messages.
347 // TODO(vitalybuka): Create PrintPreviewContext when needed and delete after
348 // use. Now it's interaction with veriouse messages is confusing.
Lei Zhang 2013/01/29 01:40:47 typo: veriouse -> various
Vitaly Buka (NO REVIEWS) 2013/01/29 05:14:57 Done.
341 class PrintPreviewContext { 349 class PrintPreviewContext {
342 public: 350 public:
343 PrintPreviewContext(); 351 PrintPreviewContext();
344 ~PrintPreviewContext(); 352 ~PrintPreviewContext();
345 353
346 // Initializes the print preview context. Need to be called to set 354 // Initializes the print preview context. Need to be called to set
347 // the |web_frame| / |web_node| to generate the print preview for. 355 // the |web_frame| / |web_node| to generate the print preview for.
348 void InitWithFrame(WebKit::WebFrame* web_frame); 356 void InitWithFrame(WebKit::WebFrame* web_frame);
349 void InitWithNode(const WebKit::WebNode& web_node); 357 void InitWithNode(const WebKit::WebNode& web_node);
350 358
351 // Does bookkeeping at the beginning of print preview. 359 // Does bookkeeping at the beginning of print preview.
352 void OnPrintPreview(); 360 void OnPrintPreview();
353 361
354 // Create the print preview document. |pages| is empty to print all pages. 362 // Create the print preview document. |pages| is empty to print all pages.
355 bool CreatePreviewDocument(const PrintMsg_Print_Params& params, 363 // Takes ownership of |prepared_frame|.
356 const std::vector<int>& pages, 364 bool CreatePreviewDocument(PrepareFrameAndViewForPrint* prepared_frame,
357 bool ignore_css_margins); 365 const std::vector<int>& pages);
358 366
359 // Called after a page gets rendered. |page_time| is how long the 367 // Called after a page gets rendered. |page_time| is how long the
360 // rendering took. 368 // rendering took.
361 void RenderedPreviewPage(const base::TimeDelta& page_time); 369 void RenderedPreviewPage(const base::TimeDelta& page_time);
362 370
363 // Updates the print preview context when the required pages are rendered. 371 // Updates the print preview context when the required pages are rendered.
364 void AllPagesRendered(); 372 void AllPagesRendered();
365 373
366 // Finalizes the print ready preview document. 374 // Finalizes the print ready preview document.
367 void FinalizePrintReadyDocument(); 375 void FinalizePrintReadyDocument();
368 376
369 // Cleanup after print preview finishes. 377 // Cleanup after print preview finishes.
370 void Finished(); 378 void Finished();
371 379
372 // Cleanup after print preview fails. 380 // Cleanup after print preview fails.
373 void Failed(bool report_error); 381 void Failed(bool report_error);
374 382
375 // Helper functions 383 // Helper functions
376 int GetNextPageNumber(); 384 int GetNextPageNumber();
377 bool IsRendering() const; 385 bool IsRendering() const;
378 bool IsModifiable() const; 386 bool IsModifiable() const;
379 bool IsLastPageOfPrintReadyMetafile() const; 387 bool IsLastPageOfPrintReadyMetafile() const;
380 bool IsFinalPageRendered() const; 388 bool IsFinalPageRendered() const;
381 389
382 // Setters 390 // Setters
383 void set_generate_draft_pages(bool generate_draft_pages); 391 void set_generate_draft_pages(bool generate_draft_pages);
384 void set_error(enum PrintPreviewErrorBuckets error); 392 void set_error(enum PrintPreviewErrorBuckets error);
385 393
386 // Getters 394 // Getters
387 WebKit::WebFrame* frame(); 395 // Original frame for which preview was requested.
388 const WebKit::WebNode& node() const; 396 WebKit::WebFrame* source_frame();
397 // Original node for which preview was requested.
398 const WebKit::WebNode& source_node() const;
399
400 // Frame to be use to render preview. May be the same as source_frame(), or
401 // generated from it, e.g. copy of selected block.
402 WebKit::WebFrame* prepared_frame();
403 // Node to be use to render preview. May be the same as source_node(), or
404 // generated from it, e.g. copy of selected block.
405 const WebKit::WebNode& prepared_node() const;
406
389 int total_page_count() const; 407 int total_page_count() const;
390 bool generate_draft_pages() const; 408 bool generate_draft_pages() const;
391 PreviewMetafile* metafile(); 409 PreviewMetafile* metafile();
392 gfx::Size GetPrintCanvasSize() const; 410 gfx::Size GetPrintCanvasSize() const;
393 int last_error() const; 411 int last_error() const;
394 412
395 private: 413 private:
396 enum State { 414 enum State {
397 UNINITIALIZED, // Not ready to render. 415 UNINITIALIZED, // Not ready to render.
398 INITIALIZED, // Ready to render. 416 INITIALIZED, // Ready to render.
399 RENDERING, // Rendering. 417 RENDERING, // Rendering.
400 DONE // Finished rendering. 418 DONE // Finished rendering.
401 }; 419 };
402 420
403 // Reset some of the internal rendering context. 421 // Reset some of the internal rendering context.
404 void ClearContext(); 422 void ClearContext();
405 423
406 // Specifies what to render for print preview. 424 // Specifies what to render for print preview.
407 WebKit::WebFrame* frame_; 425 WebKit::WebFrame* source_frame_;
408 WebKit::WebNode node_; 426 WebKit::WebNode source_node_;
409 427
410 scoped_ptr<PrepareFrameAndViewForPrint> prep_frame_view_; 428 scoped_ptr<PrepareFrameAndViewForPrint> prep_frame_view_;
411 scoped_ptr<PreviewMetafile> metafile_; 429 scoped_ptr<PreviewMetafile> metafile_;
412 430
413 // Total page count in the renderer. 431 // Total page count in the renderer.
414 int total_page_count_; 432 int total_page_count_;
415 433
416 // The current page to render. 434 // The current page to render.
417 int current_page_index_; 435 int current_page_index_;
418 436
(...skipping 15 matching lines...) Expand all
434 }; 452 };
435 453
436 bool print_node_in_progress_; 454 bool print_node_in_progress_;
437 PrintPreviewContext print_preview_context_; 455 PrintPreviewContext print_preview_context_;
438 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); 456 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper);
439 }; 457 };
440 458
441 } // namespace printing 459 } // namespace printing
442 460
443 #endif // CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ 461 #endif // CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/renderer/mock_printer.cc ('k') | chrome/renderer/printing/print_web_view_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698