OLD | NEW |
1 // Copyright (c) 2010 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 #define PEPPER_APIS_ENABLED 1 | 5 #define PEPPER_APIS_ENABLED 1 |
6 | 6 |
7 #include "chrome/renderer/webplugin_delegate_pepper.h" | 7 #include "chrome/renderer/webplugin_delegate_pepper.h" |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #if defined(OS_LINUX) | 12 #if defined(OS_LINUX) |
13 #include <unistd.h> | 13 #include <unistd.h> |
14 #endif | 14 #endif |
15 | 15 |
16 #include "base/file_path.h" | 16 #include "base/file_path.h" |
17 #include "base/file_util.h" | 17 #include "base/file_util.h" |
18 #if defined(OS_MACOSX) | |
19 #include "base/mac/mac_util.h" | |
20 #endif | |
21 #include "base/md5.h" | 18 #include "base/md5.h" |
22 #include "base/message_loop.h" | 19 #include "base/message_loop.h" |
23 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
24 #include "base/metrics/stats_counters.h" | 21 #include "base/metrics/stats_counters.h" |
25 #include "base/path_service.h" | 22 #include "base/path_service.h" |
26 #include "base/process_util.h" | 23 #include "base/process_util.h" |
27 #if defined(OS_MACOSX) | |
28 #include "base/mac/scoped_cftyperef.h" | |
29 #endif | |
30 #include "base/scoped_ptr.h" | 24 #include "base/scoped_ptr.h" |
31 #include "base/string_number_conversions.h" | 25 #include "base/string_number_conversions.h" |
32 #include "base/string_util.h" | 26 #include "base/string_util.h" |
33 #include "base/task.h" | 27 #include "base/task.h" |
34 #include "base/time.h" | 28 #include "base/time.h" |
35 #include "base/utf_string_conversions.h" | 29 #include "base/utf_string_conversions.h" |
36 #include "chrome/common/chrome_paths.h" | 30 #include "chrome/common/chrome_paths.h" |
37 #include "chrome/common/render_messages.h" | 31 #include "chrome/common/render_messages.h" |
38 #include "chrome/common/render_messages_params.h" | 32 #include "chrome/common/render_messages_params.h" |
39 #include "chrome/renderer/pepper_widget.h" | 33 #include "chrome/renderer/pepper_widget.h" |
40 #include "chrome/renderer/render_thread.h" | 34 #include "chrome/renderer/render_thread.h" |
41 #include "chrome/renderer/render_view.h" | 35 #include "chrome/renderer/render_view.h" |
42 #if defined(OS_LINUX) | |
43 #include "chrome/renderer/renderer_sandbox_support_linux.h" | |
44 #endif | |
45 #include "chrome/renderer/webplugin_delegate_proxy.h" | 36 #include "chrome/renderer/webplugin_delegate_proxy.h" |
46 #include "ui/gfx/blit.h" | 37 #include "ui/gfx/blit.h" |
47 #if defined(OS_WIN) | 38 #include "printing/native_metafile_factory.h" |
48 #include "printing/units.h" | |
49 #include "skia/ext/vector_platform_device.h" | |
50 #include "ui/gfx/codec/jpeg_codec.h" | |
51 #include "ui/gfx/gdi_util.h" | |
52 #endif | |
53 #include "printing/native_metafile.h" | 39 #include "printing/native_metafile.h" |
54 #include "third_party/npapi/bindings/npapi_extensions.h" | 40 #include "third_party/npapi/bindings/npapi_extensions.h" |
55 #include "third_party/npapi/bindings/npapi_extensions_private.h" | 41 #include "third_party/npapi/bindings/npapi_extensions_private.h" |
56 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" | 42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" |
57 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
58 #include "webkit/glue/webcursor.h" | 44 #include "webkit/glue/webcursor.h" |
59 #include "webkit/glue/webkit_glue.h" | 45 #include "webkit/glue/webkit_glue.h" |
60 #include "webkit/plugins/npapi/plugin_constants_win.h" | 46 #include "webkit/plugins/npapi/plugin_constants_win.h" |
61 #include "webkit/plugins/npapi/plugin_instance.h" | 47 #include "webkit/plugins/npapi/plugin_instance.h" |
62 #include "webkit/plugins/npapi/plugin_lib.h" | 48 #include "webkit/plugins/npapi/plugin_lib.h" |
63 #include "webkit/plugins/npapi/plugin_list.h" | 49 #include "webkit/plugins/npapi/plugin_list.h" |
64 #include "webkit/plugins/npapi/plugin_host.h" | 50 #include "webkit/plugins/npapi/plugin_host.h" |
65 #include "webkit/plugins/npapi/plugin_stream_url.h" | 51 #include "webkit/plugins/npapi/plugin_stream_url.h" |
66 | 52 |
| 53 #if defined(OS_MACOSX) |
| 54 #include "base/mac/mac_util.h" |
| 55 #include "base/mac/scoped_cftyperef.h" |
| 56 #elif defined(OS_LINUX) |
| 57 #include "chrome/renderer/renderer_sandbox_support_linux.h" |
| 58 #include "printing/pdf_ps_metafile_cairo.h" |
| 59 #elif defined(OS_WIN) |
| 60 #include "printing/units.h" |
| 61 #include "skia/ext/vector_platform_device.h" |
| 62 #include "ui/gfx/codec/jpeg_codec.h" |
| 63 #include "ui/gfx/gdi_util.h" |
| 64 #endif |
| 65 |
67 #if defined(ENABLE_GPU) | 66 #if defined(ENABLE_GPU) |
68 #include "webkit/plugins/npapi/plugin_constants_win.h" | 67 #include "webkit/plugins/npapi/plugin_constants_win.h" |
69 #endif | 68 #endif |
70 | 69 |
71 #if defined(ENABLE_GPU) | 70 #if defined(ENABLE_GPU) |
72 using gpu::Buffer; | 71 using gpu::Buffer; |
73 #endif | 72 #endif |
74 | 73 |
75 using webkit::npapi::WebPlugin; | 74 using webkit::npapi::WebPlugin; |
76 using webkit::npapi::WebPluginDelegate; | 75 using webkit::npapi::WebPluginDelegate; |
(...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1215 &pdf_output, &output_size); | 1214 &pdf_output, &output_size); |
1216 if (err != NPERR_NO_ERROR) | 1215 if (err != NPERR_NO_ERROR) |
1217 return false; | 1216 return false; |
1218 | 1217 |
1219 bool ret = false; | 1218 bool ret = false; |
1220 #if defined(OS_LINUX) | 1219 #if defined(OS_LINUX) |
1221 // On Linux we need to get the backing PdfPsMetafile and write the bits | 1220 // On Linux we need to get the backing PdfPsMetafile and write the bits |
1222 // directly. | 1221 // directly. |
1223 cairo_t* context = canvas->beginPlatformPaint(); | 1222 cairo_t* context = canvas->beginPlatformPaint(); |
1224 printing::NativeMetafile* metafile = | 1223 printing::NativeMetafile* metafile = |
1225 printing::NativeMetafile::FromCairoContext(context); | 1224 printing::PdfPsMetafile::FromCairoContext(context); |
1226 DCHECK(metafile); | 1225 DCHECK(metafile); |
1227 if (metafile) { | 1226 if (metafile) { |
1228 ret = metafile->SetRawData(pdf_output, output_size); | 1227 ret = metafile->SetRawData(pdf_output, output_size); |
1229 if (ret) | 1228 if (ret) |
1230 pdf_output_done_ = true; | 1229 pdf_output_done_ = true; |
1231 } | 1230 } |
1232 canvas->endPlatformPaint(); | 1231 canvas->endPlatformPaint(); |
1233 #elif defined(OS_MACOSX) | 1232 #elif defined(OS_MACOSX) |
1234 printing::NativeMetafile metafile; | 1233 scoped_ptr<printing::NativeMetafile> metafile( |
| 1234 printing::NativeMetafileFactory::CreateMetafile()); |
1235 // Create a PDF metafile and render from there into the passed in context. | 1235 // Create a PDF metafile and render from there into the passed in context. |
1236 if (metafile.Init(pdf_output, output_size)) { | 1236 if (metafile->Init(pdf_output, output_size)) { |
1237 // Flip the transform. | 1237 // Flip the transform. |
1238 CGContextSaveGState(canvas); | 1238 CGContextSaveGState(canvas); |
1239 CGContextTranslateCTM(canvas, 0, current_printable_area_.height()); | 1239 CGContextTranslateCTM(canvas, 0, current_printable_area_.height()); |
1240 CGContextScaleCTM(canvas, 1.0, -1.0); | 1240 CGContextScaleCTM(canvas, 1.0, -1.0); |
1241 ret = metafile.RenderPage(1, canvas, current_printable_area_.ToCGRect(), | 1241 ret = metafile->RenderPage(1, canvas, current_printable_area_.ToCGRect(), |
1242 true, false, true, true); | 1242 true, false, true, true); |
1243 CGContextRestoreGState(canvas); | 1243 CGContextRestoreGState(canvas); |
1244 } | 1244 } |
1245 #elif defined(OS_WIN) | 1245 #elif defined(OS_WIN) |
1246 // On Windows, we now need to render the PDF to the DC that backs the | 1246 // On Windows, we now need to render the PDF to the DC that backs the |
1247 // supplied canvas. | 1247 // supplied canvas. |
1248 skia::VectorPlatformDevice& device = | 1248 skia::VectorPlatformDevice& device = |
1249 static_cast<skia::VectorPlatformDevice&>( | 1249 static_cast<skia::VectorPlatformDevice&>( |
1250 canvas->getTopPlatformDevice()); | 1250 canvas->getTopPlatformDevice()); |
1251 HDC dc = device.getBitmapDC(); | 1251 HDC dc = device.getBitmapDC(); |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1760 CGRect bounds; | 1760 CGRect bounds; |
1761 bounds.origin.x = dest_rect.x(); | 1761 bounds.origin.x = dest_rect.x(); |
1762 bounds.origin.y = canvas_height - dest_rect.y() - dest_rect.height(); | 1762 bounds.origin.y = canvas_height - dest_rect.y() - dest_rect.height(); |
1763 bounds.size.width = dest_rect.width(); | 1763 bounds.size.width = dest_rect.width(); |
1764 bounds.size.height = dest_rect.height(); | 1764 bounds.size.height = dest_rect.height(); |
1765 | 1765 |
1766 CGContextDrawImage(canvas, bounds, image); | 1766 CGContextDrawImage(canvas, bounds, image); |
1767 CGContextRestoreGState(canvas); | 1767 CGContextRestoreGState(canvas); |
1768 } | 1768 } |
1769 #endif // defined(OS_MACOSX) | 1769 #endif // defined(OS_MACOSX) |
OLD | NEW |