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 "content/plugin/webplugin_delegate_stub.h" | 5 #include "content/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 "content/common/content_client.h" | 10 #include "content/common/content_client.h" |
11 #include "content/common/content_switches.h" | 11 #include "content/common/content_switches.h" |
12 #include "content/common/plugin_messages.h" | 12 #include "content/common/plugin_messages.h" |
13 #include "content/plugin/npobject_stub.h" | 13 #include "content/plugin/npobject_stub.h" |
14 #include "content/plugin/plugin_channel.h" | 14 #include "content/plugin/plugin_channel.h" |
15 #include "content/plugin/plugin_thread.h" | 15 #include "content/plugin/plugin_thread.h" |
16 #include "content/plugin/webplugin_proxy.h" | 16 #include "content/plugin/webplugin_proxy.h" |
17 #include "third_party/npapi/bindings/npapi.h" | 17 #include "third_party/npapi/bindings/npapi.h" |
18 #include "third_party/npapi/bindings/npruntime.h" | 18 #include "third_party/npapi/bindings/npruntime.h" |
19 #include "skia/ext/platform_device.h" | 19 #include "skia/ext/platform_device.h" |
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" |
22 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" | 22 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" |
23 #include "webkit/glue/webcursor.h" | 23 #include "webkit/glue/webcursor.h" |
24 | 24 |
25 #if defined(OS_WIN) | 25 #if defined(OS_WIN) |
26 #include "base/memory/scoped_ptr.h" | 26 #include "printing/metafile_impl.h" |
27 #include "printing/native_metafile_factory.h" | |
28 #include "printing/native_metafile.h" | |
29 #endif // defined(OS_WIN) | 27 #endif // defined(OS_WIN) |
30 | 28 |
31 using WebKit::WebBindings; | 29 using WebKit::WebBindings; |
32 using WebKit::WebCursorInfo; | 30 using WebKit::WebCursorInfo; |
33 using webkit::npapi::WebPlugin; | 31 using webkit::npapi::WebPlugin; |
34 using webkit::npapi::WebPluginResourceClient; | 32 using webkit::npapi::WebPluginResourceClient; |
35 | 33 |
36 class FinishDestructionTask : public Task { | 34 class FinishDestructionTask : public Task { |
37 public: | 35 public: |
38 FinishDestructionTask(webkit::npapi::WebPluginDelegateImpl* delegate, | 36 FinishDestructionTask(webkit::npapi::WebPluginDelegateImpl* delegate, |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 webplugin_->Paint(damaged_rect); | 262 webplugin_->Paint(damaged_rect); |
265 } | 263 } |
266 | 264 |
267 void WebPluginDelegateStub::OnDidPaint() { | 265 void WebPluginDelegateStub::OnDidPaint() { |
268 webplugin_->DidPaint(); | 266 webplugin_->DidPaint(); |
269 } | 267 } |
270 | 268 |
271 void WebPluginDelegateStub::OnPrint(base::SharedMemoryHandle* shared_memory, | 269 void WebPluginDelegateStub::OnPrint(base::SharedMemoryHandle* shared_memory, |
272 uint32* size) { | 270 uint32* size) { |
273 #if defined(OS_WIN) | 271 #if defined(OS_WIN) |
274 scoped_ptr<printing::NativeMetafile> metafile( | 272 printing::NativeMetafile metafile; |
275 printing::NativeMetafileFactory::Create()); | 273 if (!metafile.Init()) { |
276 if (!metafile->Init()) { | |
277 NOTREACHED(); | 274 NOTREACHED(); |
278 return; | 275 return; |
279 } | 276 } |
280 HDC hdc = metafile->context(); | 277 HDC hdc = metafile.context(); |
281 skia::PlatformDevice::InitializeDC(hdc); | 278 skia::PlatformDevice::InitializeDC(hdc); |
282 delegate_->Print(hdc); | 279 delegate_->Print(hdc); |
283 if (!metafile->FinishDocument()) { | 280 if (!metafile.FinishDocument()) { |
284 NOTREACHED(); | 281 NOTREACHED(); |
285 return; | 282 return; |
286 } | 283 } |
287 | 284 |
288 *size = metafile->GetDataSize(); | 285 *size = metafile.GetDataSize(); |
289 DCHECK(*size); | 286 DCHECK(*size); |
290 base::SharedMemory shared_buf; | 287 base::SharedMemory shared_buf; |
291 CreateSharedBuffer(*size, &shared_buf, shared_memory); | 288 CreateSharedBuffer(*size, &shared_buf, shared_memory); |
292 | 289 |
293 // Retrieve a copy of the data. | 290 // Retrieve a copy of the data. |
294 bool success = metafile->GetData(shared_buf.memory(), *size); | 291 bool success = metafile.GetData(shared_buf.memory(), *size); |
295 DCHECK(success); | 292 DCHECK(success); |
296 #else | 293 #else |
297 // TODO(port): plugin printing. | 294 // TODO(port): plugin printing. |
298 NOTIMPLEMENTED(); | 295 NOTIMPLEMENTED(); |
299 #endif | 296 #endif |
300 } | 297 } |
301 | 298 |
302 void WebPluginDelegateStub::OnUpdateGeometry( | 299 void WebPluginDelegateStub::OnUpdateGeometry( |
303 const PluginMsg_UpdateGeometry_Param& param) { | 300 const PluginMsg_UpdateGeometry_Param& param) { |
304 webplugin_->UpdateGeometry( | 301 webplugin_->UpdateGeometry( |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 delegate_->CreateSeekableResourceClient(resource_id, range_request_id); | 438 delegate_->CreateSeekableResourceClient(resource_id, range_request_id); |
442 webplugin_->OnResourceCreated(resource_id, resource_client); | 439 webplugin_->OnResourceCreated(resource_id, resource_client); |
443 } | 440 } |
444 | 441 |
445 #if defined(OS_MACOSX) | 442 #if defined(OS_MACOSX) |
446 void WebPluginDelegateStub::OnSetFakeAcceleratedSurfaceWindowHandle( | 443 void WebPluginDelegateStub::OnSetFakeAcceleratedSurfaceWindowHandle( |
447 gfx::PluginWindowHandle window) { | 444 gfx::PluginWindowHandle window) { |
448 delegate_->set_windowed_handle(window); | 445 delegate_->set_windowed_handle(window); |
449 } | 446 } |
450 #endif | 447 #endif |
OLD | NEW |