| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 is_deleted_(false), | 536 is_deleted_(false), |
| 537 view_change_weak_ptr_factory_(this), | 537 view_change_weak_ptr_factory_(this), |
| 538 weak_factory_(this) { | 538 weak_factory_(this) { |
| 539 pp_instance_ = HostGlobals::Get()->AddInstance(this); | 539 pp_instance_ = HostGlobals::Get()->AddInstance(this); |
| 540 | 540 |
| 541 memset(¤t_print_settings_, 0, sizeof(current_print_settings_)); | 541 memset(¤t_print_settings_, 0, sizeof(current_print_settings_)); |
| 542 module_->InstanceCreated(this); | 542 module_->InstanceCreated(this); |
| 543 | 543 |
| 544 if (render_frame) { // NULL in tests | 544 if (render_frame) { // NULL in tests |
| 545 render_frame->render_view()->PepperInstanceCreated(this); | 545 render_frame->render_view()->PepperInstanceCreated(this); |
| 546 // Bind a callback now so that we can inform the RenderViewImpl when we are |
| 547 // destroyed. This works around a temporary problem stemming from work to |
| 548 // move parts of RenderViewImpl in to RenderFrameImpl (see |
| 549 // crbug.com/245126). If destruction happens in this order: |
| 550 // 1) RenderFrameImpl |
| 551 // 2) PepperPluginInstanceImpl |
| 552 // 3) RenderViewImpl |
| 553 // Then after 1), the PepperPluginInstanceImpl doesn't have any way to talk |
| 554 // to the RenderViewImpl. But when the instance is destroyed, it still |
| 555 // needs to inform the RenderViewImpl that it has gone away, otherwise |
| 556 // between (2) and (3), the RenderViewImpl will still have the dead |
| 557 // instance in its active set, and so might make calls on the deleted |
| 558 // instance. See crbug.com/343576 for more information. Once the plugin |
| 559 // calls move entirely from RenderViewImpl in to RenderFrameImpl, this |
| 560 // can be a little bit simplified by instead making a direct call on |
| 561 // RenderFrameImpl in the destructor (but only if render_frame_ is valid). |
| 562 instance_deleted_callback_ = |
| 563 base::Bind(&RenderViewImpl::PepperInstanceDeleted, |
| 564 render_frame->render_view()->AsWeakPtr(), |
| 565 base::Unretained(this)); |
| 546 view_data_.is_page_visible = !render_frame_->GetRenderWidget()->is_hidden(); | 566 view_data_.is_page_visible = !render_frame_->GetRenderWidget()->is_hidden(); |
| 547 | 567 |
| 548 // Set the initial focus. | 568 // Set the initial focus. |
| 549 SetContentAreaFocus(render_frame_->GetRenderWidget()->has_focus()); | 569 SetContentAreaFocus(render_frame_->GetRenderWidget()->has_focus()); |
| 550 | 570 |
| 551 if (!module_->IsProxied()) { | 571 if (!module_->IsProxied()) { |
| 552 PepperBrowserConnection* browser_connection = | 572 PepperBrowserConnection* browser_connection = |
| 553 PepperBrowserConnection::Get(render_frame_); | 573 PepperBrowserConnection::Get(render_frame_); |
| 554 browser_connection->DidCreateInProcessInstance( | 574 browser_connection->DidCreateInProcessInstance( |
| 555 pp_instance(), | 575 pp_instance(), |
| (...skipping 21 matching lines...) Expand all Loading... |
| 577 // unregister themselves inside the delete call). | 597 // unregister themselves inside the delete call). |
| 578 PluginObjectSet plugin_object_copy; | 598 PluginObjectSet plugin_object_copy; |
| 579 live_plugin_objects_.swap(plugin_object_copy); | 599 live_plugin_objects_.swap(plugin_object_copy); |
| 580 for (PluginObjectSet::iterator i = plugin_object_copy.begin(); | 600 for (PluginObjectSet::iterator i = plugin_object_copy.begin(); |
| 581 i != plugin_object_copy.end(); ++i) | 601 i != plugin_object_copy.end(); ++i) |
| 582 delete *i; | 602 delete *i; |
| 583 | 603 |
| 584 if (TrackedCallback::IsPending(lock_mouse_callback_)) | 604 if (TrackedCallback::IsPending(lock_mouse_callback_)) |
| 585 lock_mouse_callback_->Abort(); | 605 lock_mouse_callback_->Abort(); |
| 586 | 606 |
| 587 if (render_frame_ && render_frame_->render_view()) | 607 if (!instance_deleted_callback_.is_null()) |
| 588 render_frame_->render_view()->PepperInstanceDeleted(this); | 608 instance_deleted_callback_.Run(); |
| 589 | 609 |
| 590 if (!module_->IsProxied() && render_frame_) { | 610 if (!module_->IsProxied() && render_frame_) { |
| 591 PepperBrowserConnection* browser_connection = | 611 PepperBrowserConnection* browser_connection = |
| 592 PepperBrowserConnection::Get(render_frame_); | 612 PepperBrowserConnection::Get(render_frame_); |
| 593 browser_connection->DidDeleteInProcessInstance(pp_instance()); | 613 browser_connection->DidDeleteInProcessInstance(pp_instance()); |
| 594 } | 614 } |
| 595 | 615 |
| 596 UnSetAndDeleteLockTargetAdapter(); | 616 UnSetAndDeleteLockTargetAdapter(); |
| 597 module_->InstanceDeleted(this); | 617 module_->InstanceDeleted(this); |
| 598 // If we switched from the NaCl plugin module, notify it too. | 618 // If we switched from the NaCl plugin module, notify it too. |
| (...skipping 2558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3157 // Running out-of-process. Initiate an IPC call to notify the plugin | 3177 // Running out-of-process. Initiate an IPC call to notify the plugin |
| 3158 // process. | 3178 // process. |
| 3159 ppapi::proxy::HostDispatcher* dispatcher = | 3179 ppapi::proxy::HostDispatcher* dispatcher = |
| 3160 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); | 3180 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); |
| 3161 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( | 3181 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( |
| 3162 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data)); | 3182 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data)); |
| 3163 } | 3183 } |
| 3164 } | 3184 } |
| 3165 | 3185 |
| 3166 } // namespace content | 3186 } // namespace content |
| OLD | NEW |