| 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" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/shared_memory.h" | 12 #include "base/memory/shared_memory.h" |
| 13 #include "base/memory/weak_ptr.h" |
| 13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 14 #include "content/public/renderer/render_view_observer.h" | 15 #include "content/public/renderer/render_view_observer.h" |
| 15 #include "content/public/renderer/render_view_observer_tracker.h" | 16 #include "content/public/renderer/render_view_observer_tracker.h" |
| 16 #include "printing/metafile_impl.h" | 17 #include "printing/metafile_impl.h" |
| 17 #include "third_party/WebKit/public/platform/WebCanvas.h" | 18 #include "third_party/WebKit/public/platform/WebCanvas.h" |
| 18 #include "third_party/WebKit/public/web/WebNode.h" | 19 #include "third_party/WebKit/public/web/WebNode.h" |
| 19 #include "third_party/WebKit/public/web/WebPrintParams.h" | 20 #include "third_party/WebKit/public/web/WebPrintParams.h" |
| 20 #include "ui/gfx/size.h" | 21 #include "ui/gfx/size.h" |
| 21 | 22 |
| 22 struct PrintMsg_Print_Params; | 23 struct PrintMsg_Print_Params; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 enum PrintPreviewRequestType { | 106 enum PrintPreviewRequestType { |
| 106 PRINT_PREVIEW_USER_INITIATED_ENTIRE_FRAME, | 107 PRINT_PREVIEW_USER_INITIATED_ENTIRE_FRAME, |
| 107 PRINT_PREVIEW_USER_INITIATED_SELECTION, | 108 PRINT_PREVIEW_USER_INITIATED_SELECTION, |
| 108 PRINT_PREVIEW_USER_INITIATED_CONTEXT_NODE, | 109 PRINT_PREVIEW_USER_INITIATED_CONTEXT_NODE, |
| 109 PRINT_PREVIEW_SCRIPTED // triggered by window.print(). | 110 PRINT_PREVIEW_SCRIPTED // triggered by window.print(). |
| 110 }; | 111 }; |
| 111 | 112 |
| 112 // RenderViewObserver implementation. | 113 // RenderViewObserver implementation. |
| 113 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 114 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 114 virtual void PrintPage(WebKit::WebFrame* frame, bool user_initiated) OVERRIDE; | 115 virtual void PrintPage(WebKit::WebFrame* frame, bool user_initiated) OVERRIDE; |
| 116 virtual void DidStartLoading() OVERRIDE; |
| 117 virtual void DidStopLoading() OVERRIDE; |
| 115 | 118 |
| 116 // Message handlers --------------------------------------------------------- | 119 // Message handlers --------------------------------------------------------- |
| 117 | 120 |
| 118 // Print the document. | 121 // Print the document. |
| 119 void OnPrintPages(); | 122 void OnPrintPages(); |
| 120 | 123 |
| 121 // Print the document with the print preview frame/node. | 124 // Print the document with the print preview frame/node. |
| 122 void OnPrintForSystemDialog(); | 125 void OnPrintForSystemDialog(); |
| 123 | 126 |
| 124 // Get |page_size| and |content_area| information from | 127 // Get |page_size| and |content_area| information from |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 bool IsScriptInitiatedPrintTooFrequent(WebKit::WebFrame* frame); | 322 bool IsScriptInitiatedPrintTooFrequent(WebKit::WebFrame* frame); |
| 320 | 323 |
| 321 // Reset the counter for script initiated printing. | 324 // Reset the counter for script initiated printing. |
| 322 // Scripted printing will be allowed to continue. | 325 // Scripted printing will be allowed to continue. |
| 323 void ResetScriptedPrintCount(); | 326 void ResetScriptedPrintCount(); |
| 324 | 327 |
| 325 // Increment the counter for script initiated printing. | 328 // Increment the counter for script initiated printing. |
| 326 // Scripted printing will be blocked for a limited amount of time. | 329 // Scripted printing will be blocked for a limited amount of time. |
| 327 void IncrementScriptedPrintCount(); | 330 void IncrementScriptedPrintCount(); |
| 328 | 331 |
| 332 // Shows scripted print preview when options from plugin are availible. |
| 333 void ShowScriptedPrintPreview(); |
| 334 |
| 329 void RequestPrintPreview(PrintPreviewRequestType type); | 335 void RequestPrintPreview(PrintPreviewRequestType type); |
| 330 | 336 |
| 331 // Checks whether print preview should continue or not. | 337 // Checks whether print preview should continue or not. |
| 332 // Returns true if cancelling, false if continuing. | 338 // Returns true if cancelling, false if continuing. |
| 333 bool CheckForCancel(); | 339 bool CheckForCancel(); |
| 334 | 340 |
| 335 // Notifies the browser a print preview page has been rendered. | 341 // Notifies the browser a print preview page has been rendered. |
| 336 // |page_number| is 0-based. | 342 // |page_number| is 0-based. |
| 337 // For a valid |page_number| with modifiable content, | 343 // For a valid |page_number| with modifiable content, |
| 338 // |metafile| is the rendered page. Otherwise |metafile| is NULL. | 344 // |metafile| is the rendered page. Otherwise |metafile| is NULL. |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 base::TimeDelta document_render_time_; | 477 base::TimeDelta document_render_time_; |
| 472 base::TimeTicks begin_time_; | 478 base::TimeTicks begin_time_; |
| 473 | 479 |
| 474 enum PrintPreviewErrorBuckets error_; | 480 enum PrintPreviewErrorBuckets error_; |
| 475 | 481 |
| 476 State state_; | 482 State state_; |
| 477 }; | 483 }; |
| 478 | 484 |
| 479 bool print_node_in_progress_; | 485 bool print_node_in_progress_; |
| 480 PrintPreviewContext print_preview_context_; | 486 PrintPreviewContext print_preview_context_; |
| 487 bool is_loading_; |
| 488 bool is_scripted_preview_delayed_; |
| 489 base::WeakPtrFactory<PrintWebViewHelper> weak_ptr_factory_; |
| 481 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); | 490 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); |
| 482 }; | 491 }; |
| 483 | 492 |
| 484 } // namespace printing | 493 } // namespace printing |
| 485 | 494 |
| 486 #endif // CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ | 495 #endif // CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ |
| OLD | NEW |