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

Unified Diff: content/renderer/browser_plugin/browser_plugin.cc

Issue 15941006: Track NPObject ownership by the originating plugins' NPP identifier. [2/3] (Chrome) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix CppBoundClass. Created 7 years, 7 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
Index: content/renderer/browser_plugin/browser_plugin.cc
diff --git a/content/renderer/browser_plugin/browser_plugin.cc b/content/renderer/browser_plugin/browser_plugin.cc
index d2756cb05a2d2e314bd54466b1afa6cb786171de..a7c0c7125d0aee08180bada2dbf98229c91be878 100644
--- a/content/renderer/browser_plugin/browser_plugin.cc
+++ b/content/renderer/browser_plugin/browser_plugin.cc
@@ -1138,6 +1138,10 @@ bool BrowserPlugin::initialize(WebPluginContainer* container) {
if (!GetContentClient()->renderer()->AllowBrowserPlugin(container))
return false;
+ // Tell |container| to allow this plugin to use script objects.
+ npp_.reset(new NPP_t);
+ container->allowScriptObjects();
+
bindings_.reset(new BrowserPluginBindings(this));
container_ = container;
container_->setWantsWheelEvents(true);
@@ -1181,6 +1185,12 @@ void BrowserPlugin::EnableCompositing(bool enable) {
}
void BrowserPlugin::destroy() {
+ // If the plugin was initialized then it has a valid |npp_| identifier, and
+ // the |container_| must clear references to the plugin's script objects.
+ DCHECK(!npp_ || container_);
+ if (container_)
+ container_->clearScriptObjects();
+
// The BrowserPlugin's WebPluginContainer is deleted immediately after this
// call returns, so let's not keep a reference to it around.
g_plugin_container_map.Get().erase(container_);
@@ -1203,6 +1213,10 @@ NPObject* BrowserPlugin::scriptableObject() {
return browser_plugin_np_object;
}
+NPP BrowserPlugin::pluginNPP() {
+ return npp_.get();
+}
+
bool BrowserPlugin::supportsKeyboardFocus() const {
return true;
}
« no previous file with comments | « content/renderer/browser_plugin/browser_plugin.h ('k') | content/renderer/browser_plugin/browser_plugin_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698