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

Side by Side Diff: components/plugins/renderer/mobile_youtube_plugin.cc

Issue 69953006: Bind plugin placeholder directly to v8 instead of over CppBoundClass (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/plugins/renderer/mobile_youtube_plugin.h" 5 #include "components/plugins/renderer/mobile_youtube_plugin.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/strings/string_piece.h" 9 #include "base/strings/string_piece.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 bool MobileYouTubePlugin::IsYouTubeURL(const GURL& url, 85 bool MobileYouTubePlugin::IsYouTubeURL(const GURL& url,
86 const std::string& mime_type) { 86 const std::string& mime_type) {
87 std::string host = url.host(); 87 std::string host = url.host();
88 bool is_youtube = EndsWith(host, "youtube.com", true) || 88 bool is_youtube = EndsWith(host, "youtube.com", true) ||
89 EndsWith(host, "youtube-nocookie.com", true); 89 EndsWith(host, "youtube-nocookie.com", true);
90 90
91 return is_youtube && IsValidYouTubeVideo(url.path()) && 91 return is_youtube && IsValidYouTubeVideo(url.path()) &&
92 LowerCaseEqualsASCII(mime_type, content::kFlashPluginSwfMimeType); 92 LowerCaseEqualsASCII(mime_type, content::kFlashPluginSwfMimeType);
93 } 93 }
94 94
95 // static
95 void MobileYouTubePlugin::OpenYoutubeUrlCallback( 96 void MobileYouTubePlugin::OpenYoutubeUrlCallback(
96 const webkit_glue::CppArgumentList& args, 97 const v8::FunctionCallbackInfo<v8::Value>& args) {
Bernhard Bauer 2013/11/12 16:37:20 Move to anonymous namespace
97 webkit_glue::CppVariant* result) { 98 MobileYouTubePlugin* plugin = reinterpret_cast<MobileYouTubePlugin*>(
99 v8::External::Cast(*args.Data())->Value());
98 std::string youtube("vnd.youtube:"); 100 std::string youtube("vnd.youtube:");
99 GURL url(youtube.append(GetYoutubeVideoId(GetPluginParams()))); 101 GURL url(youtube.append(GetYoutubeVideoId(plugin->GetPluginParams())));
100 WebURLRequest request; 102 WebURLRequest request;
101 request.initialize(); 103 request.initialize();
102 request.setURL(url); 104 request.setURL(url);
103 render_view()->LoadURLExternally( 105 plugin->render_view()->LoadURLExternally(
104 GetFrame(), request, blink::WebNavigationPolicyNewForegroundTab); 106 plugin->GetFrame(), request, blink::WebNavigationPolicyNewForegroundTab);
105 } 107 }
106 void MobileYouTubePlugin::BindWebFrame(WebFrame* frame) { 108
107 PluginPlaceholder::BindWebFrame(frame); 109 void MobileYouTubePlugin::InstallAdditionalCallbacsk(
108 BindCallback("openYoutubeURL", 110 v8::Handle<v8::Template> prototype) {
109 base::Bind(&MobileYouTubePlugin::OpenYoutubeUrlCallback, 111 prototype->Set(
110 base::Unretained(this))); 112 v8::String::New("openYoutubeURL"),
113 v8::FunctionTemplate::New(&PluginPlaceholder::OpenYoutubeUrlCallback,
114 v8::External::New(this))->GetFunction());
111 } 115 }
112 116
113 } // namespace plugins 117 } // namespace plugins
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698