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

Unified Diff: components/plugins/renderer/mobile_youtube_plugin.cc

Issue 116163008: Move the plugin placeholder from CppBoundClass to gin::Wrappable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 6 years, 11 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: components/plugins/renderer/mobile_youtube_plugin.cc
diff --git a/components/plugins/renderer/mobile_youtube_plugin.cc b/components/plugins/renderer/mobile_youtube_plugin.cc
index dd4688a92384122f5ff22182a619b4dcf1b4bf83..0fc3d4a73ee282bae6ebcd6e70f82c727dd9bfc6 100644
--- a/components/plugins/renderer/mobile_youtube_plugin.cc
+++ b/components/plugins/renderer/mobile_youtube_plugin.cc
@@ -11,7 +11,10 @@
#include "base/values.h"
#include "content/public/common/content_constants.h"
#include "content/public/renderer/render_frame.h"
+#include "gin/handle.h"
+#include "gin/object_template_builder.h"
#include "third_party/WebKit/public/web/WebFrame.h"
+#include "third_party/WebKit/public/web/WebKit.h"
#include "ui/base/webui/jstemplate_builder.h"
using blink::WebFrame;
@@ -81,6 +84,8 @@ MobileYouTubePlugin::MobileYouTubePlugin(content::RenderFrame* render_frame,
HtmlData(params, template_html),
placeholderDataUrl) {}
+MobileYouTubePlugin::~MobileYouTubePlugin() {}
+
// static
bool MobileYouTubePlugin::IsYouTubeURL(const GURL& url,
const std::string& mime_type) {
@@ -92,9 +97,7 @@ bool MobileYouTubePlugin::IsYouTubeURL(const GURL& url,
LowerCaseEqualsASCII(mime_type, content::kFlashPluginSwfMimeType);
}
-void MobileYouTubePlugin::OpenYoutubeUrlCallback(
- const webkit_glue::CppArgumentList& args,
- webkit_glue::CppVariant* result) {
+void MobileYouTubePlugin::OpenYoutubeUrlCallback() {
std::string youtube("vnd.youtube:");
GURL url(youtube.append(GetYoutubeVideoId(GetPluginParams())));
WebURLRequest request;
@@ -103,11 +106,23 @@ void MobileYouTubePlugin::OpenYoutubeUrlCallback(
render_frame()->LoadURLExternally(
GetFrame(), request, blink::WebNavigationPolicyNewForegroundTab);
}
+
void MobileYouTubePlugin::BindWebFrame(WebFrame* frame) {
- PluginPlaceholder::BindWebFrame(frame);
- BindCallback("openYoutubeURL",
- base::Bind(&MobileYouTubePlugin::OpenYoutubeUrlCallback,
- 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 MobileYouTubePlugin::GetObjectTemplateBuilder(
+ v8::Isolate* isolate) {
+ return PluginPlaceholder::GetObjectTemplateBuilder(isolate)
+ .SetMethod("openYoutubeURL", &MobileYouTubePlugin::OpenYoutubeUrlCallback);
}
} // namespace plugins
« no previous file with comments | « components/plugins/renderer/mobile_youtube_plugin.h ('k') | components/plugins/renderer/plugin_placeholder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698