| OLD | NEW |
| 1 // Copyright (c) 2009 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 "chrome/plugin/webplugin_delegate_stub.h" | 5 #include "chrome/plugin/webplugin_delegate_stub.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "chrome/common/child_process_logging.h" | 10 #include "chrome/common/child_process_logging.h" |
| 11 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| 12 #include "chrome/common/plugin_messages.h" | 12 #include "chrome/common/plugin_messages.h" |
| 13 #include "chrome/plugin/npobject_stub.h" | 13 #include "chrome/plugin/npobject_stub.h" |
| 14 #include "chrome/plugin/plugin_channel.h" | 14 #include "chrome/plugin/plugin_channel.h" |
| 15 #include "chrome/plugin/plugin_thread.h" | 15 #include "chrome/plugin/plugin_thread.h" |
| 16 #include "chrome/plugin/webplugin_proxy.h" | 16 #include "chrome/plugin/webplugin_proxy.h" |
| 17 #include "printing/native_metafile.h" | |
| 18 #include "third_party/npapi/bindings/npapi.h" | 17 #include "third_party/npapi/bindings/npapi.h" |
| 19 #include "third_party/npapi/bindings/npruntime.h" | 18 #include "third_party/npapi/bindings/npruntime.h" |
| 20 #include "skia/ext/platform_device.h" | 19 #include "skia/ext/platform_device.h" |
| 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
| 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" |
| 23 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" | 22 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" |
| 24 #include "webkit/glue/webcursor.h" | 23 #include "webkit/glue/webcursor.h" |
| 25 | 24 |
| 25 #if defined(OS_WIN) |
| 26 #include "base/scoped_ptr.h" |
| 27 #include "printing/native_metafile_factory.h" |
| 28 #include "printing/native_metafile.h" |
| 29 #endif // defined(OS_WIN) |
| 30 |
| 26 #if defined(ENABLE_GPU) | 31 #if defined(ENABLE_GPU) |
| 27 #include "app/gfx/gl/gl_context.h" | 32 #include "app/gfx/gl/gl_context.h" |
| 28 #endif | 33 #endif |
| 29 | 34 |
| 30 using WebKit::WebBindings; | 35 using WebKit::WebBindings; |
| 31 using WebKit::WebCursorInfo; | 36 using WebKit::WebCursorInfo; |
| 32 using webkit::npapi::WebPlugin; | 37 using webkit::npapi::WebPlugin; |
| 33 using webkit::npapi::WebPluginResourceClient; | 38 using webkit::npapi::WebPluginResourceClient; |
| 34 | 39 |
| 35 class FinishDestructionTask : public Task { | 40 class FinishDestructionTask : public Task { |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 webplugin_->Paint(damaged_rect); | 279 webplugin_->Paint(damaged_rect); |
| 275 } | 280 } |
| 276 | 281 |
| 277 void WebPluginDelegateStub::OnDidPaint() { | 282 void WebPluginDelegateStub::OnDidPaint() { |
| 278 webplugin_->DidPaint(); | 283 webplugin_->DidPaint(); |
| 279 } | 284 } |
| 280 | 285 |
| 281 void WebPluginDelegateStub::OnPrint(base::SharedMemoryHandle* shared_memory, | 286 void WebPluginDelegateStub::OnPrint(base::SharedMemoryHandle* shared_memory, |
| 282 uint32* size) { | 287 uint32* size) { |
| 283 #if defined(OS_WIN) | 288 #if defined(OS_WIN) |
| 284 printing::NativeMetafile metafile; | 289 scoped_ptr<printing::NativeMetafile> metafile( |
| 285 if (!metafile.CreateDc(NULL, NULL)) { | 290 printing::NativeMetafileFactory::CreateMetafile()); |
| 291 if (!metafile->CreateDc(NULL, NULL)) { |
| 286 NOTREACHED(); | 292 NOTREACHED(); |
| 287 return; | 293 return; |
| 288 } | 294 } |
| 289 HDC hdc = metafile.hdc(); | 295 HDC hdc = metafile->hdc(); |
| 290 skia::PlatformDevice::InitializeDC(hdc); | 296 skia::PlatformDevice::InitializeDC(hdc); |
| 291 delegate_->Print(hdc); | 297 delegate_->Print(hdc); |
| 292 if (!metafile.CloseDc()) { | 298 if (!metafile->CloseDc()) { |
| 293 NOTREACHED(); | 299 NOTREACHED(); |
| 294 return; | 300 return; |
| 295 } | 301 } |
| 296 | 302 |
| 297 *size = metafile.GetDataSize(); | 303 *size = metafile->GetDataSize(); |
| 298 DCHECK(*size); | 304 DCHECK(*size); |
| 299 base::SharedMemory shared_buf; | 305 base::SharedMemory shared_buf; |
| 300 CreateSharedBuffer(*size, &shared_buf, shared_memory); | 306 CreateSharedBuffer(*size, &shared_buf, shared_memory); |
| 301 | 307 |
| 302 // Retrieve a copy of the data. | 308 // Retrieve a copy of the data. |
| 303 bool success = metafile.GetData(shared_buf.memory(), *size); | 309 bool success = metafile->GetData(shared_buf.memory(), *size); |
| 304 DCHECK(success); | 310 DCHECK(success); |
| 305 #else | 311 #else |
| 306 // TODO(port): plugin printing. | 312 // TODO(port): plugin printing. |
| 307 NOTIMPLEMENTED(); | 313 NOTIMPLEMENTED(); |
| 308 #endif | 314 #endif |
| 309 } | 315 } |
| 310 | 316 |
| 311 void WebPluginDelegateStub::OnUpdateGeometry( | 317 void WebPluginDelegateStub::OnUpdateGeometry( |
| 312 const PluginMsg_UpdateGeometry_Param& param) { | 318 const PluginMsg_UpdateGeometry_Param& param) { |
| 313 webplugin_->UpdateGeometry( | 319 webplugin_->UpdateGeometry( |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 webplugin_->OnResourceCreated(resource_id, resource_client); | 480 webplugin_->OnResourceCreated(resource_id, resource_client); |
| 475 } | 481 } |
| 476 | 482 |
| 477 #if defined(OS_MACOSX) | 483 #if defined(OS_MACOSX) |
| 478 void WebPluginDelegateStub::OnSetFakeAcceleratedSurfaceWindowHandle( | 484 void WebPluginDelegateStub::OnSetFakeAcceleratedSurfaceWindowHandle( |
| 479 gfx::PluginWindowHandle window) { | 485 gfx::PluginWindowHandle window) { |
| 480 delegate_->set_windowed_handle(window); | 486 delegate_->set_windowed_handle(window); |
| 481 } | 487 } |
| 482 #endif | 488 #endif |
| 483 | 489 |
| OLD | NEW |