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" |
11 #include "base/time.h" | 11 #include "base/time.h" |
12 #include "content/renderer/render_view_observer.h" | 12 #include "content/renderer/render_view_observer.h" |
13 #include "content/renderer/render_view_observer_tracker.h" | 13 #include "content/renderer/render_view_observer_tracker.h" |
14 #include "printing/metafile.h" | 14 #include "printing/metafile.h" |
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" |
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebViewClient.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebViewClient.h" |
17 #include "ui/gfx/size.h" | 17 #include "ui/gfx/size.h" |
18 | 18 |
19 class DictionaryValue; | |
20 struct PrintMsg_Print_Params; | 19 struct PrintMsg_Print_Params; |
21 struct PrintMsg_PrintPage_Params; | 20 struct PrintMsg_PrintPage_Params; |
22 struct PrintMsg_PrintPages_Params; | 21 struct PrintMsg_PrintPages_Params; |
23 | 22 |
| 23 namespace base { |
| 24 class DictionaryValue; |
| 25 } |
| 26 |
24 // Class that calls the Begin and End print functions on the frame and changes | 27 // Class that calls the Begin and End print functions on the frame and changes |
25 // the size of the view temporarily to support full page printing.. | 28 // the size of the view temporarily to support full page printing.. |
26 // Do not serve any events in the time between construction and destruction of | 29 // Do not serve any events in the time between construction and destruction of |
27 // this class because it will cause flicker. | 30 // this class because it will cause flicker. |
28 class PrepareFrameAndViewForPrint { | 31 class PrepareFrameAndViewForPrint { |
29 public: | 32 public: |
30 // Prints |frame|. If |node| is not NULL, then only that node will be | 33 // Prints |frame|. If |node| is not NULL, then only that node will be |
31 // printed. | 34 // printed. |
32 PrepareFrameAndViewForPrint(const PrintMsg_Print_Params& print_params, | 35 PrepareFrameAndViewForPrint(const PrintMsg_Print_Params& print_params, |
33 WebKit::WebFrame* frame, | 36 WebKit::WebFrame* frame, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 103 |
101 // Message handlers --------------------------------------------------------- | 104 // Message handlers --------------------------------------------------------- |
102 | 105 |
103 // Print the document. | 106 // Print the document. |
104 void OnPrintPages(); | 107 void OnPrintPages(); |
105 | 108 |
106 // Initiate print preview. | 109 // Initiate print preview. |
107 void OnInitiatePrintPreview(); | 110 void OnInitiatePrintPreview(); |
108 | 111 |
109 // Generate a print preview using |settings|. | 112 // Generate a print preview using |settings|. |
110 void OnPrintPreview(const DictionaryValue& settings); | 113 void OnPrintPreview(const base::DictionaryValue& settings); |
111 | 114 |
112 // Print / preview the node under the context menu. | 115 // Print / preview the node under the context menu. |
113 void OnPrintNodeUnderContextMenu(); | 116 void OnPrintNodeUnderContextMenu(); |
114 | 117 |
115 // Print the pages for print preview. Do not display the native print dialog | 118 // Print the pages for print preview. Do not display the native print dialog |
116 // for user settings. |job_settings| has new print job settings values. | 119 // for user settings. |job_settings| has new print job settings values. |
117 void OnPrintForPrintPreview(const DictionaryValue& job_settings); | 120 void OnPrintForPrintPreview(const base::DictionaryValue& job_settings); |
118 | 121 |
119 void OnPrintingDone(bool success); | 122 void OnPrintingDone(bool success); |
120 | 123 |
121 // Main printing code ------------------------------------------------------- | 124 // Main printing code ------------------------------------------------------- |
122 | 125 |
123 void Print(WebKit::WebFrame* frame, WebKit::WebNode* node); | 126 void Print(WebKit::WebFrame* frame, WebKit::WebNode* node); |
124 | 127 |
125 void PrintPreview(WebKit::WebFrame* frame, | 128 void PrintPreview(WebKit::WebFrame* frame, |
126 WebKit::WebNode* node, | 129 WebKit::WebNode* node, |
127 const DictionaryValue& settings); | 130 const base::DictionaryValue& settings); |
128 | 131 |
129 enum PrintingResult { | 132 enum PrintingResult { |
130 OK, | 133 OK, |
131 FAIL_PRINT, | 134 FAIL_PRINT, |
132 FAIL_PREVIEW, | 135 FAIL_PREVIEW, |
133 }; | 136 }; |
134 | 137 |
135 // Notification when printing is done - signal tear-down/free resources. | 138 // Notification when printing is done - signal tear-down/free resources. |
136 void DidFinishPrinting(PrintingResult result); | 139 void DidFinishPrinting(PrintingResult result); |
137 | 140 |
138 // Print Settings ----------------------------------------------------------- | 141 // Print Settings ----------------------------------------------------------- |
139 | 142 |
140 // Initialize print page settings with default settings. | 143 // Initialize print page settings with default settings. |
141 bool InitPrintSettings(WebKit::WebFrame* frame, | 144 bool InitPrintSettings(WebKit::WebFrame* frame, |
142 WebKit::WebNode* node); | 145 WebKit::WebNode* node); |
143 | 146 |
144 // Update the current print settings with new |job_settings|. |job_settings| | 147 // Update the current print settings with new |job_settings|. |job_settings| |
145 // dictionary contains print job details such as printer name, number of | 148 // dictionary contains print job details such as printer name, number of |
146 // copies, page range, etc. | 149 // copies, page range, etc. |
147 bool UpdatePrintSettings(const DictionaryValue& job_settings); | 150 bool UpdatePrintSettings(const base::DictionaryValue& job_settings); |
148 | 151 |
149 // Get final print settings from the user. | 152 // Get final print settings from the user. |
150 // Return false if the user cancels or on error. | 153 // Return false if the user cancels or on error. |
151 bool GetPrintSettingsFromUser(WebKit::WebFrame* frame, | 154 bool GetPrintSettingsFromUser(WebKit::WebFrame* frame, |
152 int expected_pages_count, | 155 int expected_pages_count, |
153 bool use_browser_overlays); | 156 bool use_browser_overlays); |
154 | 157 |
155 // Page Printing / Rendering ------------------------------------------------ | 158 // Page Printing / Rendering ------------------------------------------------ |
156 | 159 |
157 // Prints all the pages listed in |params|. | 160 // Prints all the pages listed in |params|. |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 // the failure came from the browser in the first place. | 283 // the failure came from the browser in the first place. |
281 bool notify_browser_of_print_failure_; | 284 bool notify_browser_of_print_failure_; |
282 | 285 |
283 int preview_page_count_; | 286 int preview_page_count_; |
284 scoped_ptr<PrintMsg_PrintPages_Params> old_print_pages_params_; | 287 scoped_ptr<PrintMsg_PrintPages_Params> old_print_pages_params_; |
285 | 288 |
286 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); | 289 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); |
287 }; | 290 }; |
288 | 291 |
289 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ | 292 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ |
OLD | NEW |