| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
| 11 #include "chrome/common/plugin_messages.h" | 11 #include "chrome/common/plugin_messages.h" |
| 12 #include "chrome/plugin/npobject_stub.h" | 12 #include "chrome/plugin/npobject_stub.h" |
| 13 #include "chrome/plugin/plugin_channel.h" | 13 #include "chrome/plugin/plugin_channel.h" |
| 14 #include "chrome/plugin/plugin_thread.h" | 14 #include "chrome/plugin/plugin_thread.h" |
| 15 #include "chrome/plugin/webplugin_proxy.h" | 15 #include "chrome/plugin/webplugin_proxy.h" |
| 16 #include "printing/native_metafile.h" |
| 16 #include "third_party/npapi/bindings/npapi.h" | 17 #include "third_party/npapi/bindings/npapi.h" |
| 17 #include "third_party/npapi/bindings/npruntime.h" | 18 #include "third_party/npapi/bindings/npruntime.h" |
| 18 #include "skia/ext/platform_device.h" | 19 #include "skia/ext/platform_device.h" |
| 19 #include "webkit/glue/webcursor.h" | 20 #include "webkit/glue/webcursor.h" |
| 20 #include "webkit/glue/webplugin_delegate.h" | 21 #include "webkit/glue/webplugin_delegate.h" |
| 21 | 22 |
| 22 #if defined(OS_WIN) | |
| 23 #include "chrome/common/gfx/emf.h" | |
| 24 #endif | |
| 25 | |
| 26 class FinishDestructionTask : public Task { | 23 class FinishDestructionTask : public Task { |
| 27 public: | 24 public: |
| 28 FinishDestructionTask(WebPluginDelegate* delegate, WebPlugin* webplugin) | 25 FinishDestructionTask(WebPluginDelegate* delegate, WebPlugin* webplugin) |
| 29 : delegate_(delegate), webplugin_(webplugin) { } | 26 : delegate_(delegate), webplugin_(webplugin) { } |
| 30 | 27 |
| 31 void Run() { | 28 void Run() { |
| 32 // WebPlugin must outlive WebPluginDelegate. | 29 // WebPlugin must outlive WebPluginDelegate. |
| 33 if (delegate_) | 30 if (delegate_) |
| 34 delegate_->PluginDestroyed(); | 31 delegate_->PluginDestroyed(); |
| 35 | 32 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 webplugin_->Paint(damaged_rect); | 220 webplugin_->Paint(damaged_rect); |
| 224 } | 221 } |
| 225 | 222 |
| 226 void WebPluginDelegateStub::OnDidPaint() { | 223 void WebPluginDelegateStub::OnDidPaint() { |
| 227 webplugin_->DidPaint(); | 224 webplugin_->DidPaint(); |
| 228 } | 225 } |
| 229 | 226 |
| 230 void WebPluginDelegateStub::OnPrint(base::SharedMemoryHandle* shared_memory, | 227 void WebPluginDelegateStub::OnPrint(base::SharedMemoryHandle* shared_memory, |
| 231 size_t* size) { | 228 size_t* size) { |
| 232 #if defined(OS_WIN) | 229 #if defined(OS_WIN) |
| 233 gfx::Emf emf; | 230 printing::NativeMetafile metafile; |
| 234 if (!emf.CreateDc(NULL, NULL)) { | 231 if (!metafile.CreateDc(NULL, NULL)) { |
| 235 NOTREACHED(); | 232 NOTREACHED(); |
| 236 return; | 233 return; |
| 237 } | 234 } |
| 238 HDC hdc = emf.hdc(); | 235 HDC hdc = metafile.hdc(); |
| 239 skia::PlatformDevice::InitializeDC(hdc); | 236 skia::PlatformDevice::InitializeDC(hdc); |
| 240 delegate_->Print(hdc); | 237 delegate_->Print(hdc); |
| 241 if (!emf.CloseDc()) { | 238 if (!metafile.CloseDc()) { |
| 242 NOTREACHED(); | 239 NOTREACHED(); |
| 243 return; | 240 return; |
| 244 } | 241 } |
| 245 | 242 |
| 246 *size = emf.GetDataSize(); | 243 *size = metafile.GetDataSize(); |
| 247 DCHECK(*size); | 244 DCHECK(*size); |
| 248 base::SharedMemory shared_buf; | 245 base::SharedMemory shared_buf; |
| 249 CreateSharedBuffer(*size, &shared_buf, shared_memory); | 246 CreateSharedBuffer(*size, &shared_buf, shared_memory); |
| 250 | 247 |
| 251 // Retrieve a copy of the data. | 248 // Retrieve a copy of the data. |
| 252 bool success = emf.GetData(shared_buf.memory(), *size); | 249 bool success = metafile.GetData(shared_buf.memory(), *size); |
| 253 DCHECK(success); | 250 DCHECK(success); |
| 254 #else | 251 #else |
| 255 // TODO(port): plugin printing. | 252 // TODO(port): plugin printing. |
| 256 NOTIMPLEMENTED(); | 253 NOTIMPLEMENTED(); |
| 257 #endif | 254 #endif |
| 258 } | 255 } |
| 259 | 256 |
| 260 void WebPluginDelegateStub::OnUpdateGeometry( | 257 void WebPluginDelegateStub::OnUpdateGeometry( |
| 261 const gfx::Rect& window_rect, | 258 const gfx::Rect& window_rect, |
| 262 const gfx::Rect& clip_rect, | 259 const gfx::Rect& clip_rect, |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 params.notify_data, | 357 params.notify_data, |
| 361 params.stream); | 358 params.stream); |
| 362 webplugin_->OnResourceCreated(params.resource_id, resource_client); | 359 webplugin_->OnResourceCreated(params.resource_id, resource_client); |
| 363 } | 360 } |
| 364 | 361 |
| 365 void WebPluginDelegateStub::OnURLRequestRouted(const std::string& url, | 362 void WebPluginDelegateStub::OnURLRequestRouted(const std::string& url, |
| 366 bool notify_needed, | 363 bool notify_needed, |
| 367 intptr_t notify_data) { | 364 intptr_t notify_data) { |
| 368 delegate_->URLRequestRouted(url, notify_needed, notify_data); | 365 delegate_->URLRequestRouted(url, notify_needed, notify_data); |
| 369 } | 366 } |
| OLD | NEW |