OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_PRINTING_PRINT_WEB_VIEW_HELPER_H_ | 5 #ifndef CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ |
6 #define CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ | 6 #define CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "ui/gfx/size.h" | 21 #include "ui/gfx/size.h" |
22 | 22 |
23 struct PrintMsg_Print_Params; | 23 struct PrintMsg_Print_Params; |
24 struct PrintMsg_PrintPage_Params; | 24 struct PrintMsg_PrintPage_Params; |
25 struct PrintMsg_PrintPages_Params; | 25 struct PrintMsg_PrintPages_Params; |
26 | 26 |
27 namespace base { | 27 namespace base { |
28 class DictionaryValue; | 28 class DictionaryValue; |
29 } | 29 } |
30 | 30 |
31 namespace WebKit { | 31 namespace blink { |
32 class WebFrame; | 32 class WebFrame; |
33 class WebView; | 33 class WebView; |
34 } | 34 } |
35 | 35 |
36 namespace printing { | 36 namespace printing { |
37 | 37 |
38 struct PageSizeMargins; | 38 struct PageSizeMargins; |
39 class PrepareFrameAndViewForPrint; | 39 class PrepareFrameAndViewForPrint; |
40 | 40 |
41 // Stores reference to frame using WebVew and unique name. | 41 // Stores reference to frame using WebVew and unique name. |
42 // Workaround to modal dialog issue on Linux. crbug.com/236147. | 42 // Workaround to modal dialog issue on Linux. crbug.com/236147. |
43 class FrameReference { | 43 class FrameReference { |
44 public: | 44 public: |
45 explicit FrameReference(const WebKit::WebFrame* frame); | 45 explicit FrameReference(const blink::WebFrame* frame); |
46 FrameReference(); | 46 FrameReference(); |
47 ~FrameReference(); | 47 ~FrameReference(); |
48 | 48 |
49 void Reset(const WebKit::WebFrame* frame); | 49 void Reset(const blink::WebFrame* frame); |
50 | 50 |
51 WebKit::WebFrame* GetFrame(); | 51 blink::WebFrame* GetFrame(); |
52 WebKit::WebView* view(); | 52 blink::WebView* view(); |
53 | 53 |
54 private: | 54 private: |
55 WebKit::WebView* view_; | 55 blink::WebView* view_; |
56 WebKit::WebString frame_name_; | 56 blink::WebString frame_name_; |
57 }; | 57 }; |
58 | 58 |
59 // PrintWebViewHelper handles most of the printing grunt work for RenderView. | 59 // PrintWebViewHelper handles most of the printing grunt work for RenderView. |
60 // We plan on making print asynchronous and that will require copying the DOM | 60 // We plan on making print asynchronous and that will require copying the DOM |
61 // of the document and creating a new WebView with the contents. | 61 // of the document and creating a new WebView with the contents. |
62 class PrintWebViewHelper | 62 class PrintWebViewHelper |
63 : public content::RenderViewObserver, | 63 : public content::RenderViewObserver, |
64 public content::RenderViewObserverTracker<PrintWebViewHelper> { | 64 public content::RenderViewObserverTracker<PrintWebViewHelper> { |
65 public: | 65 public: |
66 explicit PrintWebViewHelper(content::RenderView* render_view); | 66 explicit PrintWebViewHelper(content::RenderView* render_view); |
67 virtual ~PrintWebViewHelper(); | 67 virtual ~PrintWebViewHelper(); |
68 | 68 |
69 bool IsPrintingEnabled(); | 69 bool IsPrintingEnabled(); |
70 | 70 |
71 void PrintNode(const WebKit::WebNode& node); | 71 void PrintNode(const blink::WebNode& node); |
72 | 72 |
73 private: | 73 private: |
74 friend class PrintWebViewHelperTestBase; | 74 friend class PrintWebViewHelperTestBase; |
75 FRIEND_TEST_ALL_PREFIXES(PrintWebViewHelperTest, | 75 FRIEND_TEST_ALL_PREFIXES(PrintWebViewHelperTest, |
76 BlockScriptInitiatedPrinting); | 76 BlockScriptInitiatedPrinting); |
77 FRIEND_TEST_ALL_PREFIXES(PrintWebViewHelperTest, | 77 FRIEND_TEST_ALL_PREFIXES(PrintWebViewHelperTest, |
78 BlockScriptInitiatedPrintingFromPopup); | 78 BlockScriptInitiatedPrintingFromPopup); |
79 FRIEND_TEST_ALL_PREFIXES(PrintWebViewHelperTest, OnPrintPages); | 79 FRIEND_TEST_ALL_PREFIXES(PrintWebViewHelperTest, OnPrintPages); |
80 | 80 |
81 #if defined(OS_WIN) || defined(OS_MACOSX) | 81 #if defined(OS_WIN) || defined(OS_MACOSX) |
(...skipping 23 matching lines...) Expand all Loading... |
105 | 105 |
106 enum PrintPreviewRequestType { | 106 enum PrintPreviewRequestType { |
107 PRINT_PREVIEW_USER_INITIATED_ENTIRE_FRAME, | 107 PRINT_PREVIEW_USER_INITIATED_ENTIRE_FRAME, |
108 PRINT_PREVIEW_USER_INITIATED_SELECTION, | 108 PRINT_PREVIEW_USER_INITIATED_SELECTION, |
109 PRINT_PREVIEW_USER_INITIATED_CONTEXT_NODE, | 109 PRINT_PREVIEW_USER_INITIATED_CONTEXT_NODE, |
110 PRINT_PREVIEW_SCRIPTED // triggered by window.print(). | 110 PRINT_PREVIEW_SCRIPTED // triggered by window.print(). |
111 }; | 111 }; |
112 | 112 |
113 // RenderViewObserver implementation. | 113 // RenderViewObserver implementation. |
114 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 114 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
115 virtual void PrintPage(WebKit::WebFrame* frame, bool user_initiated) OVERRIDE; | 115 virtual void PrintPage(blink::WebFrame* frame, bool user_initiated) OVERRIDE; |
116 virtual void DidStartLoading() OVERRIDE; | 116 virtual void DidStartLoading() OVERRIDE; |
117 virtual void DidStopLoading() OVERRIDE; | 117 virtual void DidStopLoading() OVERRIDE; |
118 | 118 |
119 // Message handlers --------------------------------------------------------- | 119 // Message handlers --------------------------------------------------------- |
120 | 120 |
121 // Print the document. | 121 // Print the document. |
122 void OnPrintPages(); | 122 void OnPrintPages(); |
123 | 123 |
124 // Print the document with the print preview frame/node. | 124 // Print the document with the print preview frame/node. |
125 void OnPrintForSystemDialog(); | 125 void OnPrintForSystemDialog(); |
(...skipping 18 matching lines...) Expand all Loading... |
144 // SAVE_AS_PDF. | 144 // SAVE_AS_PDF. |
145 // | 145 // |
146 // We crop the source page size to fit the printable area or we print only the | 146 // We crop the source page size to fit the printable area or we print only the |
147 // left top page contents when | 147 // left top page contents when |
148 // (1) Source is PDF and the user has requested not to fit to printable area | 148 // (1) Source is PDF and the user has requested not to fit to printable area |
149 // via |job_settings|. | 149 // via |job_settings|. |
150 // (2) Source is PDF. This is the first preview request and print scaling | 150 // (2) Source is PDF. This is the first preview request and print scaling |
151 // option is disabled for initiator renderer plugin. | 151 // option is disabled for initiator renderer plugin. |
152 // | 152 // |
153 // In all other cases, we scale the source page to fit the printable area. | 153 // In all other cases, we scale the source page to fit the printable area. |
154 WebKit::WebPrintScalingOption GetPrintScalingOption( | 154 blink::WebPrintScalingOption GetPrintScalingOption( |
155 bool source_is_html, | 155 bool source_is_html, |
156 const base::DictionaryValue& job_settings, | 156 const base::DictionaryValue& job_settings, |
157 const PrintMsg_Print_Params& params); | 157 const PrintMsg_Print_Params& params); |
158 | 158 |
159 // Initiate print preview. | 159 // Initiate print preview. |
160 void OnInitiatePrintPreview(bool selection_only); | 160 void OnInitiatePrintPreview(bool selection_only); |
161 | 161 |
162 // Start the process of generating a print preview using |settings|. | 162 // Start the process of generating a print preview using |settings|. |
163 void OnPrintPreview(const base::DictionaryValue& settings); | 163 void OnPrintPreview(const base::DictionaryValue& settings); |
164 | 164 |
(...skipping 22 matching lines...) Expand all Loading... |
187 void OnPrintForPrintPreview(const base::DictionaryValue& job_settings); | 187 void OnPrintForPrintPreview(const base::DictionaryValue& job_settings); |
188 | 188 |
189 void OnPrintingDone(bool success); | 189 void OnPrintingDone(bool success); |
190 | 190 |
191 // Enable/Disable window.print calls. If |blocked| is true window.print | 191 // Enable/Disable window.print calls. If |blocked| is true window.print |
192 // calls will silently fail. Call with |blocked| set to false to reenable. | 192 // calls will silently fail. Call with |blocked| set to false to reenable. |
193 void SetScriptedPrintBlocked(bool blocked); | 193 void SetScriptedPrintBlocked(bool blocked); |
194 | 194 |
195 // Main printing code ------------------------------------------------------- | 195 // Main printing code ------------------------------------------------------- |
196 | 196 |
197 void Print(WebKit::WebFrame* frame, const WebKit::WebNode& node); | 197 void Print(blink::WebFrame* frame, const blink::WebNode& node); |
198 | 198 |
199 // Notification when printing is done - signal tear-down/free resources. | 199 // Notification when printing is done - signal tear-down/free resources. |
200 void DidFinishPrinting(PrintingResult result); | 200 void DidFinishPrinting(PrintingResult result); |
201 | 201 |
202 // Print Settings ----------------------------------------------------------- | 202 // Print Settings ----------------------------------------------------------- |
203 | 203 |
204 // Initialize print page settings with default settings. | 204 // Initialize print page settings with default settings. |
205 // Used only for native printing workflow. | 205 // Used only for native printing workflow. |
206 bool InitPrintSettings(bool fit_to_paper_size); | 206 bool InitPrintSettings(bool fit_to_paper_size); |
207 | 207 |
208 // Calculate number of pages in source document. | 208 // Calculate number of pages in source document. |
209 bool CalculateNumberOfPages(WebKit::WebFrame* frame, | 209 bool CalculateNumberOfPages(blink::WebFrame* frame, |
210 const WebKit::WebNode& node, | 210 const blink::WebNode& node, |
211 int* number_of_pages); | 211 int* number_of_pages); |
212 | 212 |
213 // Update the current print settings with new |passed_job_settings|. | 213 // Update the current print settings with new |passed_job_settings|. |
214 // |passed_job_settings| dictionary contains print job details such as printer | 214 // |passed_job_settings| dictionary contains print job details such as printer |
215 // name, number of copies, page range, etc. | 215 // name, number of copies, page range, etc. |
216 bool UpdatePrintSettings(WebKit::WebFrame* frame, | 216 bool UpdatePrintSettings(blink::WebFrame* frame, |
217 const WebKit::WebNode& node, | 217 const blink::WebNode& node, |
218 const base::DictionaryValue& passed_job_settings); | 218 const base::DictionaryValue& passed_job_settings); |
219 | 219 |
220 // Get final print settings from the user. | 220 // Get final print settings from the user. |
221 // Return false if the user cancels or on error. | 221 // Return false if the user cancels or on error. |
222 bool GetPrintSettingsFromUser(WebKit::WebFrame* frame, | 222 bool GetPrintSettingsFromUser(blink::WebFrame* frame, |
223 const WebKit::WebNode& node, | 223 const blink::WebNode& node, |
224 int expected_pages_count); | 224 int expected_pages_count); |
225 | 225 |
226 // Page Printing / Rendering ------------------------------------------------ | 226 // Page Printing / Rendering ------------------------------------------------ |
227 | 227 |
228 void OnFramePreparedForPrintPages(); | 228 void OnFramePreparedForPrintPages(); |
229 void PrintPages(); | 229 void PrintPages(); |
230 bool PrintPagesNative(WebKit::WebFrame* frame, | 230 bool PrintPagesNative(blink::WebFrame* frame, |
231 int page_count, | 231 int page_count, |
232 const gfx::Size& canvas_size); | 232 const gfx::Size& canvas_size); |
233 void FinishFramePrinting(); | 233 void FinishFramePrinting(); |
234 | 234 |
235 // Prints the page listed in |params|. | 235 // Prints the page listed in |params|. |
236 #if defined(OS_LINUX) || defined(OS_ANDROID) | 236 #if defined(OS_LINUX) || defined(OS_ANDROID) |
237 void PrintPageInternal(const PrintMsg_PrintPage_Params& params, | 237 void PrintPageInternal(const PrintMsg_PrintPage_Params& params, |
238 const gfx::Size& canvas_size, | 238 const gfx::Size& canvas_size, |
239 WebKit::WebFrame* frame, | 239 blink::WebFrame* frame, |
240 Metafile* metafile); | 240 Metafile* metafile); |
241 #else | 241 #else |
242 void PrintPageInternal(const PrintMsg_PrintPage_Params& params, | 242 void PrintPageInternal(const PrintMsg_PrintPage_Params& params, |
243 const gfx::Size& canvas_size, | 243 const gfx::Size& canvas_size, |
244 WebKit::WebFrame* frame); | 244 blink::WebFrame* frame); |
245 #endif | 245 #endif |
246 | 246 |
247 // Render the frame for printing. | 247 // Render the frame for printing. |
248 bool RenderPagesForPrint(WebKit::WebFrame* frame, | 248 bool RenderPagesForPrint(blink::WebFrame* frame, |
249 const WebKit::WebNode& node); | 249 const blink::WebNode& node); |
250 | 250 |
251 // Platform specific helper function for rendering page(s) to |metafile|. | 251 // Platform specific helper function for rendering page(s) to |metafile|. |
252 #if defined(OS_WIN) | 252 #if defined(OS_WIN) |
253 void RenderPage(const PrintMsg_Print_Params& params, | 253 void RenderPage(const PrintMsg_Print_Params& params, |
254 int page_number, | 254 int page_number, |
255 WebKit::WebFrame* frame, | 255 blink::WebFrame* frame, |
256 bool is_preview, | 256 bool is_preview, |
257 Metafile* metafile, | 257 Metafile* metafile, |
258 double* scale_factor, | 258 double* scale_factor, |
259 gfx::Size* page_size_in_dpi, | 259 gfx::Size* page_size_in_dpi, |
260 gfx::Rect* content_area_in_dpi); | 260 gfx::Rect* content_area_in_dpi); |
261 #elif defined(OS_MACOSX) | 261 #elif defined(OS_MACOSX) |
262 void RenderPage(const PrintMsg_Print_Params& params, | 262 void RenderPage(const PrintMsg_Print_Params& params, |
263 int page_number, | 263 int page_number, |
264 WebKit::WebFrame* frame, | 264 blink::WebFrame* frame, |
265 bool is_preview, | 265 bool is_preview, |
266 Metafile* metafile, | 266 Metafile* metafile, |
267 gfx::Size* page_size, | 267 gfx::Size* page_size, |
268 gfx::Rect* content_rect); | 268 gfx::Rect* content_rect); |
269 #endif // defined(OS_WIN) | 269 #endif // defined(OS_WIN) |
270 | 270 |
271 // Renders page contents from |frame| to |content_area| of |canvas|. | 271 // Renders page contents from |frame| to |content_area| of |canvas|. |
272 // |page_number| is zero-based. | 272 // |page_number| is zero-based. |
273 // When method is called, canvas should be setup to draw to |canvas_area| | 273 // When method is called, canvas should be setup to draw to |canvas_area| |
274 // with |scale_factor|. | 274 // with |scale_factor|. |
275 static float RenderPageContent(WebKit::WebFrame* frame, | 275 static float RenderPageContent(blink::WebFrame* frame, |
276 int page_number, | 276 int page_number, |
277 const gfx::Rect& canvas_area, | 277 const gfx::Rect& canvas_area, |
278 const gfx::Rect& content_area, | 278 const gfx::Rect& content_area, |
279 double scale_factor, | 279 double scale_factor, |
280 WebKit::WebCanvas* canvas); | 280 blink::WebCanvas* canvas); |
281 | 281 |
282 // Helper methods ----------------------------------------------------------- | 282 // Helper methods ----------------------------------------------------------- |
283 | 283 |
284 bool CopyMetafileDataToSharedMem(Metafile* metafile, | 284 bool CopyMetafileDataToSharedMem(Metafile* metafile, |
285 base::SharedMemoryHandle* shared_mem_handle); | 285 base::SharedMemoryHandle* shared_mem_handle); |
286 | 286 |
287 // Helper method to get page layout in points and fit to page if needed. | 287 // Helper method to get page layout in points and fit to page if needed. |
288 static void ComputePageLayoutInPointsForCss( | 288 static void ComputePageLayoutInPointsForCss( |
289 WebKit::WebFrame* frame, | 289 blink::WebFrame* frame, |
290 int page_index, | 290 int page_index, |
291 const PrintMsg_Print_Params& default_params, | 291 const PrintMsg_Print_Params& default_params, |
292 bool ignore_css_margins, | 292 bool ignore_css_margins, |
293 double* scale_factor, | 293 double* scale_factor, |
294 PageSizeMargins* page_layout_in_points); | 294 PageSizeMargins* page_layout_in_points); |
295 | 295 |
296 // Given the |device| and |canvas| to draw on, prints the appropriate headers | 296 // Given the |device| and |canvas| to draw on, prints the appropriate headers |
297 // and footers using strings from |header_footer_info| on to the canvas. | 297 // and footers using strings from |header_footer_info| on to the canvas. |
298 static void PrintHeaderAndFooter( | 298 static void PrintHeaderAndFooter( |
299 WebKit::WebCanvas* canvas, | 299 blink::WebCanvas* canvas, |
300 int page_number, | 300 int page_number, |
301 int total_pages, | 301 int total_pages, |
302 float webkit_scale_factor, | 302 float webkit_scale_factor, |
303 const PageSizeMargins& page_layout_in_points, | 303 const PageSizeMargins& page_layout_in_points, |
304 const base::DictionaryValue& header_footer_info, | 304 const base::DictionaryValue& header_footer_info, |
305 const PrintMsg_Print_Params& params); | 305 const PrintMsg_Print_Params& params); |
306 | 306 |
307 bool GetPrintFrame(WebKit::WebFrame** frame); | 307 bool GetPrintFrame(blink::WebFrame** frame); |
308 | 308 |
309 // Script Initiated Printing ------------------------------------------------ | 309 // Script Initiated Printing ------------------------------------------------ |
310 | 310 |
311 // Return true if script initiated printing is currently | 311 // Return true if script initiated printing is currently |
312 // allowed. |user_initiated| should be true when a user event triggered the | 312 // allowed. |user_initiated| should be true when a user event triggered the |
313 // script, most likely by pressing a print button on the page. | 313 // script, most likely by pressing a print button on the page. |
314 bool IsScriptInitiatedPrintAllowed(WebKit::WebFrame* frame, | 314 bool IsScriptInitiatedPrintAllowed(blink::WebFrame* frame, |
315 bool user_initiated); | 315 bool user_initiated); |
316 | 316 |
317 // Returns true if script initiated printing occurs too often. | 317 // Returns true if script initiated printing occurs too often. |
318 bool IsScriptInitiatedPrintTooFrequent(WebKit::WebFrame* frame); | 318 bool IsScriptInitiatedPrintTooFrequent(blink::WebFrame* frame); |
319 | 319 |
320 // Reset the counter for script initiated printing. | 320 // Reset the counter for script initiated printing. |
321 // Scripted printing will be allowed to continue. | 321 // Scripted printing will be allowed to continue. |
322 void ResetScriptedPrintCount(); | 322 void ResetScriptedPrintCount(); |
323 | 323 |
324 // Increment the counter for script initiated printing. | 324 // Increment the counter for script initiated printing. |
325 // Scripted printing will be blocked for a limited amount of time. | 325 // Scripted printing will be blocked for a limited amount of time. |
326 void IncrementScriptedPrintCount(); | 326 void IncrementScriptedPrintCount(); |
327 | 327 |
328 // Shows scripted print preview when options from plugin are availible. | 328 // Shows scripted print preview when options from plugin are availible. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 // Keeps track of the state of print preview between messages. | 370 // Keeps track of the state of print preview between messages. |
371 // TODO(vitalybuka): Create PrintPreviewContext when needed and delete after | 371 // TODO(vitalybuka): Create PrintPreviewContext when needed and delete after |
372 // use. Now it's interaction with various messages is confusing. | 372 // use. Now it's interaction with various messages is confusing. |
373 class PrintPreviewContext { | 373 class PrintPreviewContext { |
374 public: | 374 public: |
375 PrintPreviewContext(); | 375 PrintPreviewContext(); |
376 ~PrintPreviewContext(); | 376 ~PrintPreviewContext(); |
377 | 377 |
378 // Initializes the print preview context. Need to be called to set | 378 // Initializes the print preview context. Need to be called to set |
379 // the |web_frame| / |web_node| to generate the print preview for. | 379 // the |web_frame| / |web_node| to generate the print preview for. |
380 void InitWithFrame(WebKit::WebFrame* web_frame); | 380 void InitWithFrame(blink::WebFrame* web_frame); |
381 void InitWithNode(const WebKit::WebNode& web_node); | 381 void InitWithNode(const blink::WebNode& web_node); |
382 | 382 |
383 // Does bookkeeping at the beginning of print preview. | 383 // Does bookkeeping at the beginning of print preview. |
384 void OnPrintPreview(); | 384 void OnPrintPreview(); |
385 | 385 |
386 // Create the print preview document. |pages| is empty to print all pages. | 386 // Create the print preview document. |pages| is empty to print all pages. |
387 // Takes ownership of |prepared_frame|. | 387 // Takes ownership of |prepared_frame|. |
388 bool CreatePreviewDocument(PrepareFrameAndViewForPrint* prepared_frame, | 388 bool CreatePreviewDocument(PrepareFrameAndViewForPrint* prepared_frame, |
389 const std::vector<int>& pages); | 389 const std::vector<int>& pages); |
390 | 390 |
391 // Called after a page gets rendered. |page_time| is how long the | 391 // Called after a page gets rendered. |page_time| is how long the |
(...skipping 19 matching lines...) Expand all Loading... |
411 bool HasSelection(); | 411 bool HasSelection(); |
412 bool IsLastPageOfPrintReadyMetafile() const; | 412 bool IsLastPageOfPrintReadyMetafile() const; |
413 bool IsFinalPageRendered() const; | 413 bool IsFinalPageRendered() const; |
414 | 414 |
415 // Setters | 415 // Setters |
416 void set_generate_draft_pages(bool generate_draft_pages); | 416 void set_generate_draft_pages(bool generate_draft_pages); |
417 void set_error(enum PrintPreviewErrorBuckets error); | 417 void set_error(enum PrintPreviewErrorBuckets error); |
418 | 418 |
419 // Getters | 419 // Getters |
420 // Original frame for which preview was requested. | 420 // Original frame for which preview was requested. |
421 WebKit::WebFrame* source_frame(); | 421 blink::WebFrame* source_frame(); |
422 // Original node for which preview was requested. | 422 // Original node for which preview was requested. |
423 const WebKit::WebNode& source_node() const; | 423 const blink::WebNode& source_node() const; |
424 | 424 |
425 // Frame to be use to render preview. May be the same as source_frame(), or | 425 // Frame to be use to render preview. May be the same as source_frame(), or |
426 // generated from it, e.g. copy of selected block. | 426 // generated from it, e.g. copy of selected block. |
427 WebKit::WebFrame* prepared_frame(); | 427 blink::WebFrame* prepared_frame(); |
428 // Node to be use to render preview. May be the same as source_node(), or | 428 // Node to be use to render preview. May be the same as source_node(), or |
429 // generated from it, e.g. copy of selected block. | 429 // generated from it, e.g. copy of selected block. |
430 const WebKit::WebNode& prepared_node() const; | 430 const blink::WebNode& prepared_node() const; |
431 | 431 |
432 int total_page_count() const; | 432 int total_page_count() const; |
433 bool generate_draft_pages() const; | 433 bool generate_draft_pages() const; |
434 PreviewMetafile* metafile(); | 434 PreviewMetafile* metafile(); |
435 gfx::Size GetPrintCanvasSize() const; | 435 gfx::Size GetPrintCanvasSize() const; |
436 int last_error() const; | 436 int last_error() const; |
437 | 437 |
438 private: | 438 private: |
439 enum State { | 439 enum State { |
440 UNINITIALIZED, // Not ready to render. | 440 UNINITIALIZED, // Not ready to render. |
441 INITIALIZED, // Ready to render. | 441 INITIALIZED, // Ready to render. |
442 RENDERING, // Rendering. | 442 RENDERING, // Rendering. |
443 DONE // Finished rendering. | 443 DONE // Finished rendering. |
444 }; | 444 }; |
445 | 445 |
446 // Reset some of the internal rendering context. | 446 // Reset some of the internal rendering context. |
447 void ClearContext(); | 447 void ClearContext(); |
448 | 448 |
449 // Specifies what to render for print preview. | 449 // Specifies what to render for print preview. |
450 FrameReference source_frame_; | 450 FrameReference source_frame_; |
451 WebKit::WebNode source_node_; | 451 blink::WebNode source_node_; |
452 | 452 |
453 scoped_ptr<PrepareFrameAndViewForPrint> prep_frame_view_; | 453 scoped_ptr<PrepareFrameAndViewForPrint> prep_frame_view_; |
454 scoped_ptr<PreviewMetafile> metafile_; | 454 scoped_ptr<PreviewMetafile> metafile_; |
455 | 455 |
456 // Total page count in the renderer. | 456 // Total page count in the renderer. |
457 int total_page_count_; | 457 int total_page_count_; |
458 | 458 |
459 // The current page to render. | 459 // The current page to render. |
460 int current_page_index_; | 460 int current_page_index_; |
461 | 461 |
(...skipping 18 matching lines...) Expand all Loading... |
480 PrintPreviewContext print_preview_context_; | 480 PrintPreviewContext print_preview_context_; |
481 bool is_loading_; | 481 bool is_loading_; |
482 bool is_scripted_preview_delayed_; | 482 bool is_scripted_preview_delayed_; |
483 base::WeakPtrFactory<PrintWebViewHelper> weak_ptr_factory_; | 483 base::WeakPtrFactory<PrintWebViewHelper> weak_ptr_factory_; |
484 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); | 484 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); |
485 }; | 485 }; |
486 | 486 |
487 } // namespace printing | 487 } // namespace printing |
488 | 488 |
489 #endif // CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ | 489 #endif // CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ |
OLD | NEW |