OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // TODO(sgurun) copied from chrome/renderer. Remove after crbug.com/322276 | 5 // TODO(sgurun) copied from chrome/renderer. Remove after crbug.com/322276 |
6 | 6 |
7 #ifndef AW_RENDERER_PRINT_WEB_VIEW_HELPER_H_ | 7 #ifndef AW_RENDERER_PRINT_WEB_VIEW_HELPER_H_ |
8 #define AW_RENDERER_PRINT_WEB_VIEW_HELPER_H_ | 8 #define AW_RENDERER_PRINT_WEB_VIEW_HELPER_H_ |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 PRINT_PREVIEW_SCRIPTED // triggered by window.print(). | 112 PRINT_PREVIEW_SCRIPTED // triggered by window.print(). |
113 }; | 113 }; |
114 | 114 |
115 // RenderViewObserver implementation. | 115 // RenderViewObserver implementation. |
116 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 116 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
117 virtual void PrintPage(blink::WebFrame* frame, bool user_initiated) OVERRIDE; | 117 virtual void PrintPage(blink::WebFrame* frame, bool user_initiated) OVERRIDE; |
118 virtual void DidStartLoading() OVERRIDE; | 118 virtual void DidStartLoading() OVERRIDE; |
119 virtual void DidStopLoading() OVERRIDE; | 119 virtual void DidStopLoading() OVERRIDE; |
120 | 120 |
121 // Message handlers --------------------------------------------------------- | 121 // Message handlers --------------------------------------------------------- |
122 | |
123 // Print the document. | |
124 void OnPrintPages(); | 122 void OnPrintPages(); |
125 | |
126 // Print the document with the print preview frame/node. | |
127 void OnPrintForSystemDialog(); | 123 void OnPrintForSystemDialog(); |
| 124 void OnInitiatePrintPreview(bool selection_only); |
| 125 void OnPrintPreview(const base::DictionaryValue& settings); |
| 126 void OnPrintForPrintPreview(const base::DictionaryValue& job_settings); |
| 127 void OnPrintingDone(bool success); |
128 | 128 |
129 // Get |page_size| and |content_area| information from | 129 // Get |page_size| and |content_area| information from |
130 // |page_layout_in_points|. | 130 // |page_layout_in_points|. |
131 void GetPageSizeAndContentAreaFromPageLayout( | 131 void GetPageSizeAndContentAreaFromPageLayout( |
132 const PageSizeMargins& page_layout_in_points, | 132 const PageSizeMargins& page_layout_in_points, |
133 gfx::Size* page_size, | 133 gfx::Size* page_size, |
134 gfx::Rect* content_area); | 134 gfx::Rect* content_area); |
135 | 135 |
136 // Update |ignore_css_margins_| based on settings. | 136 // Update |ignore_css_margins_| based on settings. |
137 void UpdateFrameMarginsCssInfo(const base::DictionaryValue& settings); | 137 void UpdateFrameMarginsCssInfo(const base::DictionaryValue& settings); |
(...skipping 13 matching lines...) Expand all Loading... |
151 // via |job_settings|. | 151 // via |job_settings|. |
152 // (2) Source is PDF. This is the first preview request and print scaling | 152 // (2) Source is PDF. This is the first preview request and print scaling |
153 // option is disabled for initiator renderer plugin. | 153 // option is disabled for initiator renderer plugin. |
154 // | 154 // |
155 // In all other cases, we scale the source page to fit the printable area. | 155 // In all other cases, we scale the source page to fit the printable area. |
156 blink::WebPrintScalingOption GetPrintScalingOption( | 156 blink::WebPrintScalingOption GetPrintScalingOption( |
157 bool source_is_html, | 157 bool source_is_html, |
158 const base::DictionaryValue& job_settings, | 158 const base::DictionaryValue& job_settings, |
159 const PrintMsg_Print_Params& params); | 159 const PrintMsg_Print_Params& params); |
160 | 160 |
161 // Initiate print preview. | |
162 void OnInitiatePrintPreview(bool selection_only); | |
163 | |
164 // Start the process of generating a print preview using |settings|. | |
165 void OnPrintPreview(const base::DictionaryValue& settings); | |
166 | |
167 // Prepare frame for creating preview document. | 161 // Prepare frame for creating preview document. |
168 void PrepareFrameForPreviewDocument(); | 162 void PrepareFrameForPreviewDocument(); |
169 | 163 |
170 // Continue creating preview document. | 164 // Continue creating preview document. |
171 void OnFramePreparedForPreviewDocument(); | 165 void OnFramePreparedForPreviewDocument(); |
172 | 166 |
173 // Initialize the print preview document. | 167 // Initialize the print preview document. |
174 bool CreatePreviewDocument(); | 168 bool CreatePreviewDocument(); |
175 | 169 |
176 // Renders a print preview page. |page_number| is 0-based. | 170 // Renders a print preview page. |page_number| is 0-based. |
177 // Returns true if print preview should continue, false on failure. | 171 // Returns true if print preview should continue, false on failure. |
178 bool RenderPreviewPage(int page_number, | 172 bool RenderPreviewPage(int page_number, |
179 const PrintMsg_Print_Params& print_params); | 173 const PrintMsg_Print_Params& print_params); |
180 | 174 |
181 // Finalize the print ready preview document. | 175 // Finalize the print ready preview document. |
182 bool FinalizePrintReadyDocument(); | 176 bool FinalizePrintReadyDocument(); |
183 | 177 |
184 // Print / preview the node under the context menu. | |
185 void OnPrintNodeUnderContextMenu(); | |
186 | |
187 // Print the pages for print preview. Do not display the native print dialog | |
188 // for user settings. |job_settings| has new print job settings values. | |
189 void OnPrintForPrintPreview(const base::DictionaryValue& job_settings); | |
190 | |
191 void OnPrintingDone(bool success); | |
192 | |
193 // Enable/Disable window.print calls. If |blocked| is true window.print | 178 // Enable/Disable window.print calls. If |blocked| is true window.print |
194 // calls will silently fail. Call with |blocked| set to false to reenable. | 179 // calls will silently fail. Call with |blocked| set to false to reenable. |
195 void SetScriptedPrintBlocked(bool blocked); | 180 void SetScriptedPrintBlocked(bool blocked); |
196 | 181 |
197 // Main printing code ------------------------------------------------------- | 182 // Main printing code ------------------------------------------------------- |
198 | 183 |
199 void Print(blink::WebFrame* frame, const blink::WebNode& node); | 184 void Print(blink::WebFrame* frame, const blink::WebNode& node); |
200 | 185 |
201 // Notification when printing is done - signal tear-down/free resources. | 186 // Notification when printing is done - signal tear-down/free resources. |
202 void DidFinishPrinting(PrintingResult result); | 187 void DidFinishPrinting(PrintingResult result); |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 PrintPreviewContext print_preview_context_; | 467 PrintPreviewContext print_preview_context_; |
483 bool is_loading_; | 468 bool is_loading_; |
484 bool is_scripted_preview_delayed_; | 469 bool is_scripted_preview_delayed_; |
485 base::WeakPtrFactory<PrintWebViewHelper> weak_ptr_factory_; | 470 base::WeakPtrFactory<PrintWebViewHelper> weak_ptr_factory_; |
486 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); | 471 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); |
487 }; | 472 }; |
488 | 473 |
489 } // namespace printing | 474 } // namespace printing |
490 | 475 |
491 #endif // AW_RENDERER_PRINT_WEB_VIEW_HELPER_H_ | 476 #endif // AW_RENDERER_PRINT_WEB_VIEW_HELPER_H_ |
OLD | NEW |