Index: components/plugins/renderer/plugin_placeholder.cc |
diff --git a/components/plugins/renderer/plugin_placeholder.cc b/components/plugins/renderer/plugin_placeholder.cc |
index aa82135446bb68a8b2c8b0a2faf53188aa3249aa..5194b83c244cf33214e0cda38df7422d9bccf311 100644 |
--- a/components/plugins/renderer/plugin_placeholder.cc |
+++ b/components/plugins/renderer/plugin_placeholder.cc |
@@ -34,8 +34,6 @@ using blink::WebPluginContainer; |
using blink::WebPluginParams; |
using blink::WebScriptSource; |
using blink::WebURLRequest; |
-using webkit_glue::CppArgumentList; |
-using webkit_glue::CppVariant; |
namespace plugins { |
@@ -58,17 +56,39 @@ PluginPlaceholder::PluginPlaceholder(content::RenderView* render_view, |
PluginPlaceholder::~PluginPlaceholder() {} |
+void PluginPlaceholder::InstallAdditionalCallbacks( |
+ v8::Handle<v8::Template> prototype) {} |
+ |
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))); |
+ v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); |
+ v8::Handle<v8::Context> context = frame->mainWorldScriptContext(); |
+ |
+ if (context.IsEmpty()) |
+ return; |
+ |
+ v8::Context::Scope context_scope(context); |
+ |
+ v8::Handle<v8::FunctionTemplate> plugin_template = |
+ v8::FunctionTemplate::New(); |
+ v8::Handle<v8::Template> prototype = plugin_template->PrototypeTemplate(); |
+ prototype->Set( |
+ v8::String::New("load"), |
+ v8::FunctionTemplate::New(&PluginPlaceholder::LoadCallback, |
+ v8::External::New(this))->GetFunction()); |
+ prototype->Set( |
+ v8::String::New("hide"), |
+ v8::FunctionTemplate::New(&PluginPlaceholder::HideCallback, |
+ v8::External::New(this))->GetFunction()); |
+ prototype->Set( |
+ v8::String::New("didFinishLoading"), |
+ v8::FunctionTemplate::New(&PluginPlaceholder::DidFinishLoadingCallback, |
+ v8::External::New(this))->GetFunction()); |
+ |
+ InstallAdditionalCallbacks(prototype); |
+ |
+ v8::Handle<v8::Object> global = context->Global(); |
+ global->Set(v8::String::New("plugin"), |
+ plugin_template->GetFunction()->NewInstance()); |
} |
void PluginPlaceholder::ReplacePlugin(WebPlugin* new_plugin) { |
@@ -206,23 +226,32 @@ void PluginPlaceholder::LoadPlugin() { |
ReplacePlugin(plugin); |
} |
-void PluginPlaceholder::LoadCallback(const CppArgumentList& args, |
- CppVariant* result) { |
+// static |
+void PluginPlaceholder::LoadCallback( |
+ const v8::FunctionCallbackInfo<v8::Value>& args) { |
+ PluginPlaceholder* plugin = reinterpret_cast<PluginPlaceholder*>( |
+ v8::External::Cast(*args.Data())->Value()); |
RenderThread::Get()->RecordUserMetrics("Plugin_Load_Click"); |
- LoadPlugin(); |
+ plugin->LoadPlugin(); |
} |
-void PluginPlaceholder::HideCallback(const CppArgumentList& args, |
- CppVariant* result) { |
+// static |
+void PluginPlaceholder::HideCallback( |
+ const v8::FunctionCallbackInfo<v8::Value>& args) { |
+ PluginPlaceholder* plugin = reinterpret_cast<PluginPlaceholder*>( |
+ v8::External::Cast(*args.Data())->Value()); |
RenderThread::Get()->RecordUserMetrics("Plugin_Hide_Click"); |
- HidePlugin(); |
+ plugin->HidePlugin(); |
} |
-void PluginPlaceholder::DidFinishLoadingCallback(const CppArgumentList& args, |
- CppVariant* result) { |
- finished_loading_ = true; |
- if (message_.length() > 0) |
- UpdateMessage(); |
+// static |
+void PluginPlaceholder::DidFinishLoadingCallback( |
+ const v8::FunctionCallbackInfo<v8::Value>& args) { |
+ PluginPlaceholder* plugin = reinterpret_cast<PluginPlaceholder*>( |
+ v8::External::Cast(*args.Data())->Value()); |
+ plugin->finished_loading_ = true; |
+ if (plugin->message_.length() > 0) |
+ plugin->UpdateMessage(); |
} |
void PluginPlaceholder::SetPluginInfo( |