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