| 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 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| (...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1136 // On Linux we need to get the backing PdfPsMetafile and write the bits | 1136 // On Linux we need to get the backing PdfPsMetafile and write the bits |
| 1137 // directly. | 1137 // directly. |
| 1138 cairo_t* context = canvas->beginPlatformPaint(); | 1138 cairo_t* context = canvas->beginPlatformPaint(); |
| 1139 printing::NativeMetafile* metafile = | 1139 printing::NativeMetafile* metafile = |
| 1140 printing::PdfPsMetafile::FromCairoContext(context); | 1140 printing::PdfPsMetafile::FromCairoContext(context); |
| 1141 DCHECK(metafile); | 1141 DCHECK(metafile); |
| 1142 if (metafile) | 1142 if (metafile) |
| 1143 ret = metafile->InitFromData(buffer->mapped_buffer(), buffer->size()); | 1143 ret = metafile->InitFromData(buffer->mapped_buffer(), buffer->size()); |
| 1144 canvas->endPlatformPaint(); | 1144 canvas->endPlatformPaint(); |
| 1145 #elif defined(OS_MACOSX) | 1145 #elif defined(OS_MACOSX) |
| 1146 // Create a PDF metafile and render from there into the passed in context. |
| 1146 scoped_ptr<printing::NativeMetafile> metafile( | 1147 scoped_ptr<printing::NativeMetafile> metafile( |
| 1147 printing::NativeMetafileFactory::Create()); | 1148 printing::NativeMetafileFactory::CreateFromData(buffer->mapped_buffer(), |
| 1148 // Create a PDF metafile and render from there into the passed in context. | 1149 buffer->size())); |
| 1149 if (metafile->InitFromData(buffer->mapped_buffer(), buffer->size())) { | 1150 if (metafile.get() != NULL) { |
| 1150 // Flip the transform. | 1151 // Flip the transform. |
| 1151 CGContextSaveGState(canvas); | 1152 CGContextSaveGState(canvas); |
| 1152 CGContextTranslateCTM(canvas, 0, | 1153 CGContextTranslateCTM(canvas, 0, |
| 1153 current_print_settings_.printable_area.size.height); | 1154 current_print_settings_.printable_area.size.height); |
| 1154 CGContextScaleCTM(canvas, 1.0, -1.0); | 1155 CGContextScaleCTM(canvas, 1.0, -1.0); |
| 1155 CGRect page_rect; | 1156 CGRect page_rect; |
| 1156 page_rect.origin.x = current_print_settings_.printable_area.point.x; | 1157 page_rect.origin.x = current_print_settings_.printable_area.point.x; |
| 1157 page_rect.origin.y = current_print_settings_.printable_area.point.y; | 1158 page_rect.origin.y = current_print_settings_.printable_area.point.y; |
| 1158 page_rect.size.width = current_print_settings_.printable_area.size.width; | 1159 page_rect.size.width = current_print_settings_.printable_area.size.width; |
| 1159 page_rect.size.height = current_print_settings_.printable_area.size.height; | 1160 page_rect.size.height = current_print_settings_.printable_area.size.height; |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1405 return found->second; | 1406 return found->second; |
| 1406 } | 1407 } |
| 1407 | 1408 |
| 1408 bool PluginInstance::IsFullPagePlugin() const { | 1409 bool PluginInstance::IsFullPagePlugin() const { |
| 1409 WebFrame* frame = container()->element().document().frame(); | 1410 WebFrame* frame = container()->element().document().frame(); |
| 1410 return frame->view()->mainFrame()->document().isPluginDocument(); | 1411 return frame->view()->mainFrame()->document().isPluginDocument(); |
| 1411 } | 1412 } |
| 1412 | 1413 |
| 1413 } // namespace ppapi | 1414 } // namespace ppapi |
| 1414 } // namespace webkit | 1415 } // namespace webkit |
| OLD | NEW |