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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 explicit PrintWebViewHelper(RenderView* render_view); | 82 explicit PrintWebViewHelper(RenderView* render_view); |
83 virtual ~PrintWebViewHelper(); | 83 virtual ~PrintWebViewHelper(); |
84 | 84 |
85 // Prints |frame|. | 85 // Prints |frame|. |
86 void PrintFrame(WebKit::WebFrame* frame, | 86 void PrintFrame(WebKit::WebFrame* frame, |
87 bool script_initiated, | 87 bool script_initiated, |
88 bool is_preview); | 88 bool is_preview); |
89 | 89 |
90 // Message handlers. Public for testing. | 90 // Message handlers. Public for testing. |
91 void OnPrintingDone(int document_cookie, bool success); | 91 void OnPrintingDone(int document_cookie, bool success); |
92 void OnPrintForPrintPreview(); | 92 void OnPrintForPrintPreview(const std::string& job_settings); |
93 void OnPrintPages(); | 93 void OnPrintPages(); |
94 void OnPrintPreview(); | 94 void OnPrintPreview(); |
95 void OnPrintNodeUnderContextMenu(); | 95 void OnPrintNodeUnderContextMenu(); |
96 | 96 |
97 protected: | 97 protected: |
98 bool CopyAndPrint(WebKit::WebFrame* web_frame); | 98 bool CopyAndPrint(WebKit::WebFrame* web_frame); |
99 | 99 |
100 // Prints the page listed in |params|. | 100 // Prints the page listed in |params|. |
101 #if defined(USE_X11) | 101 #if defined(USE_X11) |
102 void PrintPage(const ViewMsg_PrintPage_Params& params, | 102 void PrintPage(const ViewMsg_PrintPage_Params& params, |
(...skipping 10 matching lines...) Expand all Loading... | |
113 // Prints all the pages listed in |params|. | 113 // Prints all the pages listed in |params|. |
114 // It will implicitly revert the document to display CSS media type. | 114 // It will implicitly revert the document to display CSS media type. |
115 void PrintPages(const ViewMsg_PrintPages_Params& params, | 115 void PrintPages(const ViewMsg_PrintPages_Params& params, |
116 WebKit::WebFrame* frame, | 116 WebKit::WebFrame* frame, |
117 WebKit::WebNode* node); | 117 WebKit::WebNode* node); |
118 | 118 |
119 // WebKit::WebViewClient override: | 119 // WebKit::WebViewClient override: |
120 virtual void didStopLoading(); | 120 virtual void didStopLoading(); |
121 | 121 |
122 private: | 122 private: |
123 enum GetSettingsParam { | |
124 DEFAULT, | |
Lei Zhang
2011/02/18 05:21:42
Do you intend to have more types in this enum? If
kmadhusu
2011/02/21 01:30:26
Just for readability and better understanding of t
| |
125 CURRENT, | |
126 }; | |
127 | |
123 static void GetPageSizeAndMarginsInPoints( | 128 static void GetPageSizeAndMarginsInPoints( |
124 WebKit::WebFrame* frame, | 129 WebKit::WebFrame* frame, |
125 int page_index, | 130 int page_index, |
126 const ViewMsg_Print_Params& default_params, | 131 const ViewMsg_Print_Params& default_params, |
127 double* content_width_in_points, | 132 double* content_width_in_points, |
128 double* content_height_in_points, | 133 double* content_height_in_points, |
129 double* margin_top_in_points, | 134 double* margin_top_in_points, |
130 double* margin_right_in_points, | 135 double* margin_right_in_points, |
131 double* margin_bottom_in_points, | 136 double* margin_bottom_in_points, |
132 double* margin_left_in_points); | 137 double* margin_left_in_points); |
133 | 138 |
134 // RenderViewObserver implementation. | 139 // RenderViewObserver implementation. |
135 virtual bool OnMessageReceived(const IPC::Message& message); | 140 virtual bool OnMessageReceived(const IPC::Message& message); |
136 | 141 |
137 // Common method for OnPrintPages() and OnPrintPreview(). | 142 // Common method for OnPrintPages() and OnPrintPreview(). |
138 void OnPrint(bool is_preview); | 143 void OnPrint(bool is_preview); |
139 | 144 |
140 void PrintNode(WebKit::WebNode* node, | 145 void PrintNode(WebKit::WebNode* node, |
141 bool script_initiated, | 146 bool script_initiated, |
142 bool is_preview); | 147 bool is_preview, |
148 bool is_print_for_print_preview); | |
143 | 149 |
144 // Notification when printing is done - signal teardown | 150 // Notification when printing is done - signal teardown |
145 void DidFinishPrinting(bool success); | 151 void DidFinishPrinting(bool success); |
146 | 152 |
153 // Print the pages for print preview. Do not display the native print dialog | |
154 // for user settings. Use the current print settings set by the user in | |
155 // preview tab. | |
156 void PrintForPrintPreview(WebKit::WebFrame* frame, WebKit::WebNode* node); | |
157 | |
147 void Print(WebKit::WebFrame* frame, | 158 void Print(WebKit::WebFrame* frame, |
148 WebKit::WebNode* node, | 159 WebKit::WebNode* node, |
149 bool script_initiated, | 160 bool script_initiated, |
150 bool is_preview); | 161 bool is_preview); |
151 | 162 |
152 void UpdatePrintableSizeInPrintParameters(WebKit::WebFrame* frame, | 163 void UpdatePrintableSizeInPrintParameters(WebKit::WebFrame* frame, |
153 WebKit::WebNode* node, | 164 WebKit::WebNode* node, |
154 ViewMsg_Print_Params* params); | 165 ViewMsg_Print_Params* params); |
155 | 166 |
156 // Initialize print page settings with default settings. | 167 // Initialize print page settings with default settings. |
157 bool InitPrintSettings(WebKit::WebFrame* frame, | 168 bool InitPrintSettings(WebKit::WebFrame* frame, |
158 WebKit::WebNode* node); | 169 WebKit::WebNode* node, |
170 GetSettingsParam setting_type); | |
159 | 171 |
160 // Get the default printer settings. | 172 // Update the current print settings with new |job_settings|. |job_settings| |
161 bool GetDefaultPrintSettings(WebKit::WebFrame* frame, | 173 // is a json string which contains print job details such as printer name, |
162 WebKit::WebNode* node, | 174 // number of copies, page range, etc. |
163 ViewMsg_Print_Params* params); | 175 bool UpdatePrintSettings(const std::string& job_settings); |
176 | |
177 // Get the print settings. |setting_type| determines whether we need to get | |
178 // current settings or default settings. | |
179 bool GetPrintSettings(WebKit::WebFrame* frame, | |
180 WebKit::WebNode* node, | |
181 GetSettingsParam setting_type, | |
182 ViewMsg_Print_Params* params); | |
164 | 183 |
165 // Get final print settings from the user. | 184 // Get final print settings from the user. |
166 // Return false if the user cancels or on error. | 185 // Return false if the user cancels or on error. |
167 bool GetPrintSettingsFromUser(WebKit::WebFrame* frame, | 186 bool GetPrintSettingsFromUser(WebKit::WebFrame* frame, |
168 int expected_pages_count, | 187 int expected_pages_count, |
169 bool use_browser_overlays); | 188 bool use_browser_overlays); |
170 | 189 |
171 // Render the frame for printing. | 190 // Render the frame for printing. |
172 void RenderPagesForPrint(WebKit::WebFrame* frame, | 191 void RenderPagesForPrint(WebKit::WebFrame* frame, |
173 WebKit::WebNode* node); | 192 WebKit::WebNode* node); |
(...skipping 25 matching lines...) Expand all Loading... | |
199 scoped_ptr<ViewMsg_PrintPages_Params> print_pages_params_; | 218 scoped_ptr<ViewMsg_PrintPages_Params> print_pages_params_; |
200 base::Time last_cancelled_script_print_; | 219 base::Time last_cancelled_script_print_; |
201 int user_cancelled_scripted_print_count_; | 220 int user_cancelled_scripted_print_count_; |
202 bool is_preview_; | 221 bool is_preview_; |
203 | 222 |
204 private: | 223 private: |
205 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); | 224 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); |
206 }; | 225 }; |
207 | 226 |
208 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ | 227 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ |
OLD | NEW |