Chromium Code Reviews| 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 <utility> | |
| 10 #include <vector> | 9 #include <vector> |
| 11 | 10 |
| 12 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/shared_memory.h" | 12 #include "base/shared_memory.h" |
| 14 #include "base/time.h" | 13 #include "base/time.h" |
| 15 #include "content/renderer/render_view_observer.h" | 14 #include "content/renderer/render_view_observer.h" |
| 16 #include "content/renderer/render_view_observer_tracker.h" | 15 #include "content/renderer/render_view_observer_tracker.h" |
| 17 #include "printing/metafile.h" | 16 #include "printing/metafile.h" |
| 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 void OnPrintForSystemDialog(); | 127 void OnPrintForSystemDialog(); |
| 129 | 128 |
| 130 // Initiate print preview. | 129 // Initiate print preview. |
| 131 void OnInitiatePrintPreview(); | 130 void OnInitiatePrintPreview(); |
| 132 | 131 |
| 133 // Start the process of generating a print preview using |settings|. | 132 // Start the process of generating a print preview using |settings|. |
| 134 void OnPrintPreview(const base::DictionaryValue& settings); | 133 void OnPrintPreview(const base::DictionaryValue& settings); |
| 135 // Initialize the print preview document. | 134 // Initialize the print preview document. |
| 136 bool CreatePreviewDocument(); | 135 bool CreatePreviewDocument(); |
| 137 | 136 |
| 138 // Continue generating the print preview. |requested_preview_page_index| | 137 // Continue generating the print preview. |
| 139 // specifies the browser requested preview page index. It is 1-based or | 138 void OnContinuePreview(); |
| 140 // |printing::INVALID_PAGE_INDEX| to continue with next page. | |
| 141 void OnContinuePreview(int requested_preview_page_index); | |
| 142 // Renders a print preview page. |page_number| is 0-based. | 139 // Renders a print preview page. |page_number| is 0-based. |
| 143 void RenderPreviewPage(int page_number); | 140 void RenderPreviewPage(int page_number); |
| 144 // Finalize the print preview document. | 141 // Finalize the print preview document. |
| 145 bool FinalizePreviewDocument(); | 142 bool FinalizePreviewDocument(); |
| 146 | 143 |
| 147 // Abort the preview to put |print_preview_context_| into the 'UNINITIALIZED' | 144 // Abort the preview to put |print_preview_context_| into the 'UNINITIALIZED' |
| 148 // state. | 145 // state. |
| 149 void OnAbortPreview(); | 146 void OnAbortPreview(); |
| 150 | 147 |
| 151 // Print / preview the node under the context menu. | 148 // Print / preview the node under the context menu. |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 | 282 |
| 286 // Notify the browser a print preview page has been rendered. | 283 // Notify the browser a print preview page has been rendered. |
| 287 // |page_number| is 0-based or |printing::INVALID_PAGE_INDEX| to check | 284 // |page_number| is 0-based or |printing::INVALID_PAGE_INDEX| to check |
| 288 // for pending preview requests. | 285 // for pending preview requests. |
| 289 void PreviewPageRendered(int page_number, printing::Metafile* metafile); | 286 void PreviewPageRendered(int page_number, printing::Metafile* metafile); |
| 290 | 287 |
| 291 WebKit::WebView* print_web_view_; | 288 WebKit::WebView* print_web_view_; |
| 292 | 289 |
| 293 scoped_ptr<PrintMsg_PrintPages_Params> print_pages_params_; | 290 scoped_ptr<PrintMsg_PrintPages_Params> print_pages_params_; |
| 294 bool is_preview_; | 291 bool is_preview_; |
| 292 bool is_complete_metafile_already_sent_; | |
| 295 | 293 |
| 296 // Used for scripted initiated printing blocking. | 294 // Used for scripted initiated printing blocking. |
| 297 base::Time last_cancelled_script_print_; | 295 base::Time last_cancelled_script_print_; |
| 298 int user_cancelled_scripted_print_count_; | 296 int user_cancelled_scripted_print_count_; |
| 299 | 297 |
| 300 // Let the browser process know of a printing failure. Only set to false when | 298 // Let the browser process know of a printing failure. Only set to false when |
| 301 // the failure came from the browser in the first place. | 299 // the failure came from the browser in the first place. |
| 302 bool notify_browser_of_print_failure_; | 300 bool notify_browser_of_print_failure_; |
| 303 | 301 |
| 304 scoped_ptr<PrintMsg_PrintPages_Params> old_print_pages_params_; | 302 scoped_ptr<PrintMsg_PrintPages_Params> old_print_pages_params_; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 319 | 317 |
| 320 // Create the print preview document. |pages| is empty to print all pages. | 318 // Create the print preview document. |pages| is empty to print all pages. |
| 321 bool CreatePreviewDocument(PrintMsg_Print_Params* params, | 319 bool CreatePreviewDocument(PrintMsg_Print_Params* params, |
| 322 const std::vector<int>& pages); | 320 const std::vector<int>& pages); |
| 323 | 321 |
| 324 // Called after a page gets rendered. |page_time| is how long the | 322 // Called after a page gets rendered. |page_time| is how long the |
| 325 // rendering took. | 323 // rendering took. |
| 326 void RenderedPreviewPage(const base::TimeDelta& page_time); | 324 void RenderedPreviewPage(const base::TimeDelta& page_time); |
| 327 | 325 |
| 328 // Finalizes the print preview document. | 326 // Finalizes the print preview document. |
| 329 void FinalizePreviewDocument(); | 327 void FinalizePreviewDocument(bool is_complete_metafile_already_sent); |
| 330 | 328 |
| 331 // Cleanup after print preview finishes. | 329 // Cleanup after print preview finishes. |
| 332 void Finished(); | 330 void Finished(); |
| 333 | 331 |
| 334 // Abort the print preview. | 332 // Abort the print preview. |
| 335 void Abort(); | 333 void Abort(); |
| 336 | 334 |
| 337 // Helper functions | 335 // Helper functions |
| 338 int GetNextPageNumber(); | 336 int GetNextPageNumber(); |
| 339 bool IsReadyToRender() const; | 337 bool IsReadyToRender() const; |
| 340 bool IsBusy() const; | 338 bool IsBusy() const; |
| 341 bool IsModifiable() const; | 339 bool IsModifiable() const; |
| 340 bool IsCompleteMetafileReady() const; | |
| 341 | |
| 342 void set_generate_draft_pages(bool generate_draft_pages) { | |
| 343 generate_draft_pages_ = generate_draft_pages; | |
|
vandebo (ex-Chrome)
2011/08/03 20:48:21
Put the implementation in the .cc and move this do
kmadhusu
2011/08/04 20:47:53
Done.
| |
| 344 } | |
| 345 bool generate_draft_pages() { | |
| 346 return generate_draft_pages_; | |
| 347 } | |
| 342 | 348 |
| 343 // Getters | 349 // Getters |
| 344 WebKit::WebFrame* frame() const; | 350 WebKit::WebFrame* frame() const; |
| 345 WebKit::WebNode* node() const; | 351 WebKit::WebNode* node() const; |
| 346 int total_page_count() const; | 352 int total_page_count() const; |
| 347 printing::Metafile* metafile() const; | 353 printing::Metafile* metafile() const; |
| 348 const PrintMsg_Print_Params& print_params() const; | 354 const PrintMsg_Print_Params& print_params() const; |
| 349 const gfx::Size& GetPrintCanvasSize() const; | 355 const gfx::Size& GetPrintCanvasSize() const; |
| 350 | 356 |
| 351 private: | 357 private: |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 363 WebKit::WebFrame* frame_; | 369 WebKit::WebFrame* frame_; |
| 364 scoped_ptr<WebKit::WebNode> node_; | 370 scoped_ptr<WebKit::WebNode> node_; |
| 365 | 371 |
| 366 scoped_ptr<PrepareFrameAndViewForPrint> prep_frame_view_; | 372 scoped_ptr<PrepareFrameAndViewForPrint> prep_frame_view_; |
| 367 scoped_ptr<printing::Metafile> metafile_; | 373 scoped_ptr<printing::Metafile> metafile_; |
| 368 scoped_ptr<PrintMsg_Print_Params> print_params_; | 374 scoped_ptr<PrintMsg_Print_Params> print_params_; |
| 369 | 375 |
| 370 // Total page count in the renderer. | 376 // Total page count in the renderer. |
| 371 int total_page_count_; | 377 int total_page_count_; |
| 372 | 378 |
| 373 // Number of pages to render. | 379 // Store the preview page index list. |
|
vandebo (ex-Chrome)
2011/08/03 20:48:21
This comment is opaque, I'm not even sure what it
kmadhusu
2011/08/04 20:47:53
Fixed.
| |
| 374 int actual_page_count_; | 380 std::vector<int> render_page_list_; |
| 375 | 381 |
| 376 // The current page to render. | 382 // True, when draft pages needs to be generated. |
| 377 int current_page_number_; | 383 bool generate_draft_pages_; |
| 378 | 384 |
| 379 // |rendered_pages_| tracks which pages need to be printed as well as | 385 // Specifies the total number of pages in complete metafile. |
| 380 // the page slot it should be printed in. See GetPageSlotForPage. | 386 int complete_metafile_page_count_; |
| 381 typedef std::pair<bool, int> PreviewPageInfo; | 387 |
| 382 std::vector<PreviewPageInfo> rendered_pages_; | 388 // Specifies the current list index. |
|
vandebo (ex-Chrome)
2011/08/03 20:48:21
Probably best to put this next to render_page_list
kmadhusu
2011/08/04 20:47:53
Done.
| |
| 389 int render_page_list_index_; | |
| 383 | 390 |
| 384 base::TimeDelta document_render_time_; | 391 base::TimeDelta document_render_time_; |
| 385 base::TimeTicks begin_time_; | 392 base::TimeTicks begin_time_; |
| 386 | 393 |
| 387 State state_; | 394 State state_; |
| 388 }; | 395 }; |
| 389 | 396 |
| 390 PrintPreviewContext print_preview_context_; | 397 PrintPreviewContext print_preview_context_; |
| 391 | 398 |
| 392 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); | 399 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); |
| 393 }; | 400 }; |
| 394 | 401 |
| 395 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ | 402 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ |
| OLD | NEW |