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 #include "chrome/renderer/print_web_view_helper.h" | 5 #include "chrome/renderer/print_web_view_helper.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "printing/page_size_margins.h" | 23 #include "printing/page_size_margins.h" |
24 #include "printing/print_job_constants.h" | 24 #include "printing/print_job_constants.h" |
25 #include "printing/units.h" | 25 #include "printing/units.h" |
26 #include "third_party/skia/include/core/SkRect.h" | 26 #include "third_party/skia/include/core/SkRect.h" |
27 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCanvas.h" | 27 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCanvas.h" |
28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h" | 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h" |
29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" | 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" |
30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" | 31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginDocument.h" |
| 34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" |
33 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" | 35 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" |
34 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques
t.h" | 36 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques
t.h" |
35 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRespon
se.h" | 37 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRespon
se.h" |
36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 38 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
37 #include "ui/base/l10n/l10n_util.h" | 39 #include "ui/base/l10n/l10n_util.h" |
38 #include "ui/gfx/rect.h" | 40 #include "ui/gfx/rect.h" |
39 #include "webkit/glue/webpreferences.h" | 41 #include "webkit/glue/webpreferences.h" |
40 | 42 |
41 #if defined(OS_POSIX) | 43 #if defined(OS_POSIX) |
42 #include "base/process_util.h" | 44 #include "base/process_util.h" |
(...skipping 19 matching lines...) Expand all Loading... |
62 using printing::ConvertPointsToPixelDouble; | 64 using printing::ConvertPointsToPixelDouble; |
63 using printing::ConvertUnit; | 65 using printing::ConvertUnit; |
64 using printing::ConvertUnitDouble; | 66 using printing::ConvertUnitDouble; |
65 using printing::GetHeaderFooterSegmentWidth; | 67 using printing::GetHeaderFooterSegmentWidth; |
66 using printing::PageSizeMargins; | 68 using printing::PageSizeMargins; |
67 using WebKit::WebConsoleMessage; | 69 using WebKit::WebConsoleMessage; |
68 using WebKit::WebDocument; | 70 using WebKit::WebDocument; |
69 using WebKit::WebElement; | 71 using WebKit::WebElement; |
70 using WebKit::WebFrame; | 72 using WebKit::WebFrame; |
71 using WebKit::WebNode; | 73 using WebKit::WebNode; |
| 74 using WebKit::WebPlugin; |
| 75 using WebKit::WebPluginDocument; |
72 using WebKit::WebSize; | 76 using WebKit::WebSize; |
73 using WebKit::WebString; | 77 using WebKit::WebString; |
74 using WebKit::WebURLRequest; | 78 using WebKit::WebURLRequest; |
75 using WebKit::WebView; | 79 using WebKit::WebView; |
76 | 80 |
77 namespace { | 81 namespace { |
78 | 82 |
79 #if defined(USE_SKIA) | 83 #if defined(USE_SKIA) |
80 typedef SkPaint HeaderFooterPaint; | 84 typedef SkPaint HeaderFooterPaint; |
81 #elif defined(OS_MACOSX) | 85 #elif defined(OS_MACOSX) |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 result->set_width(ConvertUnit(print_params.content_size.width(), dpi, | 305 result->set_width(ConvertUnit(print_params.content_size.width(), dpi, |
302 print_params.desired_dpi)); | 306 print_params.desired_dpi)); |
303 | 307 |
304 result->set_height(ConvertUnit(print_params.content_size.height(), dpi, | 308 result->set_height(ConvertUnit(print_params.content_size.height(), dpi, |
305 print_params.desired_dpi)); | 309 print_params.desired_dpi)); |
306 } | 310 } |
307 | 311 |
308 bool PrintingNodeOrPdfFrame(const WebFrame* frame, const WebNode& node) { | 312 bool PrintingNodeOrPdfFrame(const WebFrame* frame, const WebNode& node) { |
309 if (!node.isNull()) | 313 if (!node.isNull()) |
310 return true; | 314 return true; |
311 std::string mime(frame->dataSource()->response().mimeType().utf8()); | 315 if (!frame->document().isPluginDocument()) |
312 return mime == "application/pdf"; | 316 return false; |
| 317 WebPlugin* plugin = frame->document().to<WebPluginDocument>().plugin(); |
| 318 return plugin && plugin->supportsPaginatedPrint(); |
313 } | 319 } |
314 | 320 |
315 bool PrintingFrameHasPageSizeStyle(WebFrame* frame, int total_page_count) { | 321 bool PrintingFrameHasPageSizeStyle(WebFrame* frame, int total_page_count) { |
316 if (!frame) | 322 if (!frame) |
317 return false; | 323 return false; |
318 bool frame_has_custom_page_size_style = false; | 324 bool frame_has_custom_page_size_style = false; |
319 for (int i = 0; i < total_page_count; ++i) { | 325 for (int i = 0; i < total_page_count; ++i) { |
320 if (frame->hasCustomPageSizeStyle(i)) { | 326 if (frame->hasCustomPageSizeStyle(i)) { |
321 frame_has_custom_page_size_style = true; | 327 frame_has_custom_page_size_style = true; |
322 break; | 328 break; |
(...skipping 1489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1812 DCHECK(IsRendering()); | 1818 DCHECK(IsRendering()); |
1813 return prep_frame_view_->GetPrintCanvasSize(); | 1819 return prep_frame_view_->GetPrintCanvasSize(); |
1814 } | 1820 } |
1815 | 1821 |
1816 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { | 1822 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { |
1817 prep_frame_view_.reset(); | 1823 prep_frame_view_.reset(); |
1818 metafile_.reset(); | 1824 metafile_.reset(); |
1819 pages_to_render_.clear(); | 1825 pages_to_render_.clear(); |
1820 error_ = PREVIEW_ERROR_NONE; | 1826 error_ = PREVIEW_ERROR_NONE; |
1821 } | 1827 } |
OLD | NEW |