| OLD | NEW | 
|---|
| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 49                               WebKit::WebFrame* frame, | 49                               WebKit::WebFrame* frame, | 
| 50                               const WebKit::WebNode& node); | 50                               const WebKit::WebNode& node); | 
| 51   ~PrepareFrameAndViewForPrint(); | 51   ~PrepareFrameAndViewForPrint(); | 
| 52 | 52 | 
| 53   void UpdatePrintParams(const PrintMsg_Print_Params& print_params); | 53   void UpdatePrintParams(const PrintMsg_Print_Params& print_params); | 
| 54 | 54 | 
| 55   int GetExpectedPageCount() const { | 55   int GetExpectedPageCount() const { | 
| 56     return expected_pages_count_; | 56     return expected_pages_count_; | 
| 57   } | 57   } | 
| 58 | 58 | 
| 59   bool ShouldUseBrowserOverlays() const { | 59   bool ShouldUseBrowserOverlays() const; | 
| 60     return use_browser_overlays_; |  | 
| 61   } |  | 
| 62 | 60 | 
| 63   const gfx::Size& GetPrintCanvasSize() const { | 61   const gfx::Size& GetPrintCanvasSize() const { | 
| 64     return print_canvas_size_; | 62     return print_canvas_size_; | 
| 65   } | 63   } | 
| 66 | 64 | 
| 67   void FinishPrinting(); | 65   void FinishPrinting(); | 
| 68 | 66 | 
| 69  private: | 67  private: | 
| 70   void StartPrinting(const gfx::Size& print_params); | 68   void StartPrinting(const gfx::Size& print_params, int dpi); | 
| 71 | 69 | 
| 72   WebKit::WebFrame* frame_; | 70   WebKit::WebFrame* frame_; | 
| 73   WebKit::WebNode node_to_print_; |  | 
| 74   WebKit::WebView* web_view_; | 71   WebKit::WebView* web_view_; | 
| 75   gfx::Size print_canvas_size_; | 72   gfx::Size print_canvas_size_; | 
| 76   gfx::Size prev_view_size_; | 73   gfx::Size prev_view_size_; | 
| 77   gfx::Size prev_scroll_offset_; | 74   gfx::Size prev_scroll_offset_; | 
| 78   int dpi_; | 75   int dpi_; | 
| 79   int expected_pages_count_; | 76   int expected_pages_count_; | 
| 80   bool use_browser_overlays_; |  | 
| 81   bool finished_; | 77   bool finished_; | 
| 82 | 78 | 
| 83   DISALLOW_COPY_AND_ASSIGN(PrepareFrameAndViewForPrint); | 79   DISALLOW_COPY_AND_ASSIGN(PrepareFrameAndViewForPrint); | 
| 84 }; | 80 }; | 
| 85 | 81 | 
| 86 // PrintWebViewHelper handles most of the printing grunt work for RenderView. | 82 // PrintWebViewHelper handles most of the printing grunt work for RenderView. | 
| 87 // We plan on making print asynchronous and that will require copying the DOM | 83 // We plan on making print asynchronous and that will require copying the DOM | 
| 88 // of the document and creating a new WebView with the contents. | 84 // of the document and creating a new WebView with the contents. | 
| 89 class PrintWebViewHelper | 85 class PrintWebViewHelper | 
| 90     : public content::RenderViewObserver, | 86     : public content::RenderViewObserver, | 
| 91       public content::RenderViewObserverTracker<PrintWebViewHelper>, | 87       public content::RenderViewObserverTracker<PrintWebViewHelper>, | 
| 92       public WebKit::WebViewClient, | 88       public WebKit::WebViewClient, | 
| 93       public WebKit::WebFrameClient { | 89       public WebKit::WebFrameClient { | 
| 94  public: | 90  public: | 
| 95   explicit PrintWebViewHelper(content::RenderView* render_view); | 91   explicit PrintWebViewHelper(content::RenderView* render_view); | 
| 96   virtual ~PrintWebViewHelper(); | 92   virtual ~PrintWebViewHelper(); | 
| 97 | 93 | 
| 98  protected: | 94  protected: | 
| 99   // WebKit::WebViewClient override: | 95   // WebKit::WebViewClient override: | 
| 100   virtual void didStopLoading(); | 96   virtual void didStopLoading(); | 
| 101 | 97 | 
| 102  private: | 98  private: | 
| 103   friend class PrintWebViewHelperTestBase; | 99   friend class PrintWebViewHelperTestBase; | 
| 104   FRIEND_TEST_ALL_PREFIXES(PrintWebViewHelperTest, | 100   FRIEND_TEST_ALL_PREFIXES(PrintWebViewHelperTest, | 
| 105                            BlockScriptInitiatedPrinting); | 101                            BlockScriptInitiatedPrinting); | 
| 106   FRIEND_TEST_ALL_PREFIXES(PrintWebViewHelperTest, OnPrintPages); | 102   FRIEND_TEST_ALL_PREFIXES(PrintWebViewHelperTest, OnPrintPages); | 
|  | 103   FRIEND_TEST_ALL_PREFIXES(PrintWebViewHelperTest, PrintWithMediaQuery); | 
| 107 | 104 | 
| 108 #if defined(OS_WIN) || defined(OS_MACOSX) | 105 #if defined(OS_WIN) || defined(OS_MACOSX) | 
| 109   FRIEND_TEST_ALL_PREFIXES(PrintWebViewHelperTest, PrintLayoutTest); | 106   FRIEND_TEST_ALL_PREFIXES(PrintWebViewHelperTest, PrintLayoutTest); | 
| 110   FRIEND_TEST_ALL_PREFIXES(PrintWebViewHelperTest, PrintWithIframe); | 107   FRIEND_TEST_ALL_PREFIXES(PrintWebViewHelperTest, PrintWithIframe); | 
| 111 #endif  // defined(OS_WIN) || defined(OS_MACOSX) | 108 #endif  // defined(OS_WIN) || defined(OS_MACOSX) | 
| 112 | 109 | 
| 113   // RenderViewObserver implementation. | 110   // RenderViewObserver implementation. | 
| 114   virtual bool OnMessageReceived(const IPC::Message& message); | 111   virtual bool OnMessageReceived(const IPC::Message& message); | 
| 115   virtual void PrintPage(WebKit::WebFrame* frame); | 112   virtual void PrintPage(WebKit::WebFrame* frame); | 
| 116 | 113 | 
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 429 | 426 | 
| 430     State state_; | 427     State state_; | 
| 431   }; | 428   }; | 
| 432 | 429 | 
| 433   PrintPreviewContext print_preview_context_; | 430   PrintPreviewContext print_preview_context_; | 
| 434 | 431 | 
| 435   DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); | 432   DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); | 
| 436 }; | 433 }; | 
| 437 | 434 | 
| 438 #endif  // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ | 435 #endif  // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ | 
| OLD | NEW | 
|---|