Index: components/plugins/renderer/plugin_placeholder.cc |
diff --git a/components/plugins/renderer/plugin_placeholder.cc b/components/plugins/renderer/plugin_placeholder.cc |
index 405ac86d0946f033910478085da4ea75a8b74647..343c7ad1614d011fed492ac95b5327f4129cc6ab 100644 |
--- a/components/plugins/renderer/plugin_placeholder.cc |
+++ b/components/plugins/renderer/plugin_placeholder.cc |
@@ -15,6 +15,7 @@ |
#include "content/public/common/context_menu_params.h" |
#include "content/public/renderer/render_frame.h" |
#include "content/public/renderer/render_thread.h" |
+#include "gin/object_template_builder.h" |
#include "third_party/WebKit/public/web/WebDocument.h" |
#include "third_party/WebKit/public/web/WebElement.h" |
#include "third_party/WebKit/public/web/WebFrame.h" |
@@ -35,11 +36,11 @@ using blink::WebPluginContainer; |
using blink::WebPluginParams; |
using blink::WebScriptSource; |
using blink::WebURLRequest; |
-using webkit_glue::CppArgumentList; |
-using webkit_glue::CppVariant; |
namespace plugins { |
+gin::WrapperInfo PluginPlaceholder::kWrapperInfo = {gin::kEmbedderNativeGin}; |
+ |
PluginPlaceholder::PluginPlaceholder(content::RenderFrame* render_frame, |
WebFrame* frame, |
const WebPluginParams& params, |
@@ -59,17 +60,13 @@ PluginPlaceholder::PluginPlaceholder(content::RenderFrame* render_frame, |
PluginPlaceholder::~PluginPlaceholder() {} |
-void PluginPlaceholder::BindWebFrame(WebFrame* frame) { |
- BindToJavascript(frame, "plugin"); |
- BindCallback( |
- "load", |
- base::Bind(&PluginPlaceholder::LoadCallback, base::Unretained(this))); |
- BindCallback( |
- "hide", |
- base::Bind(&PluginPlaceholder::HideCallback, base::Unretained(this))); |
- BindCallback("didFinishLoading", |
- base::Bind(&PluginPlaceholder::DidFinishLoadingCallback, |
- base::Unretained(this))); |
+gin::ObjectTemplateBuilder PluginPlaceholder::GetObjectTemplateBuilder( |
+ v8::Isolate* isolate) { |
+ return gin::Wrappable<PluginPlaceholder>::GetObjectTemplateBuilder(isolate) |
+ .SetMethod("load", &PluginPlaceholder::LoadCallback) |
+ .SetMethod("hide", &PluginPlaceholder::HideCallback) |
+ .SetMethod("didFinishLoading", |
+ &PluginPlaceholder::DidFinishLoadingCallback); |
} |
void PluginPlaceholder::ReplacePlugin(WebPlugin* new_plugin) { |
@@ -87,10 +84,11 @@ void PluginPlaceholder::ReplacePlugin(WebPlugin* new_plugin) { |
return; |
} |
- // The plug-in has been removed from the page. Destroy the old plug-in |
- // (which will destroy us). |
+ // The plug-in has been removed from the page. Destroy the old plug-in. We |
+ // will be destroyed as soon as V8 garbage collects us. |
if (!element.pluginContainer()) { |
plugin_->destroy(); |
+ plugin_ = NULL; |
return; |
} |
@@ -104,6 +102,7 @@ void PluginPlaceholder::ReplacePlugin(WebPlugin* new_plugin) { |
container->reportGeometry(); |
plugin_->ReplayReceivedData(new_plugin); |
plugin_->destroy(); |
+ plugin_ = NULL; |
} |
void PluginPlaceholder::HidePlugin() { |
@@ -152,8 +151,6 @@ void PluginPlaceholder::HidePlugin() { |
} |
} |
-void PluginPlaceholder::WillDestroyPlugin() { delete this; } |
- |
void PluginPlaceholder::SetMessage(const base::string16& message) { |
message_ = message; |
if (finished_loading_) |
@@ -173,6 +170,10 @@ void PluginPlaceholder::ShowContextMenu(const WebMouseEvent& event) { |
return; |
} |
+void PluginPlaceholder::OnDestruct() { |
+ frame_ = NULL; |
+} |
+ |
void PluginPlaceholder::OnLoadBlockedPlugins(const std::string& identifier) { |
if (!identifier.empty() && identifier != identifier_) |
return; |
@@ -207,20 +208,17 @@ void PluginPlaceholder::LoadPlugin() { |
ReplacePlugin(plugin); |
} |
-void PluginPlaceholder::LoadCallback(const CppArgumentList& args, |
- CppVariant* result) { |
+void PluginPlaceholder::LoadCallback() { |
RenderThread::Get()->RecordAction(UserMetricsAction("Plugin_Load_Click")); |
LoadPlugin(); |
} |
-void PluginPlaceholder::HideCallback(const CppArgumentList& args, |
- CppVariant* result) { |
+void PluginPlaceholder::HideCallback() { |
RenderThread::Get()->RecordAction(UserMetricsAction("Plugin_Hide_Click")); |
HidePlugin(); |
} |
-void PluginPlaceholder::DidFinishLoadingCallback(const CppArgumentList& args, |
- CppVariant* result) { |
+void PluginPlaceholder::DidFinishLoadingCallback() { |
finished_loading_ = true; |
if (message_.length() > 0) |
UpdateMessage(); |