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 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 text_input_caret_(0, 0, 0, 0), | 517 text_input_caret_(0, 0, 0, 0), |
518 text_input_caret_bounds_(0, 0, 0, 0), | 518 text_input_caret_bounds_(0, 0, 0, 0), |
519 text_input_caret_set_(false), | 519 text_input_caret_set_(false), |
520 selection_caret_(0), | 520 selection_caret_(0), |
521 selection_anchor_(0), | 521 selection_anchor_(0), |
522 pending_user_gesture_(0.0), | 522 pending_user_gesture_(0.0), |
523 document_loader_(NULL), | 523 document_loader_(NULL), |
524 external_document_load_(false), | 524 external_document_load_(false), |
525 npp_(new NPP_t), | 525 npp_(new NPP_t), |
526 isolate_(v8::Isolate::GetCurrent()), | 526 isolate_(v8::Isolate::GetCurrent()), |
| 527 is_deleted_(false), |
527 view_change_weak_ptr_factory_(this) { | 528 view_change_weak_ptr_factory_(this) { |
528 pp_instance_ = HostGlobals::Get()->AddInstance(this); | 529 pp_instance_ = HostGlobals::Get()->AddInstance(this); |
529 | 530 |
530 memset(¤t_print_settings_, 0, sizeof(current_print_settings_)); | 531 memset(¤t_print_settings_, 0, sizeof(current_print_settings_)); |
531 module_->InstanceCreated(this); | 532 module_->InstanceCreated(this); |
532 | 533 |
533 if (render_view) { // NULL in tests | 534 if (render_view) { // NULL in tests |
534 render_view->PepperInstanceCreated(this); | 535 render_view->PepperInstanceCreated(this); |
535 view_data_.is_page_visible = !render_view->is_hidden(); | 536 view_data_.is_page_visible = !render_view->is_hidden(); |
536 | 537 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 HostGlobals::Get()->InstanceDeleted(pp_instance_); | 594 HostGlobals::Get()->InstanceDeleted(pp_instance_); |
594 } | 595 } |
595 | 596 |
596 // NOTE: Any of these methods that calls into the plugin needs to take into | 597 // NOTE: Any of these methods that calls into the plugin needs to take into |
597 // account that the plugin may use Var to remove the <embed> from the DOM, which | 598 // account that the plugin may use Var to remove the <embed> from the DOM, which |
598 // will make the PepperWebPluginImpl drop its reference, usually the last one. | 599 // will make the PepperWebPluginImpl drop its reference, usually the last one. |
599 // If a method needs to access a member of the instance after the call has | 600 // If a method needs to access a member of the instance after the call has |
600 // returned, then it needs to keep its own reference on the stack. | 601 // returned, then it needs to keep its own reference on the stack. |
601 | 602 |
602 void PepperPluginInstanceImpl::Delete() { | 603 void PepperPluginInstanceImpl::Delete() { |
| 604 is_deleted_ = true; |
| 605 |
603 // Keep a reference on the stack. See NOTE above. | 606 // Keep a reference on the stack. See NOTE above. |
604 scoped_refptr<PepperPluginInstanceImpl> ref(this); | 607 scoped_refptr<PepperPluginInstanceImpl> ref(this); |
605 // Force the MessageChannel to release its "passthrough object" which should | 608 // Force the MessageChannel to release its "passthrough object" which should |
606 // release our last reference to the "InstanceObject" and will probably | 609 // release our last reference to the "InstanceObject" and will probably |
607 // destroy it. We want to do this prior to calling DidDestroy in case the | 610 // destroy it. We want to do this prior to calling DidDestroy in case the |
608 // destructor of the instance object tries to use the instance. | 611 // destructor of the instance object tries to use the instance. |
609 message_channel_->SetPassthroughObject(NULL); | 612 message_channel_->SetPassthroughObject(NULL); |
610 // If this is a NaCl plugin instance, shut down the NaCl plugin by calling | 613 // If this is a NaCl plugin instance, shut down the NaCl plugin by calling |
611 // its DidDestroy. Don't call DidDestroy on the untrusted plugin instance, | 614 // its DidDestroy. Don't call DidDestroy on the untrusted plugin instance, |
612 // since there is little that it can do at this point. | 615 // since there is little that it can do at this point. |
(...skipping 10 matching lines...) Expand all Loading... |
623 fullscreen_container_ = NULL; | 626 fullscreen_container_ = NULL; |
624 } | 627 } |
625 | 628 |
626 // Force-unbind any Graphics. In the case of Graphics2D, if the plugin | 629 // Force-unbind any Graphics. In the case of Graphics2D, if the plugin |
627 // leaks the graphics 2D, it may actually get cleaned up after our | 630 // leaks the graphics 2D, it may actually get cleaned up after our |
628 // destruction, so we need its pointers to be up-to-date. | 631 // destruction, so we need its pointers to be up-to-date. |
629 BindGraphics(pp_instance(), 0); | 632 BindGraphics(pp_instance(), 0); |
630 container_ = NULL; | 633 container_ = NULL; |
631 } | 634 } |
632 | 635 |
| 636 bool PepperPluginInstanceImpl::is_deleted() const { |
| 637 return is_deleted_; |
| 638 } |
| 639 |
633 void PepperPluginInstanceImpl::Paint(WebCanvas* canvas, | 640 void PepperPluginInstanceImpl::Paint(WebCanvas* canvas, |
634 const gfx::Rect& plugin_rect, | 641 const gfx::Rect& plugin_rect, |
635 const gfx::Rect& paint_rect) { | 642 const gfx::Rect& paint_rect) { |
636 TRACE_EVENT0("ppapi", "PluginInstance::Paint"); | 643 TRACE_EVENT0("ppapi", "PluginInstance::Paint"); |
637 if (module()->is_crashed()) { | 644 if (module()->is_crashed()) { |
638 // Crashed plugin painting. | 645 // Crashed plugin painting. |
639 if (!sad_plugin_) // Lazily initialize bitmap. | 646 if (!sad_plugin_) // Lazily initialize bitmap. |
640 sad_plugin_ = GetContentClient()->renderer()->GetSadPluginBitmap(); | 647 sad_plugin_ = GetContentClient()->renderer()->GetSadPluginBitmap(); |
641 if (sad_plugin_) | 648 if (sad_plugin_) |
642 PaintSadPlugin(canvas, plugin_rect, *sad_plugin_); | 649 PaintSadPlugin(canvas, plugin_rect, *sad_plugin_); |
(...skipping 2353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2996 // Running out-of-process. Initiate an IPC call to notify the plugin | 3003 // Running out-of-process. Initiate an IPC call to notify the plugin |
2997 // process. | 3004 // process. |
2998 ppapi::proxy::HostDispatcher* dispatcher = | 3005 ppapi::proxy::HostDispatcher* dispatcher = |
2999 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); | 3006 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); |
3000 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( | 3007 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( |
3001 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data)); | 3008 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data)); |
3002 } | 3009 } |
3003 } | 3010 } |
3004 | 3011 |
3005 } // namespace content | 3012 } // namespace content |
OLD | NEW |