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

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

Issue 8136027: Print Preview: Make print preview tab modal. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rename ReloadCloudPrintersList to ReloadPrintersList Created 9 years, 2 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
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
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/shared_memory.h" 12 #include "base/shared_memory.h"
13 #include "base/time.h" 13 #include "base/time.h"
14 #include "content/public/renderer/render_view_observer.h" 14 #include "content/public/renderer/render_view_observer.h"
15 #include "content/public/renderer/render_view_observer_tracker.h" 15 #include "content/public/renderer/render_view_observer_tracker.h"
16 #include "printing/metafile.h" 16 #include "printing/metafile.h"
17 #include "printing/metafile_impl.h" 17 #include "printing/metafile_impl.h"
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCanvas.h" 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCanvas.h"
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h"
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h"
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebViewClient.h" 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebViewClient.h"
22 #include "ui/gfx/size.h" 22 #include "ui/gfx/size.h"
23 23
24 class MessageLoop;
24 struct PrintMsg_Print_Params; 25 struct PrintMsg_Print_Params;
25 struct PrintMsg_PrintPage_Params; 26 struct PrintMsg_PrintPage_Params;
26 struct PrintMsg_PrintPages_Params; 27 struct PrintMsg_PrintPages_Params;
27 28
28 namespace base { 29 namespace base {
29 class DictionaryValue; 30 class DictionaryValue;
30 } 31 }
31 namespace printing { 32 namespace printing {
32 struct PageSizeMargins; 33 struct PageSizeMargins;
33 } 34 }
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 // Returns true if cancelling, false if continuing. 293 // Returns true if cancelling, false if continuing.
293 bool CheckForCancel(); 294 bool CheckForCancel();
294 295
295 // Notifies the browser a print preview page has been rendered. 296 // Notifies the browser a print preview page has been rendered.
296 // |page_number| is 0-based. 297 // |page_number| is 0-based.
297 // For a valid |page_number| with modifiable content, 298 // For a valid |page_number| with modifiable content,
298 // |metafile| is the rendered page. Otherwise |metafile| is NULL. 299 // |metafile| is the rendered page. Otherwise |metafile| is NULL.
299 // Returns true if print preview should continue, false on failure. 300 // Returns true if print preview should continue, false on failure.
300 bool PreviewPageRendered(int page_number, printing::Metafile* metafile); 301 bool PreviewPageRendered(int page_number, printing::Metafile* metafile);
301 302
303 // Stop the nested message loop when print preview has finished.
304 void OnPrintPreviewDone();
305
302 WebKit::WebView* print_web_view_; 306 WebKit::WebView* print_web_view_;
303 307
304 scoped_ptr<PrintMsg_PrintPages_Params> print_pages_params_; 308 scoped_ptr<PrintMsg_PrintPages_Params> print_pages_params_;
305 bool is_preview_; 309 bool is_preview_;
306 bool is_print_ready_metafile_sent_; 310 bool is_print_ready_metafile_sent_;
307 311
308 // Used for scripted initiated printing blocking. 312 // Used for scripted initiated printing blocking.
309 base::Time last_cancelled_script_print_; 313 base::Time last_cancelled_script_print_;
310 int user_cancelled_scripted_print_count_; 314 int user_cancelled_scripted_print_count_;
311 315
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 // Helper functions 373 // Helper functions
370 int GetNextPageNumber(); 374 int GetNextPageNumber();
371 bool IsReadyToRender() const; 375 bool IsReadyToRender() const;
372 bool IsModifiable() const; 376 bool IsModifiable() const;
373 bool IsLastPageOfPrintReadyMetafile() const; 377 bool IsLastPageOfPrintReadyMetafile() const;
374 bool IsFinalPageRendered() const; 378 bool IsFinalPageRendered() const;
375 379
376 // Setters 380 // Setters
377 void set_generate_draft_pages(bool generate_draft_pages); 381 void set_generate_draft_pages(bool generate_draft_pages);
378 void set_error(enum PrintPreviewErrorBuckets error); 382 void set_error(enum PrintPreviewErrorBuckets error);
383 void set_message_loop(MessageLoop* message_loop);
379 384
380 // Getters 385 // Getters
381 WebKit::WebFrame* frame() const; 386 WebKit::WebFrame* frame() const;
382 const WebKit::WebNode& node() const; 387 const WebKit::WebNode& node() const;
388 MessageLoop* message_loop() const;
383 int total_page_count() const; 389 int total_page_count() const;
384 bool generate_draft_pages(); 390 bool generate_draft_pages();
385 printing::PreviewMetafile* metafile() const; 391 printing::PreviewMetafile* metafile() const;
386 const PrintMsg_Print_Params& print_params() const; 392 const PrintMsg_Print_Params& print_params() const;
387 const gfx::Size& GetPrintCanvasSize() const; 393 const gfx::Size& GetPrintCanvasSize() const;
388 int last_error() const; 394 int last_error() const;
389 395
390 private: 396 private:
391 enum State { 397 enum State {
392 UNINITIALIZED, // Not ready to render. 398 UNINITIALIZED, // Not ready to render.
393 INITIALIZED, // Ready to render. 399 INITIALIZED, // Ready to render.
394 RENDERING, // Rendering. 400 RENDERING, // Rendering.
395 DONE // Finished rendering. 401 DONE // Finished rendering.
396 }; 402 };
397 403
398 // Reset some of the internal rendering context. 404 // Reset some of the internal rendering context.
399 void ClearContext(); 405 void ClearContext();
400 406
401 // Specifies what to render for print preview. 407 // Specifies what to render for print preview.
402 WebKit::WebFrame* frame_; 408 WebKit::WebFrame* frame_;
403 WebKit::WebNode node_; 409 WebKit::WebNode node_;
404 410
405 scoped_ptr<PrepareFrameAndViewForPrint> prep_frame_view_; 411 scoped_ptr<PrepareFrameAndViewForPrint> prep_frame_view_;
406 scoped_ptr<printing::PreviewMetafile> metafile_; 412 scoped_ptr<printing::PreviewMetafile> metafile_;
407 scoped_ptr<PrintMsg_Print_Params> print_params_; 413 scoped_ptr<PrintMsg_Print_Params> print_params_;
408 414
415 MessageLoop* message_loop_;
416
409 // Total page count in the renderer. 417 // Total page count in the renderer.
410 int total_page_count_; 418 int total_page_count_;
411 419
412 // The current page to render. 420 // The current page to render.
413 int current_page_index_; 421 int current_page_index_;
414 422
415 // List of page indices that need to be rendered. 423 // List of page indices that need to be rendered.
416 std::vector<int> pages_to_render_; 424 std::vector<int> pages_to_render_;
417 425
418 // True, when draft pages needs to be generated. 426 // True, when draft pages needs to be generated.
419 bool generate_draft_pages_; 427 bool generate_draft_pages_;
420 428
421 // Specifies the total number of pages in the print ready metafile. 429 // Specifies the total number of pages in the print ready metafile.
422 int print_ready_metafile_page_count_; 430 int print_ready_metafile_page_count_;
423 431
424 base::TimeDelta document_render_time_; 432 base::TimeDelta document_render_time_;
425 base::TimeTicks begin_time_; 433 base::TimeTicks begin_time_;
426 434
427 enum PrintPreviewErrorBuckets error_; 435 enum PrintPreviewErrorBuckets error_;
428 436
429 State state_; 437 State state_;
430 }; 438 };
431 439
432 PrintPreviewContext print_preview_context_; 440 PrintPreviewContext print_preview_context_;
433 441
434 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); 442 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper);
435 }; 443 };
436 444
437 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ 445 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698