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 "components/printing/renderer/print_web_view_helper.h" | 5 #include "components/printing/renderer/print_web_view_helper.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 42 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
43 #include "third_party/WebKit/public/web/WebPlugin.h" | 43 #include "third_party/WebKit/public/web/WebPlugin.h" |
44 #include "third_party/WebKit/public/web/WebPluginDocument.h" | 44 #include "third_party/WebKit/public/web/WebPluginDocument.h" |
45 #include "third_party/WebKit/public/web/WebPrintParams.h" | 45 #include "third_party/WebKit/public/web/WebPrintParams.h" |
46 #include "third_party/WebKit/public/web/WebPrintPresetOptions.h" | 46 #include "third_party/WebKit/public/web/WebPrintPresetOptions.h" |
47 #include "third_party/WebKit/public/web/WebSandboxFlags.h" | 47 #include "third_party/WebKit/public/web/WebSandboxFlags.h" |
48 #include "third_party/WebKit/public/web/WebScriptSource.h" | 48 #include "third_party/WebKit/public/web/WebScriptSource.h" |
49 #include "third_party/WebKit/public/web/WebSettings.h" | 49 #include "third_party/WebKit/public/web/WebSettings.h" |
50 #include "third_party/WebKit/public/web/WebView.h" | 50 #include "third_party/WebKit/public/web/WebView.h" |
51 #include "third_party/WebKit/public/web/WebViewClient.h" | 51 #include "third_party/WebKit/public/web/WebViewClient.h" |
| 52 #include "third_party/skia/include/core/SkCanvas.h" |
52 #include "ui/base/resource/resource_bundle.h" | 53 #include "ui/base/resource/resource_bundle.h" |
53 | 54 |
54 using content::WebPreferences; | 55 using content::WebPreferences; |
55 | 56 |
56 namespace printing { | 57 namespace printing { |
57 | 58 |
58 namespace { | 59 namespace { |
59 | 60 |
60 #define STATIC_ASSERT_PP_MATCHING_ENUM(a, b) \ | 61 #define STATIC_ASSERT_PP_MATCHING_ENUM(a, b) \ |
61 static_assert(static_cast<int>(a) == static_cast<int>(b), \ | 62 static_assert(static_cast<int>(a) == static_cast<int>(b), \ |
(...skipping 1703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1765 float scale_factor = css_scale_factor * webkit_page_shrink_factor; | 1766 float scale_factor = css_scale_factor * webkit_page_shrink_factor; |
1766 #endif | 1767 #endif |
1767 // TODO(thestig) GetVectorCanvasForNewPage() and RenderPageContent() take a | 1768 // TODO(thestig) GetVectorCanvasForNewPage() and RenderPageContent() take a |
1768 // different scale factor vs Windows. Figure out why and combine the two. | 1769 // different scale factor vs Windows. Figure out why and combine the two. |
1769 #if defined(OS_WIN) | 1770 #if defined(OS_WIN) |
1770 float platform_scale_factor = scale_factor; | 1771 float platform_scale_factor = scale_factor; |
1771 #else | 1772 #else |
1772 float platform_scale_factor = css_scale_factor; | 1773 float platform_scale_factor = css_scale_factor; |
1773 #endif // defined(OS_WIN) | 1774 #endif // defined(OS_WIN) |
1774 | 1775 |
1775 skia::PlatformCanvas* canvas = metafile->GetVectorCanvasForNewPage( | 1776 SkCanvas* canvas = metafile->GetVectorCanvasForNewPage( |
1776 page_size, canvas_area, platform_scale_factor); | 1777 page_size, canvas_area, platform_scale_factor); |
1777 if (!canvas) | 1778 if (!canvas) |
1778 return; | 1779 return; |
1779 | 1780 |
1780 MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile); | 1781 MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile); |
1781 | 1782 |
1782 #if defined(ENABLE_PRINT_PREVIEW) | 1783 #if defined(ENABLE_PRINT_PREVIEW) |
1783 if (params.params.display_header_footer) { | 1784 if (params.params.display_header_footer) { |
1784 // |page_number| is 0-based, so 1 is added. | 1785 // |page_number| is 0-based, so 1 is added. |
1785 PrintHeaderAndFooter(canvas, params.page_number + 1, | 1786 PrintHeaderAndFooter(canvas, params.page_number + 1, |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2248 blink::WebConsoleMessage::LevelWarning, message)); | 2249 blink::WebConsoleMessage::LevelWarning, message)); |
2249 return false; | 2250 return false; |
2250 } | 2251 } |
2251 | 2252 |
2252 void PrintWebViewHelper::ScriptingThrottler::Reset() { | 2253 void PrintWebViewHelper::ScriptingThrottler::Reset() { |
2253 // Reset counter on successful print. | 2254 // Reset counter on successful print. |
2254 count_ = 0; | 2255 count_ = 0; |
2255 } | 2256 } |
2256 | 2257 |
2257 } // namespace printing | 2258 } // namespace printing |
OLD | NEW |