summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/webplugin_delegate_pepper.cc
diff options
context:
space:
mode:
authorsanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-28 18:56:30 +0000
committersanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-28 18:56:30 +0000
commitf3cab625e9f5a94b12449e1ca552cca67a17ce3b (patch)
tree9795bdcd8474d93629ef0987df7981a873c73b4b /chrome/renderer/webplugin_delegate_pepper.cc
parent52a69186b43c61c0f3c96abd583dc9a9e3cf447d (diff)
downloadchromium_src-f3cab625e9f5a94b12449e1ca552cca67a17ce3b.zip
chromium_src-f3cab625e9f5a94b12449e1ca552cca67a17ce3b.tar.gz
chromium_src-f3cab625e9f5a94b12449e1ca552cca67a17ce3b.tar.bz2
Added support for vector printing of Pepper v1 plugins on the Mac.
BUG=None. TEST=Test printing from Chrome PDF plugin on the Mac. Review URL: http://codereview.chromium.org/2808029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51008 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/webplugin_delegate_pepper.cc')
-rw-r--r--chrome/renderer/webplugin_delegate_pepper.cc21
1 files changed, 17 insertions, 4 deletions
diff --git a/chrome/renderer/webplugin_delegate_pepper.cc b/chrome/renderer/webplugin_delegate_pepper.cc
index 9c6cf2f..3ceac28 100644
--- a/chrome/renderer/webplugin_delegate_pepper.cc
+++ b/chrome/renderer/webplugin_delegate_pepper.cc
@@ -44,6 +44,7 @@
#include "printing/units.h"
#include "skia/ext/vector_platform_device.h"
#endif
+#include "printing/native_metafile.h"
#include "third_party/npapi/bindings/npapi_extensions.h"
#include "third_party/npapi/bindings/npapi_extensions_private.h"
#include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h"
@@ -1136,10 +1137,10 @@ int WebPluginDelegatePepper::PrintBegin(const gfx::Rect& printable_area,
bool WebPluginDelegatePepper::VectorPrintPage(int page_number,
WebKit::WebCanvas* canvas) {
-#if !defined(OS_WIN)
- // TODO(sanjeevr): Add vector print support for Mac and Linux.
+#if !defined(OS_WIN) && !defined(OS_MACOSX)
+ // TODO(sanjeevr): Add vector print support for Linux.
return false;
-#endif // !defined(OS_WIN)
+#endif // !defined(OS_WIN) && !defined(OS_MACOSX)
NPPPrintExtensions* print_extensions = GetPrintExtensions();
if (!print_extensions)
return false;
@@ -1165,7 +1166,19 @@ bool WebPluginDelegatePepper::VectorPrintPage(int page_number,
return false;
bool ret = false;
-#if defined(OS_WIN)
+#if defined(OS_MACOSX)
+ printing::NativeMetafile metafile;
+ // Create a PDF metafile and render from there into the passed in context.
+ if (metafile.Init(pdf_output, output_size)) {
+ // Flip the transform.
+ CGContextSaveGState(canvas);
+ CGContextTranslateCTM(canvas, 0, current_printable_area_.height());
+ CGContextScaleCTM(canvas, 1.0, -1.0);
+ ret = metafile.RenderPage(1, canvas, current_printable_area_.ToCGRect(),
+ true, false, true, true);
+ CGContextRestoreGState(canvas);
+ }
+#elif defined(OS_WIN)
// On Windows, we now need to render the PDF to the DC that backs the
// supplied canvas.
skia::VectorPlatformDevice& device =