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

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: updates 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 MobileYouTubePlugin::MobileYouTubePlugin(content::RenderView* render_view, 73 MobileYouTubePlugin::MobileYouTubePlugin(content::RenderView* render_view,
74 blink::WebFrame* frame, 74 blink::WebFrame* frame,
75 const blink::WebPluginParams& params, 75 const blink::WebPluginParams& params,
76 base::StringPiece& template_html, 76 base::StringPiece& template_html,
77 GURL placeholderDataUrl) 77 GURL placeholderDataUrl)
78 : PluginPlaceholder(render_view, 78 : PluginPlaceholder(render_view,
79 frame, 79 frame,
80 params, 80 params,
81 HtmlData(params, template_html), 81 HtmlData(params, template_html),
82 placeholderDataUrl) {} 82 placeholderDataUrl),
83 weak_factory_(this) {
84 RegisterCallback("openYoutubeURL",
85 base::Bind(&MobileYouTubePlugin::OpenYoutubeUrlCallback,
86 weak_factory_.GetWeakPtr()));
87 }
88
89 MobileYouTubePlugin::~MobileYouTubePlugin() {}
83 90
84 // static 91 // static
85 bool MobileYouTubePlugin::IsYouTubeURL(const GURL& url, 92 bool MobileYouTubePlugin::IsYouTubeURL(const GURL& url,
86 const std::string& mime_type) { 93 const std::string& mime_type) {
87 std::string host = url.host(); 94 std::string host = url.host();
88 bool is_youtube = EndsWith(host, "youtube.com", true) || 95 bool is_youtube = EndsWith(host, "youtube.com", true) ||
89 EndsWith(host, "youtube-nocookie.com", true); 96 EndsWith(host, "youtube-nocookie.com", true);
90 97
91 return is_youtube && IsValidYouTubeVideo(url.path()) && 98 return is_youtube && IsValidYouTubeVideo(url.path()) &&
92 LowerCaseEqualsASCII(mime_type, content::kFlashPluginSwfMimeType); 99 LowerCaseEqualsASCII(mime_type, content::kFlashPluginSwfMimeType);
93 } 100 }
94 101
95 void MobileYouTubePlugin::OpenYoutubeUrlCallback( 102 void MobileYouTubePlugin::OpenYoutubeUrlCallback() {
96 const webkit_glue::CppArgumentList& args,
97 webkit_glue::CppVariant* result) {
98 std::string youtube("vnd.youtube:"); 103 std::string youtube("vnd.youtube:");
99 GURL url(youtube.append(GetYoutubeVideoId(GetPluginParams()))); 104 GURL url(youtube.append(GetYoutubeVideoId(GetPluginParams())));
100 WebURLRequest request; 105 WebURLRequest request;
101 request.initialize(); 106 request.initialize();
102 request.setURL(url); 107 request.setURL(url);
103 render_view()->LoadURLExternally( 108 render_view()->LoadURLExternally(
104 GetFrame(), request, blink::WebNavigationPolicyNewForegroundTab); 109 GetFrame(), request, blink::WebNavigationPolicyNewForegroundTab);
105 } 110 }
106 void MobileYouTubePlugin::BindWebFrame(WebFrame* frame) {
107 PluginPlaceholder::BindWebFrame(frame);
108 BindCallback("openYoutubeURL",
109 base::Bind(&MobileYouTubePlugin::OpenYoutubeUrlCallback,
110 base::Unretained(this)));
111 }
112 111
113 } // namespace plugins 112 } // namespace plugins
OLDNEW
« 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