| 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 "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "ppapi/c/pp_rect.h" | 22 #include "ppapi/c/pp_rect.h" |
| 23 #include "ppapi/c/pp_resource.h" | 23 #include "ppapi/c/pp_resource.h" |
| 24 #include "ppapi/c/pp_var.h" | 24 #include "ppapi/c/pp_var.h" |
| 25 #include "ppapi/c/ppb_core.h" | 25 #include "ppapi/c/ppb_core.h" |
| 26 #include "ppapi/c/ppb_instance.h" | 26 #include "ppapi/c/ppb_instance.h" |
| 27 #include "ppapi/c/ppp_input_event.h" | 27 #include "ppapi/c/ppp_input_event.h" |
| 28 #include "ppapi/c/ppp_instance.h" | 28 #include "ppapi/c/ppp_instance.h" |
| 29 #include "ppapi/c/ppp_messaging.h" | 29 #include "ppapi/c/ppp_messaging.h" |
| 30 #include "ppapi/c/private/ppb_instance_private.h" | 30 #include "ppapi/c/private/ppb_instance_private.h" |
| 31 #include "ppapi/c/private/ppp_instance_private.h" | 31 #include "ppapi/c/private/ppp_instance_private.h" |
| 32 #include "ppapi/shared_impl/resource.h" |
| 32 #include "ppapi/shared_impl/var.h" | 33 #include "ppapi/shared_impl/var.h" |
| 33 #include "ppapi/thunk/enter.h" | 34 #include "ppapi/thunk/enter.h" |
| 34 #include "ppapi/thunk/ppb_buffer_api.h" | 35 #include "ppapi/thunk/ppb_buffer_api.h" |
| 35 #include "printing/units.h" | 36 #include "printing/units.h" |
| 36 #include "skia/ext/platform_canvas.h" | 37 #include "skia/ext/platform_canvas.h" |
| 37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | 38 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
| 38 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" | 39 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" |
| 39 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 40 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| 40 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" | 41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
| 41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 58 #include "webkit/plugins/ppapi/plugin_object.h" | 59 #include "webkit/plugins/ppapi/plugin_object.h" |
| 59 #include "webkit/plugins/ppapi/ppb_buffer_impl.h" | 60 #include "webkit/plugins/ppapi/ppb_buffer_impl.h" |
| 60 #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h" | 61 #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h" |
| 61 #include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h" | 62 #include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h" |
| 62 #include "webkit/plugins/ppapi/ppb_image_data_impl.h" | 63 #include "webkit/plugins/ppapi/ppb_image_data_impl.h" |
| 63 #include "webkit/plugins/ppapi/ppb_input_event_impl.h" | 64 #include "webkit/plugins/ppapi/ppb_input_event_impl.h" |
| 64 #include "webkit/plugins/ppapi/ppb_surface_3d_impl.h" | 65 #include "webkit/plugins/ppapi/ppb_surface_3d_impl.h" |
| 65 #include "webkit/plugins/ppapi/ppb_url_loader_impl.h" | 66 #include "webkit/plugins/ppapi/ppb_url_loader_impl.h" |
| 66 #include "webkit/plugins/ppapi/ppb_url_request_info_impl.h" | 67 #include "webkit/plugins/ppapi/ppb_url_request_info_impl.h" |
| 67 #include "webkit/plugins/ppapi/ppp_pdf.h" | 68 #include "webkit/plugins/ppapi/ppp_pdf.h" |
| 69 #include "webkit/plugins/ppapi/resource_tracker.h" |
| 68 #include "webkit/plugins/ppapi/string.h" | 70 #include "webkit/plugins/ppapi/string.h" |
| 69 #include "webkit/plugins/sad_plugin.h" | 71 #include "webkit/plugins/sad_plugin.h" |
| 70 | 72 |
| 71 #if defined(OS_MACOSX) | 73 #if defined(OS_MACOSX) |
| 72 #include "base/mac/mac_util.h" | 74 #include "base/mac/mac_util.h" |
| 73 #include "base/mac/scoped_cftyperef.h" | 75 #include "base/mac/scoped_cftyperef.h" |
| 74 #include "printing/metafile_impl.h" | 76 #include "printing/metafile_impl.h" |
| 75 #endif | 77 #endif |
| 76 | 78 |
| 77 #if defined(USE_SKIA) | 79 #if defined(USE_SKIA) |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 argc++; | 426 argc++; |
| 425 } | 427 } |
| 426 | 428 |
| 427 return PP_ToBool(instance_interface_->DidCreate(pp_instance(), | 429 return PP_ToBool(instance_interface_->DidCreate(pp_instance(), |
| 428 argc, | 430 argc, |
| 429 argn.get(), | 431 argn.get(), |
| 430 argv.get())); | 432 argv.get())); |
| 431 } | 433 } |
| 432 | 434 |
| 433 bool PluginInstance::HandleDocumentLoad(PPB_URLLoader_Impl* loader) { | 435 bool PluginInstance::HandleDocumentLoad(PPB_URLLoader_Impl* loader) { |
| 434 Resource::ScopedResourceId resource(loader); | 436 return PP_ToBool(instance_interface_->HandleDocumentLoad( |
| 435 return PP_ToBool(instance_interface_->HandleDocumentLoad(pp_instance(), | 437 pp_instance(), loader->pp_resource())); |
| 436 resource.id)); | |
| 437 } | 438 } |
| 438 | 439 |
| 439 bool PluginInstance::HandleInputEvent(const WebKit::WebInputEvent& event, | 440 bool PluginInstance::HandleInputEvent(const WebKit::WebInputEvent& event, |
| 440 WebCursorInfo* cursor_info) { | 441 WebCursorInfo* cursor_info) { |
| 441 // Keep a reference on the stack. See NOTE above. | 442 // Keep a reference on the stack. See NOTE above. |
| 442 scoped_refptr<PluginInstance> ref(this); | 443 scoped_refptr<PluginInstance> ref(this); |
| 443 | 444 |
| 444 bool rv = false; | 445 bool rv = false; |
| 445 if (LoadInputEventInterface()) { | 446 if (LoadInputEventInterface()) { |
| 446 PP_InputEvent_Class event_class = ClassifyInputEvent(event.type); | 447 PP_InputEvent_Class event_class = ClassifyInputEvent(event.type); |
| 447 if (!event_class) | 448 if (!event_class) |
| 448 return false; | 449 return false; |
| 449 | 450 |
| 450 if ((filtered_input_event_mask_ & event_class) || | 451 if ((filtered_input_event_mask_ & event_class) || |
| 451 (input_event_mask_ & event_class)) { | 452 (input_event_mask_ & event_class)) { |
| 452 // Actually send the event. | 453 // Actually send the event. |
| 453 std::vector< ::ppapi::InputEventData > events; | 454 std::vector< ::ppapi::InputEventData > events; |
| 454 CreateInputEventData(event, &events); | 455 CreateInputEventData(event, &events); |
| 455 | 456 |
| 456 // Each input event may generate more than one PP_InputEvent. | 457 // Each input event may generate more than one PP_InputEvent. |
| 457 for (size_t i = 0; i < events.size(); i++) { | 458 for (size_t i = 0; i < events.size(); i++) { |
| 458 if (filtered_input_event_mask_ & event_class) | 459 if (filtered_input_event_mask_ & event_class) |
| 459 events[i].is_filtered = true; | 460 events[i].is_filtered = true; |
| 460 else | 461 else |
| 461 rv = true; // Unfiltered events are assumed to be handled. | 462 rv = true; // Unfiltered events are assumed to be handled. |
| 462 scoped_refptr<PPB_InputEvent_Impl> event_resource( | 463 scoped_refptr<PPB_InputEvent_Impl> event_resource( |
| 463 new PPB_InputEvent_Impl(this, events[i])); | 464 new PPB_InputEvent_Impl(pp_instance(), events[i])); |
| 464 Resource::ScopedResourceId resource(event_resource); | |
| 465 | 465 |
| 466 rv |= PP_ToBool(plugin_input_event_interface_->HandleInputEvent( | 466 rv |= PP_ToBool(plugin_input_event_interface_->HandleInputEvent( |
| 467 pp_instance(), resource.id)); | 467 pp_instance(), event_resource->pp_resource())); |
| 468 } | 468 } |
| 469 } | 469 } |
| 470 } | 470 } |
| 471 | 471 |
| 472 if (cursor_.get()) | 472 if (cursor_.get()) |
| 473 *cursor_info = *cursor_; | 473 *cursor_info = *cursor_; |
| 474 return rv; | 474 return rv; |
| 475 } | 475 } |
| 476 | 476 |
| 477 void PluginInstance::HandlePolicyUpdate(const std::string& policy_json) { | 477 void PluginInstance::HandlePolicyUpdate(const std::string& policy_json) { |
| (...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1362 PPB_Graphics2D_Impl* graphics_2d = enter_2d.succeeded() ? | 1362 PPB_Graphics2D_Impl* graphics_2d = enter_2d.succeeded() ? |
| 1363 static_cast<PPB_Graphics2D_Impl*>(enter_2d.object()) : NULL; | 1363 static_cast<PPB_Graphics2D_Impl*>(enter_2d.object()) : NULL; |
| 1364 EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false); | 1364 EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false); |
| 1365 PPB_Graphics3D_Impl* graphics_3d = enter_3d.succeeded() ? | 1365 PPB_Graphics3D_Impl* graphics_3d = enter_3d.succeeded() ? |
| 1366 static_cast<PPB_Graphics3D_Impl*>(enter_3d.object()) : NULL; | 1366 static_cast<PPB_Graphics3D_Impl*>(enter_3d.object()) : NULL; |
| 1367 EnterResourceNoLock<PPB_Surface3D_API> enter_surface_3d(device, false); | 1367 EnterResourceNoLock<PPB_Surface3D_API> enter_surface_3d(device, false); |
| 1368 PPB_Surface3D_Impl* surface_3d = enter_surface_3d.succeeded() ? | 1368 PPB_Surface3D_Impl* surface_3d = enter_surface_3d.succeeded() ? |
| 1369 static_cast<PPB_Surface3D_Impl*>(enter_surface_3d.object()) : NULL; | 1369 static_cast<PPB_Surface3D_Impl*>(enter_surface_3d.object()) : NULL; |
| 1370 | 1370 |
| 1371 if (graphics_2d) { | 1371 if (graphics_2d) { |
| 1372 if (graphics_2d->instance() != this) | 1372 if (graphics_2d->pp_instance() != pp_instance()) |
| 1373 return PP_FALSE; // Can't bind other instance's contexts. | 1373 return PP_FALSE; // Can't bind other instance's contexts. |
| 1374 if (!graphics_2d->BindToInstance(this)) | 1374 if (!graphics_2d->BindToInstance(this)) |
| 1375 return PP_FALSE; // Can't bind to more than one instance. | 1375 return PP_FALSE; // Can't bind to more than one instance. |
| 1376 | 1376 |
| 1377 bound_graphics_ = graphics_2d; | 1377 bound_graphics_ = graphics_2d; |
| 1378 setBackingTextureId(0); | 1378 setBackingTextureId(0); |
| 1379 // BindToInstance will have invalidated the plugin if necessary. | 1379 // BindToInstance will have invalidated the plugin if necessary. |
| 1380 } else if (graphics_3d) { | 1380 } else if (graphics_3d) { |
| 1381 // Make sure graphics can only be bound to the instance it is | 1381 // Make sure graphics can only be bound to the instance it is |
| 1382 // associated with. | 1382 // associated with. |
| 1383 if (graphics_3d->instance() != this) | 1383 if (graphics_3d->pp_instance() != pp_instance()) |
| 1384 return PP_FALSE; | 1384 return PP_FALSE; |
| 1385 if (!graphics_3d->BindToInstance(true)) | 1385 if (!graphics_3d->BindToInstance(true)) |
| 1386 return PP_FALSE; | 1386 return PP_FALSE; |
| 1387 | 1387 |
| 1388 bound_graphics_ = graphics_3d; | 1388 bound_graphics_ = graphics_3d; |
| 1389 setBackingTextureId(graphics_3d->GetBackingTextureId()); | 1389 setBackingTextureId(graphics_3d->GetBackingTextureId()); |
| 1390 } else if (surface_3d) { | 1390 } else if (surface_3d) { |
| 1391 // Make sure graphics can only be bound to the instance it is | 1391 // Make sure graphics can only be bound to the instance it is |
| 1392 // associated with. | 1392 // associated with. |
| 1393 if (surface_3d->instance() != this) | 1393 if (surface_3d->pp_instance() != pp_instance()) |
| 1394 return PP_FALSE; | 1394 return PP_FALSE; |
| 1395 if (!surface_3d->BindToInstance(true)) | 1395 if (!surface_3d->BindToInstance(true)) |
| 1396 return PP_FALSE; | 1396 return PP_FALSE; |
| 1397 | 1397 |
| 1398 bound_graphics_ = surface_3d; | 1398 bound_graphics_ = surface_3d; |
| 1399 setBackingTextureId(surface_3d->GetBackingTextureId()); | 1399 setBackingTextureId(surface_3d->GetBackingTextureId()); |
| 1400 } else { | 1400 } else { |
| 1401 // The device is not a valid resource type. | 1401 // The device is not a valid resource type. |
| 1402 return PP_FALSE; | 1402 return PP_FALSE; |
| 1403 } | 1403 } |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1542 } | 1542 } |
| 1543 | 1543 |
| 1544 void PluginInstance::DoSetCursor(WebCursorInfo* cursor) { | 1544 void PluginInstance::DoSetCursor(WebCursorInfo* cursor) { |
| 1545 cursor_.reset(cursor); | 1545 cursor_.reset(cursor); |
| 1546 if (fullscreen_container_) | 1546 if (fullscreen_container_) |
| 1547 fullscreen_container_->DidChangeCursor(*cursor); | 1547 fullscreen_container_->DidChangeCursor(*cursor); |
| 1548 } | 1548 } |
| 1549 | 1549 |
| 1550 } // namespace ppapi | 1550 } // namespace ppapi |
| 1551 } // namespace webkit | 1551 } // namespace webkit |
| OLD | NEW |