Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Unified Diff: webkit/plugins/npapi/webplugin_impl.cc

Issue 17208003: Track NPObject ownership by the originating plugins' NPP identifier. [4/6] (Chrome) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove DCHECKs on proxy and stub maps. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/webplugin_delegate_proxy.cc ('k') | webkit/renderer/cpp_variant_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/plugins/npapi/webplugin_impl.cc
diff --git a/webkit/plugins/npapi/webplugin_impl.cc b/webkit/plugins/npapi/webplugin_impl.cc
index e110309c15d041b34a457722d04dcdc7a6f1d02c..3754b259ee389cc539948cc1d6d2c5111eee5fdb 100644
--- a/webkit/plugins/npapi/webplugin_impl.cc
+++ b/webkit/plugins/npapi/webplugin_impl.cc
@@ -260,12 +260,17 @@ bool WebPluginImpl::initialize(WebPluginContainer* container) {
WebKit::WebPlugin* replacement_plugin =
page_delegate_->CreatePluginReplacement(file_path_);
- if (!replacement_plugin || !replacement_plugin->initialize(container))
+ if (!replacement_plugin)
return false;
- container->setPlugin(replacement_plugin);
+ // Disable scripting by this plugin before replacing it with the new
+ // one. This plugin also needs destroying, so use destroy(), which will
+ // implicitly disable scripting while un-setting the container.
destroy();
- return true;
+
+ // Inform the container of the replacement plugin, then initialize it.
+ container->setPlugin(replacement_plugin);
+ return replacement_plugin->initialize(container);
}
delegate_ = plugin_delegate;
@@ -1320,10 +1325,17 @@ bool WebPluginImpl::ReinitializePluginForResponse(
WebPluginDelegate* plugin_delegate = page_delegate_->CreatePluginDelegate(
file_path_, mime_type_);
+ // Store the plugin's unique identifier, used by the container to track its
+ // script objects, and enable script objects (since Initialize may use them
+ // even if it fails).
+ npp_ = plugin_delegate->GetPluginNPP();
+ container_->allowScriptObjects();
+
bool ok = plugin_delegate && plugin_delegate->Initialize(
plugin_url_, arg_names_, arg_values_, this, load_manually_);
if (!ok) {
+ container_->clearScriptObjects();
container_ = NULL;
// TODO(iyengar) Should we delete the current plugin instance here?
return false;
« no previous file with comments | « content/renderer/webplugin_delegate_proxy.cc ('k') | webkit/renderer/cpp_variant_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698