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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 FAIL_PRINT, | 165 FAIL_PRINT, |
166 FAIL_PREVIEW, | 166 FAIL_PREVIEW, |
167 }; | 167 }; |
168 | 168 |
169 // Notification when printing is done - signal tear-down/free resources. | 169 // Notification when printing is done - signal tear-down/free resources. |
170 void DidFinishPrinting(PrintingResult result); | 170 void DidFinishPrinting(PrintingResult result); |
171 | 171 |
172 // Print Settings ----------------------------------------------------------- | 172 // Print Settings ----------------------------------------------------------- |
173 | 173 |
174 // Initialize print page settings with default settings. | 174 // Initialize print page settings with default settings. |
175 bool InitPrintSettings(WebKit::WebFrame* frame, | 175 bool InitPrintSettings(WebKit::WebFrame* frame); |
176 WebKit::WebNode* node, | |
177 bool is_preview); | |
178 | 176 |
179 // Initialize print page settings with default settings and prepare the frame | 177 // Prepare the frame for print. A new PrepareFrameAndViewForPrint is created |
180 // for print. A new PrepareFrameAndViewForPrint is created to fulfill the | 178 // to fulfill the request and is filled into the |prepare| argument. |
181 // request and is filled into the |prepare| argument. | |
182 bool InitPrintSettingsAndPrepareFrame( | 179 bool InitPrintSettingsAndPrepareFrame( |
183 WebKit::WebFrame* frame, | 180 WebKit::WebFrame* frame, |
184 WebKit::WebNode* node, | 181 WebKit::WebNode* node, |
185 scoped_ptr<PrepareFrameAndViewForPrint>* prepare); | 182 scoped_ptr<PrepareFrameAndViewForPrint>* prepare); |
186 | 183 |
187 // Update the current print settings with new |job_settings|. |job_settings| | 184 // Update the current print settings with new |job_settings|. |job_settings| |
188 // dictionary contains print job details such as printer name, number of | 185 // dictionary contains print job details such as printer name, number of |
189 // copies, page range, etc. | 186 // copies, page range, etc. |
190 bool UpdatePrintSettings(const base::DictionaryValue& job_settings, | 187 bool UpdatePrintSettings(const base::DictionaryValue& job_settings, |
191 bool is_preview); | 188 bool is_preview); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
327 | 324 |
328 enum PrintPreviewErrorBuckets { | 325 enum PrintPreviewErrorBuckets { |
329 PREVIEW_ERROR_NONE, // Always first. | 326 PREVIEW_ERROR_NONE, // Always first. |
330 PREVIEW_ERROR_BAD_SETTING, | 327 PREVIEW_ERROR_BAD_SETTING, |
331 PREVIEW_ERROR_METAFILE_COPY_FAILED, | 328 PREVIEW_ERROR_METAFILE_COPY_FAILED, |
332 PREVIEW_ERROR_METAFILE_INIT_FAILED, | 329 PREVIEW_ERROR_METAFILE_INIT_FAILED, |
333 PREVIEW_ERROR_ZERO_PAGES, | 330 PREVIEW_ERROR_ZERO_PAGES, |
334 PREVIEW_ERROR_MAC_DRAFT_METAFILE_INIT_FAILED, | 331 PREVIEW_ERROR_MAC_DRAFT_METAFILE_INIT_FAILED, |
335 PREVIEW_ERROR_PAGE_RENDERED_WITHOUT_METAFILE, | 332 PREVIEW_ERROR_PAGE_RENDERED_WITHOUT_METAFILE, |
336 PREVIEW_ERROR_UPDATING_PRINT_SETTINGS, | 333 PREVIEW_ERROR_UPDATING_PRINT_SETTINGS, |
334 PREVIEW_ERROR_INVALID_PRINTER_SETTINGS, | |
kmadhusu
2011/09/19 19:09:41
Please don't forget to add add this in the uma xml
arthurhsu
2011/09/19 22:24:49
Will do in a separate CL.
| |
337 PREVIEW_ERROR_LAST_ENUM // Always last. | 335 PREVIEW_ERROR_LAST_ENUM // Always last. |
338 }; | 336 }; |
339 | 337 |
340 // Keeps track of the state of print preview between messages. | 338 // Keeps track of the state of print preview between messages. |
341 class PrintPreviewContext { | 339 class PrintPreviewContext { |
342 public: | 340 public: |
343 PrintPreviewContext(); | 341 PrintPreviewContext(); |
344 ~PrintPreviewContext(); | 342 ~PrintPreviewContext(); |
345 | 343 |
346 // Initializes the print preview context. Need to be called to set | 344 // Initializes the print preview context. Need to be called to set |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
383 void set_error(enum PrintPreviewErrorBuckets error); | 381 void set_error(enum PrintPreviewErrorBuckets error); |
384 | 382 |
385 // Getters | 383 // Getters |
386 WebKit::WebFrame* frame() const; | 384 WebKit::WebFrame* frame() const; |
387 WebKit::WebNode* node() const; | 385 WebKit::WebNode* node() const; |
388 int total_page_count() const; | 386 int total_page_count() const; |
389 bool generate_draft_pages(); | 387 bool generate_draft_pages(); |
390 printing::PreviewMetafile* metafile() const; | 388 printing::PreviewMetafile* metafile() const; |
391 const PrintMsg_Print_Params& print_params() const; | 389 const PrintMsg_Print_Params& print_params() const; |
392 const gfx::Size& GetPrintCanvasSize() const; | 390 const gfx::Size& GetPrintCanvasSize() const; |
391 int last_error() const; | |
393 | 392 |
394 private: | 393 private: |
395 enum State { | 394 enum State { |
396 UNINITIALIZED, // Not ready to render. | 395 UNINITIALIZED, // Not ready to render. |
397 INITIALIZED, // Ready to render. | 396 INITIALIZED, // Ready to render. |
398 RENDERING, // Rendering. | 397 RENDERING, // Rendering. |
399 DONE // Finished rendering. | 398 DONE // Finished rendering. |
400 }; | 399 }; |
401 | 400 |
402 // Reset some of the internal rendering context. | 401 // Reset some of the internal rendering context. |
(...skipping 29 matching lines...) Expand all Loading... | |
432 | 431 |
433 State state_; | 432 State state_; |
434 }; | 433 }; |
435 | 434 |
436 PrintPreviewContext print_preview_context_; | 435 PrintPreviewContext print_preview_context_; |
437 | 436 |
438 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); | 437 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); |
439 }; | 438 }; |
440 | 439 |
441 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ | 440 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ |
OLD | NEW |