| 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 "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/shared_memory.h" | 10 #include "base/shared_memory.h" |
| 11 #include "base/time.h" | 11 #include "base/time.h" |
| 12 #include "content/renderer/render_view_observer.h" | 12 #include "content/renderer/render_view_observer.h" |
| 13 #include "content/renderer/render_view_observer_tracker.h" | 13 #include "content/renderer/render_view_observer_tracker.h" |
| 14 #include "printing/native_metafile.h" | 14 #include "printing/metafile.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebViewClient.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebViewClient.h" |
| 17 #include "ui/gfx/size.h" | 17 #include "ui/gfx/size.h" |
| 18 | 18 |
| 19 class DictionaryValue; | 19 class DictionaryValue; |
| 20 struct PrintMsg_Print_Params; | 20 struct PrintMsg_Print_Params; |
| 21 struct PrintMsg_PrintPage_Params; | 21 struct PrintMsg_PrintPage_Params; |
| 22 struct PrintMsg_PrintPages_Params; | 22 struct PrintMsg_PrintPages_Params; |
| 23 | 23 |
| 24 #if defined(USE_X11) | 24 #if defined(USE_X11) |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 // It will implicitly revert the document to display CSS media type. | 145 // It will implicitly revert the document to display CSS media type. |
| 146 void PrintPages(const PrintMsg_PrintPages_Params& params, | 146 void PrintPages(const PrintMsg_PrintPages_Params& params, |
| 147 WebKit::WebFrame* frame, | 147 WebKit::WebFrame* frame, |
| 148 WebKit::WebNode* node); | 148 WebKit::WebNode* node); |
| 149 | 149 |
| 150 // Prints the page listed in |params|. | 150 // Prints the page listed in |params|. |
| 151 #if defined(USE_X11) | 151 #if defined(USE_X11) |
| 152 void PrintPageInternal(const PrintMsg_PrintPage_Params& params, | 152 void PrintPageInternal(const PrintMsg_PrintPage_Params& params, |
| 153 const gfx::Size& canvas_size, | 153 const gfx::Size& canvas_size, |
| 154 WebKit::WebFrame* frame, | 154 WebKit::WebFrame* frame, |
| 155 printing::NativeMetafile* metafile, | 155 printing::Metafile* metafile, |
| 156 scoped_ptr<skia::VectorCanvas>* canvas); | 156 scoped_ptr<skia::VectorCanvas>* canvas); |
| 157 #else | 157 #else |
| 158 void PrintPageInternal(const PrintMsg_PrintPage_Params& params, | 158 void PrintPageInternal(const PrintMsg_PrintPage_Params& params, |
| 159 const gfx::Size& canvas_size, | 159 const gfx::Size& canvas_size, |
| 160 WebKit::WebFrame* frame); | 160 WebKit::WebFrame* frame); |
| 161 #endif | 161 #endif |
| 162 | 162 |
| 163 // Render the frame for printing. | 163 // Render the frame for printing. |
| 164 void RenderPagesForPrint(WebKit::WebFrame* frame, WebKit::WebNode* node); | 164 void RenderPagesForPrint(WebKit::WebFrame* frame, WebKit::WebNode* node); |
| 165 | 165 |
| 166 // Render the frame for preview. | 166 // Render the frame for preview. |
| 167 void RenderPagesForPreview(WebKit::WebFrame* frame, WebKit::WebNode* node); | 167 void RenderPagesForPreview(WebKit::WebFrame* frame, WebKit::WebNode* node); |
| 168 | 168 |
| 169 // Renders all the pages listed in |params| for preview. | 169 // Renders all the pages listed in |params| for preview. |
| 170 // On success, Send PrintHostMsg_PagesReadyForPreview message with a | 170 // On success, Send PrintHostMsg_PagesReadyForPreview message with a |
| 171 // valid metafile data handle. | 171 // valid metafile data handle. |
| 172 void CreatePreviewDocument(const PrintMsg_PrintPages_Params& params, | 172 void CreatePreviewDocument(const PrintMsg_PrintPages_Params& params, |
| 173 WebKit::WebFrame* frame, | 173 WebKit::WebFrame* frame, |
| 174 WebKit::WebNode* node); | 174 WebKit::WebNode* node); |
| 175 | 175 |
| 176 // Platform specific helper function for rendering page(s) to |metafile|. | 176 // Platform specific helper function for rendering page(s) to |metafile|. |
| 177 #if defined(OS_WIN) | 177 #if defined(OS_WIN) |
| 178 void RenderPage(const PrintMsg_Print_Params& params, float* scale_factor, | 178 void RenderPage(const PrintMsg_Print_Params& params, float* scale_factor, |
| 179 int page_number, WebKit::WebFrame* frame, | 179 int page_number, WebKit::WebFrame* frame, |
| 180 scoped_ptr<printing::NativeMetafile>* metafile); | 180 scoped_ptr<printing::Metafile>* metafile); |
| 181 #elif defined(OS_MACOSX) | 181 #elif defined(OS_MACOSX) |
| 182 void RenderPage(const gfx::Size& page_size, const gfx::Point& content_origin, | 182 void RenderPage(const gfx::Size& page_size, const gfx::Point& content_origin, |
| 183 const float& scale_factor, int page_number, | 183 const float& scale_factor, int page_number, |
| 184 WebKit::WebFrame* frame, printing::NativeMetafile* metafile); | 184 WebKit::WebFrame* frame, |
| 185 printing::Metafile* metafile); |
| 185 #elif defined(OS_POSIX) | 186 #elif defined(OS_POSIX) |
| 186 bool RenderPages(const PrintMsg_PrintPages_Params& params, | 187 bool RenderPages(const PrintMsg_PrintPages_Params& params, |
| 187 WebKit::WebFrame* frame, | 188 WebKit::WebFrame* frame, |
| 188 WebKit::WebNode* node, | 189 WebKit::WebNode* node, |
| 189 bool send_expected_page_count, | 190 bool send_expected_page_count, |
| 190 int* page_count, | 191 int* page_count, |
| 191 printing::NativeMetafile* metafile); | 192 printing::Metafile* metafile); |
| 192 #endif // defined(OS_WIN) | 193 #endif // defined(OS_WIN) |
| 193 | 194 |
| 194 // Helper methods ----------------------------------------------------------- | 195 // Helper methods ----------------------------------------------------------- |
| 195 | 196 |
| 196 bool CopyAndPrint(WebKit::WebFrame* web_frame); | 197 bool CopyAndPrint(WebKit::WebFrame* web_frame); |
| 197 | 198 |
| 198 bool CopyMetafileDataToSharedMem(printing::NativeMetafile* metafile, | 199 bool CopyMetafileDataToSharedMem(printing::Metafile* metafile, |
| 199 base::SharedMemoryHandle* shared_mem_handle); | 200 base::SharedMemoryHandle* shared_mem_handle); |
| 200 | 201 |
| 201 static void GetPageSizeAndMarginsInPoints( | 202 static void GetPageSizeAndMarginsInPoints( |
| 202 WebKit::WebFrame* frame, | 203 WebKit::WebFrame* frame, |
| 203 int page_index, | 204 int page_index, |
| 204 const PrintMsg_Print_Params& default_params, | 205 const PrintMsg_Print_Params& default_params, |
| 205 double* content_width_in_points, | 206 double* content_width_in_points, |
| 206 double* content_height_in_points, | 207 double* content_height_in_points, |
| 207 double* margin_top_in_points, | 208 double* margin_top_in_points, |
| 208 double* margin_right_in_points, | 209 double* margin_right_in_points, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 238 | 239 |
| 239 scoped_ptr<PrintMsg_PrintPages_Params> print_pages_params_; | 240 scoped_ptr<PrintMsg_PrintPages_Params> print_pages_params_; |
| 240 base::Time last_cancelled_script_print_; | 241 base::Time last_cancelled_script_print_; |
| 241 int user_cancelled_scripted_print_count_; | 242 int user_cancelled_scripted_print_count_; |
| 242 bool is_preview_; | 243 bool is_preview_; |
| 243 | 244 |
| 244 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); | 245 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); |
| 245 }; | 246 }; |
| 246 | 247 |
| 247 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ | 248 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ |
| OLD | NEW |