Index: components/plugins/renderer/plugin_placeholder.cc |
diff --git a/components/plugins/renderer/plugin_placeholder.cc b/components/plugins/renderer/plugin_placeholder.cc |
index df85dd562bd181041fd12c095143e0a83406458a..2953ca5f5ec66ea665f97db10bf199f7f716a498 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) { |
@@ -91,6 +88,7 @@ void PluginPlaceholder::ReplacePlugin(WebPlugin* new_plugin) { |
// (which will destroy us). |
Bernhard Bauer
2014/01/07 09:35:42
I think this comment needs updating now.
jochen (gone - plz use gerrit)
2014/01/08 19:18:23
Done.
|
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(); |