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 "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/shared_memory.h" | 10 #include "base/shared_memory.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 // PrintWebViewHelper handles most of the printing grunt work for RenderView. | 68 // PrintWebViewHelper handles most of the printing grunt work for RenderView. |
69 // We plan on making print asynchronous and that will require copying the DOM | 69 // We plan on making print asynchronous and that will require copying the DOM |
70 // of the document and creating a new WebView with the contents. | 70 // of the document and creating a new WebView with the contents. |
71 class PrintWebViewHelper : public RenderViewObserver , | 71 class PrintWebViewHelper : public RenderViewObserver , |
72 public WebKit::WebViewClient, | 72 public WebKit::WebViewClient, |
73 public WebKit::WebFrameClient { | 73 public WebKit::WebFrameClient { |
74 public: | 74 public: |
75 explicit PrintWebViewHelper(RenderView* render_view); | 75 explicit PrintWebViewHelper(RenderView* render_view); |
76 virtual ~PrintWebViewHelper(); | 76 virtual ~PrintWebViewHelper(); |
77 | 77 |
78 // Prints |frame| which called window.print(). | |
79 void ScriptInitiatedPrint(WebKit::WebFrame* frame); | |
80 | |
81 protected: | 78 protected: |
82 // WebKit::WebViewClient override: | 79 // WebKit::WebViewClient override: |
83 virtual void didStopLoading(); | 80 virtual void didStopLoading(); |
84 | 81 |
85 private: | 82 private: |
86 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, BlockScriptInitiatedPrinting); | 83 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, BlockScriptInitiatedPrinting); |
87 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnPrintPages); | 84 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnPrintPages); |
88 | 85 |
89 #if defined(OS_WIN) || defined(OS_MACOSX) | 86 #if defined(OS_WIN) || defined(OS_MACOSX) |
90 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, PrintLayoutTest); | 87 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, PrintLayoutTest); |
91 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, PrintWithIframe); | 88 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, PrintWithIframe); |
92 #endif // defined(OS_WIN) || defined(OS_MACOSX) | 89 #endif // defined(OS_WIN) || defined(OS_MACOSX) |
93 | 90 |
94 // RenderViewObserver implementation. | 91 // RenderViewObserver implementation. |
95 virtual bool OnMessageReceived(const IPC::Message& message); | 92 virtual bool OnMessageReceived(const IPC::Message& message); |
| 93 virtual void printPage(WebKit::WebFrame* frame); |
96 | 94 |
97 // Message handlers --------------------------------------------------------- | 95 // Message handlers --------------------------------------------------------- |
98 | 96 |
99 // Print the document. | 97 // Print the document. |
100 void OnPrintPages(); | 98 void OnPrintPages(); |
101 | 99 |
102 // Generate a print preview using |settings|. | 100 // Generate a print preview using |settings|. |
103 void OnPrintPreview(const DictionaryValue& settings); | 101 void OnPrintPreview(const DictionaryValue& settings); |
104 | 102 |
105 // Print / preview the node under the context menu. | 103 // Print / preview the node under the context menu. |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 | 236 |
239 scoped_ptr<PrintMsg_PrintPages_Params> print_pages_params_; | 237 scoped_ptr<PrintMsg_PrintPages_Params> print_pages_params_; |
240 base::Time last_cancelled_script_print_; | 238 base::Time last_cancelled_script_print_; |
241 int user_cancelled_scripted_print_count_; | 239 int user_cancelled_scripted_print_count_; |
242 bool is_preview_; | 240 bool is_preview_; |
243 | 241 |
244 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); | 242 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); |
245 }; | 243 }; |
246 | 244 |
247 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ | 245 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ |
OLD | NEW |