Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: chrome/renderer/print_web_view_helper.h

Issue 9703013: Printing: Catch more error conditions and remove more cruft. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 BlockScriptInitiatedPrinting); 102 BlockScriptInitiatedPrinting);
103 FRIEND_TEST_ALL_PREFIXES(PrintWebViewHelperTest, OnPrintPages); 103 FRIEND_TEST_ALL_PREFIXES(PrintWebViewHelperTest, OnPrintPages);
104 104
105 #if defined(OS_WIN) || defined(OS_MACOSX) 105 #if defined(OS_WIN) || defined(OS_MACOSX)
106 FRIEND_TEST_ALL_PREFIXES(PrintWebViewHelperTest, PrintLayoutTest); 106 FRIEND_TEST_ALL_PREFIXES(PrintWebViewHelperTest, PrintLayoutTest);
107 FRIEND_TEST_ALL_PREFIXES(PrintWebViewHelperTest, PrintWithIframe); 107 FRIEND_TEST_ALL_PREFIXES(PrintWebViewHelperTest, PrintWithIframe);
108 #endif // defined(OS_WIN) || defined(OS_MACOSX) 108 #endif // defined(OS_WIN) || defined(OS_MACOSX)
109 109
110 enum PrintingResult { 110 enum PrintingResult {
111 OK, 111 OK,
112 FAIL_PRINT_INIT,
112 FAIL_PRINT, 113 FAIL_PRINT,
113 FAIL_PREVIEW, 114 FAIL_PREVIEW,
114 }; 115 };
115 116
116 enum PrintPreviewErrorBuckets { 117 enum PrintPreviewErrorBuckets {
117 PREVIEW_ERROR_NONE, // Always first. 118 PREVIEW_ERROR_NONE, // Always first.
118 PREVIEW_ERROR_BAD_SETTING, 119 PREVIEW_ERROR_BAD_SETTING,
119 PREVIEW_ERROR_METAFILE_COPY_FAILED, 120 PREVIEW_ERROR_METAFILE_COPY_FAILED,
120 PREVIEW_ERROR_METAFILE_INIT_FAILED, 121 PREVIEW_ERROR_METAFILE_INIT_FAILED,
121 PREVIEW_ERROR_ZERO_PAGES, 122 PREVIEW_ERROR_ZERO_PAGES,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 187
187 void Print(WebKit::WebFrame* frame, const WebKit::WebNode& node); 188 void Print(WebKit::WebFrame* frame, const WebKit::WebNode& node);
188 189
189 // Notification when printing is done - signal tear-down/free resources. 190 // Notification when printing is done - signal tear-down/free resources.
190 void DidFinishPrinting(PrintingResult result); 191 void DidFinishPrinting(PrintingResult result);
191 192
192 // Print Settings ----------------------------------------------------------- 193 // Print Settings -----------------------------------------------------------
193 194
194 // Initialize print page settings with default settings. 195 // Initialize print page settings with default settings.
195 // Used only for native printing workflow. 196 // Used only for native printing workflow.
196 bool InitPrintSettings(WebKit::WebFrame* frame, const WebKit::WebNode& node); 197 bool InitPrintSettings();
197 198
198 // Initialize print page settings with default settings and prepare the frame 199 // Initialize print page settings with default settings and prepare the frame
199 // for print. A new PrepareFrameAndViewForPrint is created to fulfill the 200 // for print. A new PrepareFrameAndViewForPrint is created to fulfill the
200 // request and is filled into the |prepare| argument. 201 // request and is filled into the |prepare| argument.
201 // Used only for native printing workflow. 202 // Used only for native printing workflow.
202 bool InitPrintSettingsAndPrepareFrame( 203 bool InitPrintSettingsAndPrepareFrame(
203 WebKit::WebFrame* frame, 204 WebKit::WebFrame* frame,
204 const WebKit::WebNode& node, 205 const WebKit::WebNode& node,
205 scoped_ptr<PrepareFrameAndViewForPrint>* prepare); 206 scoped_ptr<PrepareFrameAndViewForPrint>* prepare);
206 207
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 // Returns true if cancelling, false if continuing. 332 // Returns true if cancelling, false if continuing.
332 bool CheckForCancel(); 333 bool CheckForCancel();
333 334
334 // Notifies the browser a print preview page has been rendered. 335 // Notifies the browser a print preview page has been rendered.
335 // |page_number| is 0-based. 336 // |page_number| is 0-based.
336 // For a valid |page_number| with modifiable content, 337 // For a valid |page_number| with modifiable content,
337 // |metafile| is the rendered page. Otherwise |metafile| is NULL. 338 // |metafile| is the rendered page. Otherwise |metafile| is NULL.
338 // Returns true if print preview should continue, false on failure. 339 // Returns true if print preview should continue, false on failure.
339 bool PreviewPageRendered(int page_number, printing::Metafile* metafile); 340 bool PreviewPageRendered(int page_number, printing::Metafile* metafile);
340 341
342 // WebView used only to print the selection.
341 WebKit::WebView* print_web_view_; 343 WebKit::WebView* print_web_view_;
342 344
343 scoped_ptr<PrintMsg_PrintPages_Params> print_pages_params_; 345 scoped_ptr<PrintMsg_PrintPages_Params> print_pages_params_;
344 bool is_preview_enabled_; 346 bool is_preview_enabled_;
345 bool is_print_ready_metafile_sent_; 347 bool is_print_ready_metafile_sent_;
346 bool ignore_css_margins_; 348 bool ignore_css_margins_;
347 349
348 // True if we need to auto fit to page else false. 350 // True if we need to auto fit to page else false.
349 // NOTE: When we print to pdf, we don't fit to page. 351 // NOTE: When we print to pdf, we don't fit to page.
350 bool fit_to_page_; 352 bool fit_to_page_;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 463
462 State state_; 464 State state_;
463 }; 465 };
464 466
465 PrintPreviewContext print_preview_context_; 467 PrintPreviewContext print_preview_context_;
466 468
467 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); 469 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper);
468 }; 470 };
469 471
470 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ 472 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698