diff options
-rw-r--r-- | content/renderer/pepper/pepper_plugin_instance_impl.cc | 7 | ||||
-rw-r--r-- | content/renderer/pepper/pepper_plugin_instance_impl.h | 5 | ||||
-rw-r--r-- | content/renderer/pepper/pepper_plugin_registry.cc | 26 |
3 files changed, 35 insertions, 3 deletions
diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.cc b/content/renderer/pepper/pepper_plugin_instance_impl.cc index af198b4..08e22dc 100644 --- a/content/renderer/pepper/pepper_plugin_instance_impl.cc +++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc @@ -524,6 +524,7 @@ PepperPluginInstanceImpl::PepperPluginInstanceImpl( external_document_load_(false), npp_(new NPP_t), isolate_(v8::Isolate::GetCurrent()), + is_deleted_(false), view_change_weak_ptr_factory_(this), weak_factory_(this) { pp_instance_ = HostGlobals::Get()->AddInstance(this); @@ -601,6 +602,8 @@ PepperPluginInstanceImpl::~PepperPluginInstanceImpl() { // returned, then it needs to keep its own reference on the stack. void PepperPluginInstanceImpl::Delete() { + is_deleted_ = true; + // Keep a reference on the stack. See NOTE above. scoped_refptr<PepperPluginInstanceImpl> ref(this); // Force the MessageChannel to release its "passthrough object" which should @@ -631,6 +634,10 @@ void PepperPluginInstanceImpl::Delete() { container_ = NULL; } +bool PepperPluginInstanceImpl::is_deleted() const { + return is_deleted_; +} + void PepperPluginInstanceImpl::Paint(WebCanvas* canvas, const gfx::Rect& plugin_rect, const gfx::Rect& paint_rect) { diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.h b/content/renderer/pepper/pepper_plugin_instance_impl.h index 32d0959..d94b802 100644 --- a/content/renderer/pepper/pepper_plugin_instance_impl.h +++ b/content/renderer/pepper/pepper_plugin_instance_impl.h @@ -146,6 +146,9 @@ class CONTENT_EXPORT PepperPluginInstanceImpl // the WebPlugin implementation when WebKit is about to remove the plugin. void Delete(); + // Returns true if Delete() has been called on this object. + bool is_deleted() const; + // Paints the current backing store to the web page. void Paint(blink::WebCanvas* canvas, const gfx::Rect& plugin_rect, @@ -847,6 +850,8 @@ class CONTENT_EXPORT PepperPluginInstanceImpl scoped_ptr<MouseLockDispatcher::LockTarget> lock_target_; + bool is_deleted_; + // We use a weak ptr factory for scheduling DidChangeView events so that we // can tell whether updates are pending and consolidate them. When there's // already a weak ptr pending (HasWeakPtrs is true), code should update the diff --git a/content/renderer/pepper/pepper_plugin_registry.cc b/content/renderer/pepper/pepper_plugin_registry.cc index c40294b..5939ce1 100644 --- a/content/renderer/pepper/pepper_plugin_registry.cc +++ b/content/renderer/pepper/pepper_plugin_registry.cc @@ -6,6 +6,7 @@ #include "base/logging.h" #include "content/common/pepper_plugin_list.h" +#include "content/renderer/pepper/pepper_plugin_instance_impl.h" #include "content/renderer/pepper/plugin_module.h" #include "ppapi/shared_impl/ppapi_permissions.h" @@ -43,10 +44,29 @@ const PepperPluginInfo* PepperPluginRegistry::GetInfoForPlugin( } PluginModule* PepperPluginRegistry::GetLiveModule(const base::FilePath& path) { - NonOwningModuleMap::iterator it = live_modules_.find(path); - if (it == live_modules_.end()) + NonOwningModuleMap::iterator module_iter = live_modules_.find(path); + if (module_iter == live_modules_.end()) return NULL; - return it->second; + + // Check the instances for the module to see if they've all been Delete()d. + // We don't want to return a PluginModule in that case, since the plugin may + // have exited already. + const PluginModule::PluginInstanceSet& instance_set = + module_iter->second->GetAllInstances(); + + // If instance_set is empty, InstanceCreated() hasn't been called yet, so + // it's safe to return the PluginModule. + if (instance_set.empty()) + return module_iter->second; + + PluginModule::PluginInstanceSet::const_iterator instance_iter = + instance_set.begin(); + while (instance_iter != instance_set.end()) { + if (!(*instance_iter)->is_deleted()) + return module_iter->second; + ++instance_iter; + } + return NULL; } void PepperPluginRegistry::AddLiveModule(const base::FilePath& path, |