| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/glue/plugins/pepper_plugin_instance.h" | 5 #include "webkit/glue/plugins/pepper_plugin_instance.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/histogram.h" | 8 #include "base/histogram.h" |
| 9 #if defined(OS_MACOSX) | 9 #if defined(OS_MACOSX) |
| 10 #include "base/mac_util.h" | 10 #include "base/mac_util.h" |
| 11 #include "base/scoped_cftyperef.h" | 11 #include "base/scoped_cftyperef.h" |
| 12 #endif | 12 #endif |
| 13 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "gfx/rect.h" | 15 #include "gfx/rect.h" |
| 16 #if defined(OS_WIN) | 16 #if defined(OS_WIN) |
| 17 #include "gfx/codec/jpeg_codec.h" | 17 #include "gfx/codec/jpeg_codec.h" |
| 18 #include "gfx/gdi_util.h" | 18 #include "gfx/gdi_util.h" |
| 19 #endif | 19 #endif |
| 20 #include "gfx/skia_util.h" | 20 #include "gfx/skia_util.h" |
| 21 #include "printing/native_metafile.h" | 21 #include "printing/native_metafile.h" |
| 22 #include "printing/units.h" | 22 #include "printing/units.h" |
| 23 #include "skia/ext/vector_platform_device.h" | 23 #include "skia/ext/vector_platform_device.h" |
| 24 #include "skia/ext/platform_canvas.h" | 24 #include "skia/ext/platform_canvas.h" |
| 25 #include "third_party/ppapi/c/dev/ppb_find_dev.h" | 25 #include "third_party/ppapi/c/dev/ppb_find_dev.h" |
| 26 #include "third_party/ppapi/c/dev/ppb_fullscreen_dev.h" | 26 #include "third_party/ppapi/c/dev/ppb_fullscreen_dev.h" |
| 27 #include "third_party/ppapi/c/dev/ppp_find_dev.h" | 27 #include "third_party/ppapi/c/dev/ppp_find_dev.h" |
| 28 #include "third_party/ppapi/c/dev/ppp_zoom_dev.h" | 28 #include "third_party/ppapi/c/dev/ppp_zoom_dev.h" |
| 29 #include "third_party/ppapi/c/pp_event.h" | 29 #include "third_party/ppapi/c/pp_input_event.h" |
| 30 #include "third_party/ppapi/c/pp_instance.h" | 30 #include "third_party/ppapi/c/pp_instance.h" |
| 31 #include "third_party/ppapi/c/pp_rect.h" | 31 #include "third_party/ppapi/c/pp_rect.h" |
| 32 #include "third_party/ppapi/c/pp_resource.h" | 32 #include "third_party/ppapi/c/pp_resource.h" |
| 33 #include "third_party/ppapi/c/pp_var.h" | 33 #include "third_party/ppapi/c/pp_var.h" |
| 34 #include "third_party/ppapi/c/ppb_core.h" | 34 #include "third_party/ppapi/c/ppb_core.h" |
| 35 #include "third_party/ppapi/c/ppb_instance.h" | 35 #include "third_party/ppapi/c/ppb_instance.h" |
| 36 #include "third_party/ppapi/c/ppp_instance.h" | 36 #include "third_party/ppapi/c/ppp_instance.h" |
| 37 #include "third_party/WebKit/WebKit/chromium/public/WebBindings.h" | 37 #include "third_party/WebKit/WebKit/chromium/public/WebBindings.h" |
| 38 #include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h" | 38 #include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h" |
| 39 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" | 39 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 argc, argn.get(), argv.get()); | 443 argc, argn.get(), argv.get()); |
| 444 } | 444 } |
| 445 | 445 |
| 446 bool PluginInstance::HandleDocumentLoad(URLLoader* loader) { | 446 bool PluginInstance::HandleDocumentLoad(URLLoader* loader) { |
| 447 Resource::ScopedResourceId resource(loader); | 447 Resource::ScopedResourceId resource(loader); |
| 448 return instance_interface_->HandleDocumentLoad(GetPPInstance(), resource.id); | 448 return instance_interface_->HandleDocumentLoad(GetPPInstance(), resource.id); |
| 449 } | 449 } |
| 450 | 450 |
| 451 bool PluginInstance::HandleInputEvent(const WebKit::WebInputEvent& event, | 451 bool PluginInstance::HandleInputEvent(const WebKit::WebInputEvent& event, |
| 452 WebCursorInfo* cursor_info) { | 452 WebCursorInfo* cursor_info) { |
| 453 scoped_ptr<PP_Event> pp_event(CreatePP_Event(event)); | 453 std::vector<PP_InputEvent> pp_events; |
| 454 if (!pp_event.get()) | 454 CreatePPEvent(event, &pp_events); |
| 455 return false; | |
| 456 | 455 |
| 457 bool rv = instance_interface_->HandleEvent(GetPPInstance(), pp_event.get()); | 456 // Each input event may generate more than one PP_InputEvent. |
| 457 bool rv = false; |
| 458 for (size_t i = 0; i < pp_events.size(); i++) |
| 459 rv |= instance_interface_->HandleInputEvent(GetPPInstance(), &pp_events[i]); |
| 460 |
| 458 if (cursor_.get()) | 461 if (cursor_.get()) |
| 459 *cursor_info = *cursor_; | 462 *cursor_info = *cursor_; |
| 460 return rv; | 463 return rv; |
| 461 } | 464 } |
| 462 | 465 |
| 466 void PluginInstance::FocusChanged(bool has_focus) { |
| 467 instance_interface_->FocusChanged(GetPPInstance(), has_focus); |
| 468 } |
| 469 |
| 463 PP_Var PluginInstance::GetInstanceObject() { | 470 PP_Var PluginInstance::GetInstanceObject() { |
| 464 return instance_interface_->GetInstanceObject(GetPPInstance()); | 471 return instance_interface_->GetInstanceObject(GetPPInstance()); |
| 465 } | 472 } |
| 466 | 473 |
| 467 void PluginInstance::ViewChanged(const gfx::Rect& position, | 474 void PluginInstance::ViewChanged(const gfx::Rect& position, |
| 468 const gfx::Rect& clip) { | 475 const gfx::Rect& clip) { |
| 469 position_ = position; | 476 position_ = position; |
| 470 if (clip.IsEmpty()) { | 477 if (clip.IsEmpty()) { |
| 471 // WebKit can give weird (x,y) positions for empty clip rects (since the | 478 // WebKit can give weird (x,y) positions for empty clip rects (since the |
| 472 // position technically doesn't matter). But we want to make these | 479 // position technically doesn't matter). But we want to make these |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 bounds.size.width = dest_rect.width(); | 930 bounds.size.width = dest_rect.width(); |
| 924 bounds.size.height = dest_rect.height(); | 931 bounds.size.height = dest_rect.height(); |
| 925 | 932 |
| 926 CGContextDrawImage(canvas, bounds, image); | 933 CGContextDrawImage(canvas, bounds, image); |
| 927 CGContextRestoreGState(canvas); | 934 CGContextRestoreGState(canvas); |
| 928 } | 935 } |
| 929 #endif // defined(OS_MACOSX) | 936 #endif // defined(OS_MACOSX) |
| 930 | 937 |
| 931 | 938 |
| 932 } // namespace pepper | 939 } // namespace pepper |
| OLD | NEW |