OLD | NEW |
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 params, | 82 params, |
83 HtmlData(params, template_html)) { | 83 HtmlData(params, template_html)) { |
84 } | 84 } |
85 | 85 |
86 MobileYouTubePlugin::~MobileYouTubePlugin() {} | 86 MobileYouTubePlugin::~MobileYouTubePlugin() {} |
87 | 87 |
88 // static | 88 // static |
89 bool MobileYouTubePlugin::IsYouTubeURL(const GURL& url, | 89 bool MobileYouTubePlugin::IsYouTubeURL(const GURL& url, |
90 const std::string& mime_type) { | 90 const std::string& mime_type) { |
91 std::string host = url.host(); | 91 std::string host = url.host(); |
92 bool is_youtube = EndsWith(host, "youtube.com", true) || | 92 bool is_youtube = base::EndsWith(host, "youtube.com", true) || |
93 EndsWith(host, "youtube-nocookie.com", true); | 93 base::EndsWith(host, "youtube-nocookie.com", true); |
94 | 94 |
95 return is_youtube && IsValidYouTubeVideo(url.path()) && | 95 return is_youtube && IsValidYouTubeVideo(url.path()) && |
96 base::LowerCaseEqualsASCII(mime_type, | 96 base::LowerCaseEqualsASCII(mime_type, |
97 content::kFlashPluginSwfMimeType); | 97 content::kFlashPluginSwfMimeType); |
98 } | 98 } |
99 | 99 |
100 void MobileYouTubePlugin::OpenYoutubeUrlCallback() { | 100 void MobileYouTubePlugin::OpenYoutubeUrlCallback() { |
101 std::string youtube("vnd.youtube:"); | 101 std::string youtube("vnd.youtube:"); |
102 GURL url(youtube.append(GetYoutubeVideoId(GetPluginParams()))); | 102 GURL url(youtube.append(GetYoutubeVideoId(GetPluginParams()))); |
103 WebURLRequest request; | 103 WebURLRequest request; |
104 request.initialize(); | 104 request.initialize(); |
105 request.setURL(url); | 105 request.setURL(url); |
106 render_frame()->LoadURLExternally( | 106 render_frame()->LoadURLExternally( |
107 GetFrame(), request, blink::WebNavigationPolicyNewForegroundTab); | 107 GetFrame(), request, blink::WebNavigationPolicyNewForegroundTab); |
108 } | 108 } |
109 | 109 |
110 v8::Local<v8::Value> MobileYouTubePlugin::GetV8Handle(v8::Isolate* isolate) { | 110 v8::Local<v8::Value> MobileYouTubePlugin::GetV8Handle(v8::Isolate* isolate) { |
111 return gin::CreateHandle(isolate, this).ToV8(); | 111 return gin::CreateHandle(isolate, this).ToV8(); |
112 } | 112 } |
113 | 113 |
114 gin::ObjectTemplateBuilder MobileYouTubePlugin::GetObjectTemplateBuilder( | 114 gin::ObjectTemplateBuilder MobileYouTubePlugin::GetObjectTemplateBuilder( |
115 v8::Isolate* isolate) { | 115 v8::Isolate* isolate) { |
116 return gin::Wrappable<MobileYouTubePlugin>::GetObjectTemplateBuilder(isolate) | 116 return gin::Wrappable<MobileYouTubePlugin>::GetObjectTemplateBuilder(isolate) |
117 .SetMethod("openYoutubeURL", | 117 .SetMethod("openYoutubeURL", |
118 &MobileYouTubePlugin::OpenYoutubeUrlCallback); | 118 &MobileYouTubePlugin::OpenYoutubeUrlCallback); |
119 } | 119 } |
120 | 120 |
121 } // namespace plugins | 121 } // namespace plugins |
OLD | NEW |