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 "base/scoped_ptr.h" | |
10 #include "chrome/common/child_process_logging.h" | 11 #include "chrome/common/child_process_logging.h" |
11 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
12 #include "chrome/common/plugin_messages.h" | 13 #include "chrome/common/plugin_messages.h" |
13 #include "chrome/plugin/npobject_stub.h" | 14 #include "chrome/plugin/npobject_stub.h" |
14 #include "chrome/plugin/plugin_channel.h" | 15 #include "chrome/plugin/plugin_channel.h" |
15 #include "chrome/plugin/plugin_thread.h" | 16 #include "chrome/plugin/plugin_thread.h" |
16 #include "chrome/plugin/webplugin_proxy.h" | 17 #include "chrome/plugin/webplugin_proxy.h" |
18 #include "printing/native_metafile_factory.h" | |
Lei Zhang
2011/03/02 00:05:15
nit: new includes are Windows only. Same goes for:
dpapad
2011/03/02 01:17:18
Done. Also I think that the same holds for the alr
| |
17 #include "printing/native_metafile.h" | 19 #include "printing/native_metafile.h" |
18 #include "third_party/npapi/bindings/npapi.h" | 20 #include "third_party/npapi/bindings/npapi.h" |
19 #include "third_party/npapi/bindings/npruntime.h" | 21 #include "third_party/npapi/bindings/npruntime.h" |
20 #include "skia/ext/platform_device.h" | 22 #include "skia/ext/platform_device.h" |
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" | 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" |
23 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" | 25 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" |
24 #include "webkit/glue/webcursor.h" | 26 #include "webkit/glue/webcursor.h" |
25 | 27 |
26 #if defined(ENABLE_GPU) | 28 #if defined(ENABLE_GPU) |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
274 webplugin_->Paint(damaged_rect); | 276 webplugin_->Paint(damaged_rect); |
275 } | 277 } |
276 | 278 |
277 void WebPluginDelegateStub::OnDidPaint() { | 279 void WebPluginDelegateStub::OnDidPaint() { |
278 webplugin_->DidPaint(); | 280 webplugin_->DidPaint(); |
279 } | 281 } |
280 | 282 |
281 void WebPluginDelegateStub::OnPrint(base::SharedMemoryHandle* shared_memory, | 283 void WebPluginDelegateStub::OnPrint(base::SharedMemoryHandle* shared_memory, |
282 uint32* size) { | 284 uint32* size) { |
283 #if defined(OS_WIN) | 285 #if defined(OS_WIN) |
284 printing::NativeMetafile metafile; | 286 scoped_ptr<printing::NativeMetafile> metafile( |
285 if (!metafile.CreateDc(NULL, NULL)) { | 287 printing::NativeMetafileFactory::CreateMetafile()); |
288 if (!metafile->CreateDc(NULL, NULL)) { | |
286 NOTREACHED(); | 289 NOTREACHED(); |
287 return; | 290 return; |
288 } | 291 } |
289 HDC hdc = metafile.hdc(); | 292 HDC hdc = metafile->hdc(); |
290 skia::PlatformDevice::InitializeDC(hdc); | 293 skia::PlatformDevice::InitializeDC(hdc); |
291 delegate_->Print(hdc); | 294 delegate_->Print(hdc); |
292 if (!metafile.CloseDc()) { | 295 if (!metafile->CloseDc()) { |
293 NOTREACHED(); | 296 NOTREACHED(); |
294 return; | 297 return; |
295 } | 298 } |
296 | 299 |
297 *size = metafile.GetDataSize(); | 300 *size = metafile->GetDataSize(); |
298 DCHECK(*size); | 301 DCHECK(*size); |
299 base::SharedMemory shared_buf; | 302 base::SharedMemory shared_buf; |
300 CreateSharedBuffer(*size, &shared_buf, shared_memory); | 303 CreateSharedBuffer(*size, &shared_buf, shared_memory); |
301 | 304 |
302 // Retrieve a copy of the data. | 305 // Retrieve a copy of the data. |
303 bool success = metafile.GetData(shared_buf.memory(), *size); | 306 bool success = metafile->GetData(shared_buf.memory(), *size); |
304 DCHECK(success); | 307 DCHECK(success); |
305 #else | 308 #else |
306 // TODO(port): plugin printing. | 309 // TODO(port): plugin printing. |
307 NOTIMPLEMENTED(); | 310 NOTIMPLEMENTED(); |
308 #endif | 311 #endif |
309 } | 312 } |
310 | 313 |
311 void WebPluginDelegateStub::OnUpdateGeometry( | 314 void WebPluginDelegateStub::OnUpdateGeometry( |
312 const PluginMsg_UpdateGeometry_Param& param) { | 315 const PluginMsg_UpdateGeometry_Param& param) { |
313 webplugin_->UpdateGeometry( | 316 webplugin_->UpdateGeometry( |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
474 webplugin_->OnResourceCreated(resource_id, resource_client); | 477 webplugin_->OnResourceCreated(resource_id, resource_client); |
475 } | 478 } |
476 | 479 |
477 #if defined(OS_MACOSX) | 480 #if defined(OS_MACOSX) |
478 void WebPluginDelegateStub::OnSetFakeAcceleratedSurfaceWindowHandle( | 481 void WebPluginDelegateStub::OnSetFakeAcceleratedSurfaceWindowHandle( |
479 gfx::PluginWindowHandle window) { | 482 gfx::PluginWindowHandle window) { |
480 delegate_->set_windowed_handle(window); | 483 delegate_->set_windowed_handle(window); |
481 } | 484 } |
482 #endif | 485 #endif |
483 | 486 |
OLD | NEW |