summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-08 22:55:22 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-08 22:55:22 +0000
commita0820d24d4f20fbc5f1c4fbe51c29b096cce6403 (patch)
treeb1184f774de27154e7be6e2911fe35908a413306 /chrome/renderer
parent9dcbadfa6c23e301a8c21da4cc98b990847ed34f (diff)
downloadchromium_src-a0820d24d4f20fbc5f1c4fbe51c29b096cce6403.zip
chromium_src-a0820d24d4f20fbc5f1c4fbe51c29b096cce6403.tar.gz
chromium_src-a0820d24d4f20fbc5f1c4fbe51c29b096cce6403.tar.bz2
Move the plugin placeholder from CppBoundClass to gin::Wrappable
BUG=297480 R=aa@chromium.org,bauerb@chromium.org Review URL: https://codereview.chromium.org/116163008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243682 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/plugins/DEPS1
-rw-r--r--chrome/renderer/plugins/chrome_plugin_placeholder.cc30
-rw-r--r--chrome/renderer/plugins/chrome_plugin_placeholder.h8
3 files changed, 26 insertions, 13 deletions
diff --git a/chrome/renderer/plugins/DEPS b/chrome/renderer/plugins/DEPS
index 9883c71..3929850 100644
--- a/chrome/renderer/plugins/DEPS
+++ b/chrome/renderer/plugins/DEPS
@@ -1,3 +1,4 @@
include_rules = [
+ "+gin",
"+third_party/widevine",
]
diff --git a/chrome/renderer/plugins/chrome_plugin_placeholder.cc b/chrome/renderer/plugins/chrome_plugin_placeholder.cc
index 899087a..d6631e6 100644
--- a/chrome/renderer/plugins/chrome_plugin_placeholder.cc
+++ b/chrome/renderer/plugins/chrome_plugin_placeholder.cc
@@ -14,12 +14,15 @@
#include "content/public/common/context_menu_params.h"
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_thread.h"
+#include "gin/handle.h"
+#include "gin/object_template_builder.h"
#include "grit/generated_resources.h"
#include "grit/renderer_resources.h"
#include "grit/webkit_strings.h"
#include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebFrame.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
+#include "third_party/WebKit/public/web/WebKit.h"
#include "third_party/WebKit/public/web/WebScriptSource.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
@@ -36,8 +39,6 @@ using blink::WebNode;
using blink::WebPlugin;
using blink::WebPluginContainer;
using blink::WebPluginParams;
-using webkit_glue::CppArgumentList;
-using webkit_glue::CppVariant;
namespace {
const plugins::PluginPlaceholder* g_last_active_menu = NULL;
@@ -218,9 +219,7 @@ void ChromePluginPlaceholder::OnLoadBlockedPlugins(
plugins::PluginPlaceholder::OnLoadBlockedPlugins(identifier);
}
-void ChromePluginPlaceholder::OpenAboutPluginsCallback(
- const CppArgumentList& args,
- CppVariant* result) {
+void ChromePluginPlaceholder::OpenAboutPluginsCallback() {
RenderThread::Get()->Send(
new ChromeViewHostMsg_OpenAboutPlugins(routing_id()));
}
@@ -267,7 +266,7 @@ void ChromePluginPlaceholder::OnCancelledDownloadingPlugin() {
#endif // defined(ENABLE_PLUGIN_INSTALLATION)
void ChromePluginPlaceholder::PluginListChanged() {
- if (!GetFrame())
+ if (!GetFrame() || !plugin())
return;
WebDocument document = GetFrame()->top()->document();
if (document.isNull())
@@ -354,8 +353,19 @@ void ChromePluginPlaceholder::ShowContextMenu(const WebMouseEvent& event) {
}
void ChromePluginPlaceholder::BindWebFrame(blink::WebFrame* frame) {
- plugins::PluginPlaceholder::BindWebFrame(frame);
- BindCallback("openAboutPlugins",
- base::Bind(&ChromePluginPlaceholder::OpenAboutPluginsCallback,
- base::Unretained(this)));
+ v8::Isolate* isolate = blink::mainThreadIsolate();
+ v8::HandleScope handle_scope(isolate);
+ v8::Handle<v8::Context> context = frame->mainWorldScriptContext();
+ DCHECK(!context.IsEmpty());
+
+ v8::Context::Scope context_scope(context);
+ v8::Handle<v8::Object> global = context->Global();
+ global->Set(gin::StringToV8(isolate, "plugin"),
+ gin::CreateHandle(isolate, this).ToV8());
+}
+
+gin::ObjectTemplateBuilder ChromePluginPlaceholder::GetObjectTemplateBuilder(
+ v8::Isolate* isolate) {
+ return PluginPlaceholder::GetObjectTemplateBuilder(isolate).SetMethod(
+ "openAboutPlugins", &ChromePluginPlaceholder::OpenAboutPluginsCallback);
}
diff --git a/chrome/renderer/plugins/chrome_plugin_placeholder.h b/chrome/renderer/plugins/chrome_plugin_placeholder.h
index 6686920..d7d1d81 100644
--- a/chrome/renderer/plugins/chrome_plugin_placeholder.h
+++ b/chrome/renderer/plugins/chrome_plugin_placeholder.h
@@ -52,6 +52,10 @@ class ChromePluginPlaceholder : public plugins::PluginPlaceholder,
// WebViewPlugin::Delegate (via PluginPlaceholder) method
virtual void BindWebFrame(blink::WebFrame* frame) OVERRIDE;
+ // gin::Wrappable (via PluginPlaceholder) method
+ virtual gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
+ v8::Isolate* isolate) OVERRIDE;
+
// content::RenderViewObserver (via PluginPlaceholder) override:
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
@@ -66,9 +70,7 @@ class ChromePluginPlaceholder : public plugins::PluginPlaceholder,
virtual void OnMenuClosed(int request_id) OVERRIDE;
// Javascript callback opens chrome://plugins in a new tab.
- // Arguments are required by the caller, but not used.
- void OpenAboutPluginsCallback(const webkit_glue::CppArgumentList& args,
- webkit_glue::CppVariant* result);
+ void OpenAboutPluginsCallback();
void OnLoadBlockedPlugins(const std::string& identifier);
void OnSetIsPrerendering(bool is_prerendering);