| 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 // Used only for native printing workflow. |
| 176 WebKit::WebNode* node, | 176 bool InitPrintSettings(WebKit::WebFrame* frame); |
| 177 bool is_preview); | |
| 178 | 177 |
| 179 // Initialize print page settings with default settings and prepare the frame | 178 // Initialize print page settings with default settings and prepare the frame |
| 180 // for print. A new PrepareFrameAndViewForPrint is created to fulfill the | 179 // for print. A new PrepareFrameAndViewForPrint is created to fulfill the |
| 181 // request and is filled into the |prepare| argument. | 180 // request and is filled into the |prepare| argument. |
| 181 // Used only for native printing workflow. |
| 182 bool InitPrintSettingsAndPrepareFrame( | 182 bool InitPrintSettingsAndPrepareFrame( |
| 183 WebKit::WebFrame* frame, | 183 WebKit::WebFrame* frame, |
| 184 WebKit::WebNode* node, | 184 WebKit::WebNode* node, |
| 185 scoped_ptr<PrepareFrameAndViewForPrint>* prepare); | 185 scoped_ptr<PrepareFrameAndViewForPrint>* prepare); |
| 186 | 186 |
| 187 // Update the current print settings with new |job_settings|. |job_settings| | 187 // Update the current print settings with new |job_settings|. |job_settings| |
| 188 // dictionary contains print job details such as printer name, number of | 188 // dictionary contains print job details such as printer name, number of |
| 189 // copies, page range, etc. | 189 // copies, page range, etc. |
| 190 bool UpdatePrintSettings(const base::DictionaryValue& job_settings, | 190 bool UpdatePrintSettings(const base::DictionaryValue& job_settings, |
| 191 bool is_preview); | 191 bool is_preview); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 | 327 |
| 328 enum PrintPreviewErrorBuckets { | 328 enum PrintPreviewErrorBuckets { |
| 329 PREVIEW_ERROR_NONE, // Always first. | 329 PREVIEW_ERROR_NONE, // Always first. |
| 330 PREVIEW_ERROR_BAD_SETTING, | 330 PREVIEW_ERROR_BAD_SETTING, |
| 331 PREVIEW_ERROR_METAFILE_COPY_FAILED, | 331 PREVIEW_ERROR_METAFILE_COPY_FAILED, |
| 332 PREVIEW_ERROR_METAFILE_INIT_FAILED, | 332 PREVIEW_ERROR_METAFILE_INIT_FAILED, |
| 333 PREVIEW_ERROR_ZERO_PAGES, | 333 PREVIEW_ERROR_ZERO_PAGES, |
| 334 PREVIEW_ERROR_MAC_DRAFT_METAFILE_INIT_FAILED, | 334 PREVIEW_ERROR_MAC_DRAFT_METAFILE_INIT_FAILED, |
| 335 PREVIEW_ERROR_PAGE_RENDERED_WITHOUT_METAFILE, | 335 PREVIEW_ERROR_PAGE_RENDERED_WITHOUT_METAFILE, |
| 336 PREVIEW_ERROR_UPDATING_PRINT_SETTINGS, | 336 PREVIEW_ERROR_UPDATING_PRINT_SETTINGS, |
| 337 PREVIEW_ERROR_INVALID_PRINTER_SETTINGS, |
| 337 PREVIEW_ERROR_LAST_ENUM // Always last. | 338 PREVIEW_ERROR_LAST_ENUM // Always last. |
| 338 }; | 339 }; |
| 339 | 340 |
| 340 // Keeps track of the state of print preview between messages. | 341 // Keeps track of the state of print preview between messages. |
| 341 class PrintPreviewContext { | 342 class PrintPreviewContext { |
| 342 public: | 343 public: |
| 343 PrintPreviewContext(); | 344 PrintPreviewContext(); |
| 344 ~PrintPreviewContext(); | 345 ~PrintPreviewContext(); |
| 345 | 346 |
| 346 // Initializes the print preview context. Need to be called to set | 347 // 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); | 384 void set_error(enum PrintPreviewErrorBuckets error); |
| 384 | 385 |
| 385 // Getters | 386 // Getters |
| 386 WebKit::WebFrame* frame() const; | 387 WebKit::WebFrame* frame() const; |
| 387 WebKit::WebNode* node() const; | 388 WebKit::WebNode* node() const; |
| 388 int total_page_count() const; | 389 int total_page_count() const; |
| 389 bool generate_draft_pages(); | 390 bool generate_draft_pages(); |
| 390 printing::PreviewMetafile* metafile() const; | 391 printing::PreviewMetafile* metafile() const; |
| 391 const PrintMsg_Print_Params& print_params() const; | 392 const PrintMsg_Print_Params& print_params() const; |
| 392 const gfx::Size& GetPrintCanvasSize() const; | 393 const gfx::Size& GetPrintCanvasSize() const; |
| 394 int last_error() const; |
| 393 | 395 |
| 394 private: | 396 private: |
| 395 enum State { | 397 enum State { |
| 396 UNINITIALIZED, // Not ready to render. | 398 UNINITIALIZED, // Not ready to render. |
| 397 INITIALIZED, // Ready to render. | 399 INITIALIZED, // Ready to render. |
| 398 RENDERING, // Rendering. | 400 RENDERING, // Rendering. |
| 399 DONE // Finished rendering. | 401 DONE // Finished rendering. |
| 400 }; | 402 }; |
| 401 | 403 |
| 402 // Reset some of the internal rendering context. | 404 // Reset some of the internal rendering context. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 432 | 434 |
| 433 State state_; | 435 State state_; |
| 434 }; | 436 }; |
| 435 | 437 |
| 436 PrintPreviewContext print_preview_context_; | 438 PrintPreviewContext print_preview_context_; |
| 437 | 439 |
| 438 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); | 440 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); |
| 439 }; | 441 }; |
| 440 | 442 |
| 441 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ | 443 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ |
| OLD | NEW |