| 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/callback.h" | 10 #include "base/callback.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 // PrintWebViewHelper handles most of the printing grunt work for RenderView. | 62 // PrintWebViewHelper handles most of the printing grunt work for RenderView. |
| 63 // We plan on making print asynchronous and that will require copying the DOM | 63 // We plan on making print asynchronous and that will require copying the DOM |
| 64 // of the document and creating a new WebView with the contents. | 64 // of the document and creating a new WebView with the contents. |
| 65 class PrintWebViewHelper | 65 class PrintWebViewHelper |
| 66 : public content::RenderViewObserver, | 66 : public content::RenderViewObserver, |
| 67 public content::RenderViewObserverTracker<PrintWebViewHelper> { | 67 public content::RenderViewObserverTracker<PrintWebViewHelper> { |
| 68 public: | 68 public: |
| 69 explicit PrintWebViewHelper(content::RenderView* render_view); | 69 explicit PrintWebViewHelper(content::RenderView* render_view); |
| 70 virtual ~PrintWebViewHelper(); | 70 ~PrintWebViewHelper() override; |
| 71 | 71 |
| 72 // Disable print preview and switch to system dialog printing even if full | 72 // Disable print preview and switch to system dialog printing even if full |
| 73 // printing is build-in. This method is used by CEF. | 73 // printing is build-in. This method is used by CEF. |
| 74 static void DisablePreview(); | 74 static void DisablePreview(); |
| 75 | 75 |
| 76 bool IsPrintingEnabled(); | 76 bool IsPrintingEnabled(); |
| 77 | 77 |
| 78 void PrintNode(const blink::WebNode& node); | 78 void PrintNode(const blink::WebNode& node); |
| 79 | 79 |
| 80 private: | 80 private: |
| (...skipping 30 matching lines...) Expand all Loading... |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 enum PrintPreviewRequestType { | 113 enum PrintPreviewRequestType { |
| 114 PRINT_PREVIEW_USER_INITIATED_ENTIRE_FRAME, | 114 PRINT_PREVIEW_USER_INITIATED_ENTIRE_FRAME, |
| 115 PRINT_PREVIEW_USER_INITIATED_SELECTION, | 115 PRINT_PREVIEW_USER_INITIATED_SELECTION, |
| 116 PRINT_PREVIEW_USER_INITIATED_CONTEXT_NODE, | 116 PRINT_PREVIEW_USER_INITIATED_CONTEXT_NODE, |
| 117 PRINT_PREVIEW_SCRIPTED // triggered by window.print(). | 117 PRINT_PREVIEW_SCRIPTED // triggered by window.print(). |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 // RenderViewObserver implementation. | 120 // RenderViewObserver implementation. |
| 121 virtual bool OnMessageReceived(const IPC::Message& message) override; | 121 bool OnMessageReceived(const IPC::Message& message) override; |
| 122 virtual void PrintPage(blink::WebLocalFrame* frame, | 122 void PrintPage(blink::WebLocalFrame* frame, bool user_initiated) override; |
| 123 bool user_initiated) override; | 123 void DidStartLoading() override; |
| 124 virtual void DidStartLoading() override; | 124 void DidStopLoading() override; |
| 125 virtual void DidStopLoading() override; | |
| 126 | 125 |
| 127 // Message handlers --------------------------------------------------------- | 126 // Message handlers --------------------------------------------------------- |
| 128 #if !defined(DISABLE_BASIC_PRINTING) | 127 #if !defined(DISABLE_BASIC_PRINTING) |
| 129 void OnPrintPages(); | 128 void OnPrintPages(); |
| 130 void OnPrintForSystemDialog(); | 129 void OnPrintForSystemDialog(); |
| 131 #endif // !DISABLE_BASIC_PRINTING | 130 #endif // !DISABLE_BASIC_PRINTING |
| 132 void OnInitiatePrintPreview(bool selection_only); | 131 void OnInitiatePrintPreview(bool selection_only); |
| 133 void OnPrintPreview(const base::DictionaryValue& settings); | 132 void OnPrintPreview(const base::DictionaryValue& settings); |
| 134 void OnPrintForPrintPreview(const base::DictionaryValue& job_settings); | 133 void OnPrintForPrintPreview(const base::DictionaryValue& job_settings); |
| 135 void OnPrintingDone(bool success); | 134 void OnPrintingDone(bool success); |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 base::Closure on_stop_loading_closure_; | 460 base::Closure on_stop_loading_closure_; |
| 462 | 461 |
| 463 base::WeakPtrFactory<PrintWebViewHelper> weak_ptr_factory_; | 462 base::WeakPtrFactory<PrintWebViewHelper> weak_ptr_factory_; |
| 464 | 463 |
| 465 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); | 464 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); |
| 466 }; | 465 }; |
| 467 | 466 |
| 468 } // namespace printing | 467 } // namespace printing |
| 469 | 468 |
| 470 #endif // CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ | 469 #endif // CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ |
| OLD | NEW |