Index: components/plugins/renderer/loadable_plugin_placeholder.cc |
diff --git a/components/plugins/renderer/loadable_plugin_placeholder.cc b/components/plugins/renderer/loadable_plugin_placeholder.cc |
index aa9a97fedcd6237d352ee8237d847c34112cc4b1..7d50eecaf8112ca14a78ce2bfefb8e6f5cabf90c 100644 |
--- a/components/plugins/renderer/loadable_plugin_placeholder.cc |
+++ b/components/plugins/renderer/loadable_plugin_placeholder.cc |
@@ -104,9 +104,6 @@ void LoadablePluginPlaceholder::ReplacePlugin(blink::WebPlugin* new_plugin) { |
} |
container->setPlugin(new_plugin); |
- // Save the element in case the plugin is removed from the page during |
- // initialization. |
- blink::WebElement element = container->element(); |
bool plugin_needs_initialization = |
!premade_throttler_ || new_plugin != premade_throttler_->GetWebPlugin(); |
if (plugin_needs_initialization && !new_plugin->initialize(container)) { |
@@ -115,17 +112,14 @@ void LoadablePluginPlaceholder::ReplacePlugin(blink::WebPlugin* new_plugin) { |
// still exists, restore the placeholder and destroy the new plugin. |
container->setPlugin(plugin()); |
new_plugin->destroy(); |
+ } else { |
+ // The container has been destroyed, along with the new plugin. Destroy |
+ // our placeholder plugin also. |
+ plugin()->destroy(); |
} |
return; |
} |
- // The plugin has been removed from the page. Destroy the old plugin. We |
- // will be destroyed as soon as V8 garbage collects us. |
- if (!element.pluginContainer()) { |
- plugin()->destroy(); |
- return; |
- } |
- |
// During initialization, the new plugin might have replaced itself in turn |
// with another plugin. Make sure not to use the passed in |new_plugin| after |
// this point. |