Chromium Code Reviews| 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..7d6266f2b95828d754bf8b2da926d8a5bbeb30b0 100644 |
| --- a/webkit/plugins/npapi/webplugin_impl.cc |
| +++ b/webkit/plugins/npapi/webplugin_impl.cc |
| @@ -260,12 +260,15 @@ bool WebPluginImpl::initialize(WebPluginContainer* container) { |
| WebKit::WebPlugin* replacement_plugin = |
| page_delegate_->CreatePluginReplacement(file_path_); |
| - if (!replacement_plugin || !replacement_plugin->initialize(container)) |
| + if (!replacement_plugin) |
|
darin (slow to review)
2013/06/18 23:26:24
It is not clear to me why you are making this chan
Wez
2013/06/19 05:17:54
Reworded comment to try to make that clearer.
|
| return false; |
| - container->setPlugin(replacement_plugin); |
| + // Schedule ourself for asynchronous destruction, and and swap ourself out |
|
darin (slow to review)
2013/06/18 23:26:24
nit: "and and"
Wez
2013/06/19 05:17:54
Done.
|
| + // for the replacement plugin. |
| destroy(); |
| - return true; |
| + container->setPlugin(replacement_plugin); |
| + |
| + return replacement_plugin->initialize(container); |
| } |
| delegate_ = plugin_delegate; |
| @@ -1320,10 +1323,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; |