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" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 PRINT_PREVIEW_SCRIPTED // triggered by window.print(). | 110 PRINT_PREVIEW_SCRIPTED // triggered by window.print(). |
111 }; | 111 }; |
112 | 112 |
113 // RenderViewObserver implementation. | 113 // RenderViewObserver implementation. |
114 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 114 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
115 virtual void PrintPage(blink::WebFrame* frame, bool user_initiated) OVERRIDE; | 115 virtual void PrintPage(blink::WebFrame* frame, bool user_initiated) OVERRIDE; |
116 virtual void DidStartLoading() OVERRIDE; | 116 virtual void DidStartLoading() OVERRIDE; |
117 virtual void DidStopLoading() OVERRIDE; | 117 virtual void DidStopLoading() OVERRIDE; |
118 | 118 |
119 // Message handlers --------------------------------------------------------- | 119 // Message handlers --------------------------------------------------------- |
120 | |
121 // Print the document. | |
122 void OnPrintPages(); | 120 void OnPrintPages(); |
123 | |
124 // Print the document with the print preview frame/node. | |
125 void OnPrintForSystemDialog(); | 121 void OnPrintForSystemDialog(); |
| 122 void OnInitiatePrintPreview(bool selection_only); |
| 123 void OnPrintPreview(const base::DictionaryValue& settings); |
| 124 void OnPrintForPrintPreview(const base::DictionaryValue& job_settings); |
| 125 void OnPrintingDone(bool success); |
126 | 126 |
127 // Get |page_size| and |content_area| information from | 127 // Get |page_size| and |content_area| information from |
128 // |page_layout_in_points|. | 128 // |page_layout_in_points|. |
129 void GetPageSizeAndContentAreaFromPageLayout( | 129 void GetPageSizeAndContentAreaFromPageLayout( |
130 const PageSizeMargins& page_layout_in_points, | 130 const PageSizeMargins& page_layout_in_points, |
131 gfx::Size* page_size, | 131 gfx::Size* page_size, |
132 gfx::Rect* content_area); | 132 gfx::Rect* content_area); |
133 | 133 |
134 // Update |ignore_css_margins_| based on settings. | 134 // Update |ignore_css_margins_| based on settings. |
135 void UpdateFrameMarginsCssInfo(const base::DictionaryValue& settings); | 135 void UpdateFrameMarginsCssInfo(const base::DictionaryValue& settings); |
136 | 136 |
137 // Returns true if the current destination printer is PRINT_TO_PDF. | 137 // Returns true if the current destination printer is PRINT_TO_PDF. |
138 bool IsPrintToPdfRequested(const base::DictionaryValue& settings); | 138 bool IsPrintToPdfRequested(const base::DictionaryValue& settings); |
139 | 139 |
140 // Initiate print preview. | |
141 void OnInitiatePrintPreview(bool selection_only); | |
142 | |
143 // Start the process of generating a print preview using |settings|. | |
144 void OnPrintPreview(const base::DictionaryValue& settings); | |
145 | |
146 // Prepare frame for creating preview document. | 140 // Prepare frame for creating preview document. |
147 void PrepareFrameForPreviewDocument(); | 141 void PrepareFrameForPreviewDocument(); |
148 | 142 |
149 // Continue creating preview document. | 143 // Continue creating preview document. |
150 void OnFramePreparedForPreviewDocument(); | 144 void OnFramePreparedForPreviewDocument(); |
151 | 145 |
152 // Initialize the print preview document. | 146 // Initialize the print preview document. |
153 bool CreatePreviewDocument(); | 147 bool CreatePreviewDocument(); |
154 | 148 |
155 // Renders a print preview page. |page_number| is 0-based. | 149 // Renders a print preview page. |page_number| is 0-based. |
156 // Returns true if print preview should continue, false on failure. | 150 // Returns true if print preview should continue, false on failure. |
157 bool RenderPreviewPage(int page_number, | 151 bool RenderPreviewPage(int page_number, |
158 const PrintMsg_Print_Params& print_params); | 152 const PrintMsg_Print_Params& print_params); |
159 | 153 |
160 // Finalize the print ready preview document. | 154 // Finalize the print ready preview document. |
161 bool FinalizePrintReadyDocument(); | 155 bool FinalizePrintReadyDocument(); |
162 | 156 |
163 // Print / preview the node under the context menu. | |
164 void OnPrintNodeUnderContextMenu(); | |
165 | |
166 // Print the pages for print preview. Do not display the native print dialog | |
167 // for user settings. |job_settings| has new print job settings values. | |
168 void OnPrintForPrintPreview(const base::DictionaryValue& job_settings); | |
169 | |
170 void OnPrintingDone(bool success); | |
171 | |
172 // Enable/Disable window.print calls. If |blocked| is true window.print | 157 // Enable/Disable window.print calls. If |blocked| is true window.print |
173 // calls will silently fail. Call with |blocked| set to false to reenable. | 158 // calls will silently fail. Call with |blocked| set to false to reenable. |
174 void SetScriptedPrintBlocked(bool blocked); | 159 void SetScriptedPrintBlocked(bool blocked); |
175 | 160 |
176 // Main printing code ------------------------------------------------------- | 161 // Main printing code ------------------------------------------------------- |
177 | 162 |
178 void Print(blink::WebFrame* frame, const blink::WebNode& node); | 163 void Print(blink::WebFrame* frame, const blink::WebNode& node); |
179 | 164 |
180 // Notification when printing is done - signal tear-down/free resources. | 165 // Notification when printing is done - signal tear-down/free resources. |
181 void DidFinishPrinting(PrintingResult result); | 166 void DidFinishPrinting(PrintingResult result); |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 PrintPreviewContext print_preview_context_; | 446 PrintPreviewContext print_preview_context_; |
462 bool is_loading_; | 447 bool is_loading_; |
463 bool is_scripted_preview_delayed_; | 448 bool is_scripted_preview_delayed_; |
464 base::WeakPtrFactory<PrintWebViewHelper> weak_ptr_factory_; | 449 base::WeakPtrFactory<PrintWebViewHelper> weak_ptr_factory_; |
465 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); | 450 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); |
466 }; | 451 }; |
467 | 452 |
468 } // namespace printing | 453 } // namespace printing |
469 | 454 |
470 #endif // CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ | 455 #endif // CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ |
OLD | NEW |