| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer/pepper/pepper_plugin_instance_impl.h" | 5 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bit_cast.h" | 10 #include "base/bit_cast.h" |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 is_deleted_(false), | 529 is_deleted_(false), |
| 530 initialized_(false), | 530 initialized_(false), |
| 531 view_change_weak_ptr_factory_(this), | 531 view_change_weak_ptr_factory_(this), |
| 532 weak_factory_(this) { | 532 weak_factory_(this) { |
| 533 pp_instance_ = HostGlobals::Get()->AddInstance(this); | 533 pp_instance_ = HostGlobals::Get()->AddInstance(this); |
| 534 | 534 |
| 535 memset(¤t_print_settings_, 0, sizeof(current_print_settings_)); | 535 memset(¤t_print_settings_, 0, sizeof(current_print_settings_)); |
| 536 module_->InstanceCreated(this); | 536 module_->InstanceCreated(this); |
| 537 | 537 |
| 538 if (render_frame) { // NULL in tests | 538 if (render_frame) { // NULL in tests |
| 539 render_frame->render_view()->PepperInstanceCreated(this); | 539 render_frame->PepperInstanceCreated(this); |
| 540 // Bind a callback now so that we can inform the RenderViewImpl when we are | |
| 541 // destroyed. This works around a temporary problem stemming from work to | |
| 542 // move parts of RenderViewImpl in to RenderFrameImpl (see | |
| 543 // crbug.com/245126). If destruction happens in this order: | |
| 544 // 1) RenderFrameImpl | |
| 545 // 2) PepperPluginInstanceImpl | |
| 546 // 3) RenderViewImpl | |
| 547 // Then after 1), the PepperPluginInstanceImpl doesn't have any way to talk | |
| 548 // to the RenderViewImpl. But when the instance is destroyed, it still | |
| 549 // needs to inform the RenderViewImpl that it has gone away, otherwise | |
| 550 // between (2) and (3), the RenderViewImpl will still have the dead | |
| 551 // instance in its active set, and so might make calls on the deleted | |
| 552 // instance. See crbug.com/343576 for more information. Once the plugin | |
| 553 // calls move entirely from RenderViewImpl in to RenderFrameImpl, this | |
| 554 // can be a little bit simplified by instead making a direct call on | |
| 555 // RenderFrameImpl in the destructor (but only if render_frame_ is valid). | |
| 556 instance_deleted_callback_ = | |
| 557 base::Bind(&RenderViewImpl::PepperInstanceDeleted, | |
| 558 render_frame->render_view()->AsWeakPtr(), | |
| 559 base::Unretained(this)); | |
| 560 view_data_.is_page_visible = !render_frame_->GetRenderWidget()->is_hidden(); | 540 view_data_.is_page_visible = !render_frame_->GetRenderWidget()->is_hidden(); |
| 561 | 541 |
| 562 // Set the initial focus. | 542 // Set the initial focus. |
| 563 SetContentAreaFocus(render_frame_->render_view()->has_focus()); | 543 SetContentAreaFocus(render_frame_->GetRenderWidget()->has_focus()); |
| 564 | 544 |
| 565 if (!module_->IsProxied()) { | 545 if (!module_->IsProxied()) { |
| 566 PepperBrowserConnection* browser_connection = | 546 PepperBrowserConnection* browser_connection = |
| 567 PepperBrowserConnection::Get(render_frame_); | 547 PepperBrowserConnection::Get(render_frame_); |
| 568 browser_connection->DidCreateInProcessInstance( | 548 browser_connection->DidCreateInProcessInstance( |
| 569 pp_instance(), | 549 pp_instance(), |
| 570 render_frame_->GetRoutingID(), | 550 render_frame_->GetRoutingID(), |
| 571 document_url_, | 551 document_url_, |
| 572 GetPluginURL()); | 552 GetPluginURL()); |
| 573 } | 553 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 597 (*i)->InstanceDeleted(); | 577 (*i)->InstanceDeleted(); |
| 598 } | 578 } |
| 599 | 579 |
| 600 if (message_channel_) | 580 if (message_channel_) |
| 601 message_channel_->InstanceDeleted(); | 581 message_channel_->InstanceDeleted(); |
| 602 message_channel_object_.Reset(); | 582 message_channel_object_.Reset(); |
| 603 | 583 |
| 604 if (TrackedCallback::IsPending(lock_mouse_callback_)) | 584 if (TrackedCallback::IsPending(lock_mouse_callback_)) |
| 605 lock_mouse_callback_->Abort(); | 585 lock_mouse_callback_->Abort(); |
| 606 | 586 |
| 607 if (!instance_deleted_callback_.is_null()) | 587 if (render_frame_) |
| 608 instance_deleted_callback_.Run(); | 588 render_frame_->PepperInstanceDeleted(this); |
| 609 | 589 |
| 610 if (!module_->IsProxied() && render_frame_) { | 590 if (!module_->IsProxied() && render_frame_) { |
| 611 PepperBrowserConnection* browser_connection = | 591 PepperBrowserConnection* browser_connection = |
| 612 PepperBrowserConnection::Get(render_frame_); | 592 PepperBrowserConnection::Get(render_frame_); |
| 613 browser_connection->DidDeleteInProcessInstance(pp_instance()); | 593 browser_connection->DidDeleteInProcessInstance(pp_instance()); |
| 614 } | 594 } |
| 615 | 595 |
| 616 UnSetAndDeleteLockTargetAdapter(); | 596 UnSetAndDeleteLockTargetAdapter(); |
| 617 module_->InstanceDeleted(this); | 597 module_->InstanceDeleted(this); |
| 618 // If we switched from the NaCl plugin module, notify it too. | 598 // If we switched from the NaCl plugin module, notify it too. |
| (...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1627 top_left.y() / graphics_2d_size_in_dip.height()), | 1607 top_left.y() / graphics_2d_size_in_dip.height()), |
| 1628 gfx::PointF(lower_right.x() / graphics_2d_size_in_dip.width(), | 1608 gfx::PointF(lower_right.x() / graphics_2d_size_in_dip.width(), |
| 1629 lower_right.y() / graphics_2d_size_in_dip.height())); | 1609 lower_right.y() / graphics_2d_size_in_dip.height())); |
| 1630 } | 1610 } |
| 1631 | 1611 |
| 1632 bool PepperPluginInstanceImpl::PluginHasFocus() const { | 1612 bool PepperPluginInstanceImpl::PluginHasFocus() const { |
| 1633 return flash_fullscreen_ || (has_webkit_focus_ && has_content_area_focus_); | 1613 return flash_fullscreen_ || (has_webkit_focus_ && has_content_area_focus_); |
| 1634 } | 1614 } |
| 1635 | 1615 |
| 1636 void PepperPluginInstanceImpl::SendFocusChangeNotification() { | 1616 void PepperPluginInstanceImpl::SendFocusChangeNotification() { |
| 1637 // Keep a reference on the stack. RenderViewImpl::PepperFocusChanged may | 1617 // Keep a reference on the stack. RenderFrameImpl::PepperFocusChanged may |
| 1638 // remove the <embed> from the DOM, which will make the PepperWebPluginImpl | 1618 // remove the <embed> from the DOM, which will make the PepperWebPluginImpl |
| 1639 // drop its reference, usually the last one. This is similar to possible | 1619 // drop its reference, usually the last one. This is similar to possible |
| 1640 // plugin behavior described at the NOTE above Delete(). | 1620 // plugin behavior described at the NOTE above Delete(). |
| 1641 scoped_refptr<PepperPluginInstanceImpl> ref(this); | 1621 scoped_refptr<PepperPluginInstanceImpl> ref(this); |
| 1642 | 1622 |
| 1643 if (!render_frame_) | 1623 if (!render_frame_) |
| 1644 return; | 1624 return; |
| 1645 | 1625 |
| 1646 bool has_focus = PluginHasFocus(); | 1626 bool has_focus = PluginHasFocus(); |
| 1647 render_frame_->render_view()->PepperFocusChanged(this, has_focus); | 1627 render_frame_->PepperFocusChanged(this, has_focus); |
| 1648 | 1628 |
| 1649 // instance_interface_ may have been cleared in Delete() if the | 1629 // instance_interface_ may have been cleared in Delete() if the |
| 1650 // PepperWebPluginImpl is destroyed. | 1630 // PepperWebPluginImpl is destroyed. |
| 1651 if (instance_interface_) | 1631 if (instance_interface_) |
| 1652 instance_interface_->DidChangeFocus(pp_instance(), PP_FromBool(has_focus)); | 1632 instance_interface_->DidChangeFocus(pp_instance(), PP_FromBool(has_focus)); |
| 1653 } | 1633 } |
| 1654 | 1634 |
| 1655 void PepperPluginInstanceImpl::UpdateTouchEventRequest() { | 1635 void PepperPluginInstanceImpl::UpdateTouchEventRequest() { |
| 1656 bool raw_touch = (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_TOUCH) || | 1636 bool raw_touch = (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_TOUCH) || |
| 1657 (input_event_mask_ & PP_INPUTEVENT_CLASS_TOUCH); | 1637 (input_event_mask_ & PP_INPUTEVENT_CLASS_TOUCH); |
| (...skipping 1761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3419 const cc::TextureMailbox& mailbox) const { | 3399 const cc::TextureMailbox& mailbox) const { |
| 3420 auto it = | 3400 auto it = |
| 3421 std::find_if(texture_ref_counts_.begin(), texture_ref_counts_.end(), | 3401 std::find_if(texture_ref_counts_.begin(), texture_ref_counts_.end(), |
| 3422 [&mailbox](const TextureMailboxRefCount& ref_count) { | 3402 [&mailbox](const TextureMailboxRefCount& ref_count) { |
| 3423 return ref_count.first.mailbox() == mailbox.mailbox(); | 3403 return ref_count.first.mailbox() == mailbox.mailbox(); |
| 3424 }); | 3404 }); |
| 3425 return it != texture_ref_counts_.end(); | 3405 return it != texture_ref_counts_.end(); |
| 3426 } | 3406 } |
| 3427 | 3407 |
| 3428 } // namespace content | 3408 } // namespace content |
| OLD | NEW |