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/scoped_ptr.h" | 9 #include "base/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 "chrome/renderer/render_view_observer.h" | 12 #include "chrome/renderer/render_view_observer.h" |
13 #include "printing/native_metafile.h" | 13 #include "printing/native_metafile.h" |
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" |
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebViewClient.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebViewClient.h" |
16 #include "ui/gfx/size.h" | 16 #include "ui/gfx/size.h" |
17 | 17 |
| 18 class DictionaryValue; |
| 19 |
18 namespace gfx { | 20 namespace gfx { |
19 class Size; | 21 class Size; |
20 } | 22 } |
21 | 23 |
22 #if defined(USE_X11) | 24 #if defined(USE_X11) |
23 namespace skia { | 25 namespace skia { |
24 class VectorCanvas; | 26 class VectorCanvas; |
25 } | 27 } |
26 #endif | 28 #endif |
27 | 29 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 explicit PrintWebViewHelper(RenderView* render_view); | 80 explicit PrintWebViewHelper(RenderView* render_view); |
79 virtual ~PrintWebViewHelper(); | 81 virtual ~PrintWebViewHelper(); |
80 | 82 |
81 // Prints |frame|. | 83 // Prints |frame|. |
82 void PrintFrame(WebKit::WebFrame* frame, | 84 void PrintFrame(WebKit::WebFrame* frame, |
83 bool script_initiated, | 85 bool script_initiated, |
84 bool is_preview); | 86 bool is_preview); |
85 | 87 |
86 // Message handlers. Public for testing. | 88 // Message handlers. Public for testing. |
87 void OnPrintingDone(int document_cookie, bool success); | 89 void OnPrintingDone(int document_cookie, bool success); |
88 void OnPrintForPrintPreview(); | 90 |
| 91 // Print the pages for print preview. Do not display the native print dialog |
| 92 // for user settings. |job_settings| has new print job settings values. |
| 93 void OnPrintForPrintPreview(const DictionaryValue& job_settings); |
| 94 |
89 void OnPrintPages(); | 95 void OnPrintPages(); |
90 void OnPrintPreview(); | 96 void OnPrintPreview(); |
91 void OnPrintNodeUnderContextMenu(); | 97 void OnPrintNodeUnderContextMenu(); |
92 | 98 |
93 protected: | 99 protected: |
94 bool CopyAndPrint(WebKit::WebFrame* web_frame); | 100 bool CopyAndPrint(WebKit::WebFrame* web_frame); |
95 | 101 |
96 // Prints the page listed in |params|. | 102 // Prints the page listed in |params|. |
97 #if defined(USE_X11) | 103 #if defined(USE_X11) |
98 void PrintPage(const ViewMsg_PrintPage_Params& params, | 104 void PrintPage(const ViewMsg_PrintPage_Params& params, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 bool is_preview); | 152 bool is_preview); |
147 | 153 |
148 void UpdatePrintableSizeInPrintParameters(WebKit::WebFrame* frame, | 154 void UpdatePrintableSizeInPrintParameters(WebKit::WebFrame* frame, |
149 WebKit::WebNode* node, | 155 WebKit::WebNode* node, |
150 ViewMsg_Print_Params* params); | 156 ViewMsg_Print_Params* params); |
151 | 157 |
152 // Initialize print page settings with default settings. | 158 // Initialize print page settings with default settings. |
153 bool InitPrintSettings(WebKit::WebFrame* frame, | 159 bool InitPrintSettings(WebKit::WebFrame* frame, |
154 WebKit::WebNode* node); | 160 WebKit::WebNode* node); |
155 | 161 |
| 162 // Update the current print settings with new |job_settings|. |job_settings| |
| 163 // dictionary contains print job details such as printer name, number of |
| 164 // copies, page range, etc. |
| 165 bool UpdatePrintSettings(const DictionaryValue& job_settings); |
| 166 |
156 // Get the default printer settings. | 167 // Get the default printer settings. |
157 bool GetDefaultPrintSettings(WebKit::WebFrame* frame, | 168 bool GetDefaultPrintSettings(WebKit::WebFrame* frame, |
158 WebKit::WebNode* node, | 169 WebKit::WebNode* node, |
159 ViewMsg_Print_Params* params); | 170 ViewMsg_Print_Params* params); |
160 | 171 |
161 // Get final print settings from the user. | 172 // Get final print settings from the user. |
162 // Return false if the user cancels or on error. | 173 // Return false if the user cancels or on error. |
163 bool GetPrintSettingsFromUser(WebKit::WebFrame* frame, | 174 bool GetPrintSettingsFromUser(WebKit::WebFrame* frame, |
164 int expected_pages_count, | 175 int expected_pages_count, |
165 bool use_browser_overlays); | 176 bool use_browser_overlays); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 scoped_ptr<ViewMsg_PrintPages_Params> print_pages_params_; | 212 scoped_ptr<ViewMsg_PrintPages_Params> print_pages_params_; |
202 base::Time last_cancelled_script_print_; | 213 base::Time last_cancelled_script_print_; |
203 int user_cancelled_scripted_print_count_; | 214 int user_cancelled_scripted_print_count_; |
204 bool is_preview_; | 215 bool is_preview_; |
205 | 216 |
206 private: | 217 private: |
207 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); | 218 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); |
208 }; | 219 }; |
209 | 220 |
210 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ | 221 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ |
OLD | NEW |