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

Unified Diff: components/plugins/renderer/loadable_plugin_placeholder.cc

Issue 2151483007: Plugin Power Saver: Fix a dangling WebViewPlugin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698