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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 MobileYouTubePlugin::~MobileYouTubePlugin() {} | 87 MobileYouTubePlugin::~MobileYouTubePlugin() {} |
88 | 88 |
89 // static | 89 // static |
90 bool MobileYouTubePlugin::IsYouTubeURL(const GURL& url, | 90 bool MobileYouTubePlugin::IsYouTubeURL(const GURL& url, |
91 const std::string& mime_type) { | 91 const std::string& mime_type) { |
92 std::string host = url.host(); | 92 std::string host = url.host(); |
93 bool is_youtube = EndsWith(host, "youtube.com", true) || | 93 bool is_youtube = EndsWith(host, "youtube.com", true) || |
94 EndsWith(host, "youtube-nocookie.com", true); | 94 EndsWith(host, "youtube-nocookie.com", true); |
95 | 95 |
96 return is_youtube && IsValidYouTubeVideo(url.path()) && | 96 return is_youtube && IsValidYouTubeVideo(url.path()) && |
97 base::LowerCaseEqualsASCII(mime_type, | 97 LowerCaseEqualsASCII(mime_type, content::kFlashPluginSwfMimeType); |
98 content::kFlashPluginSwfMimeType); | |
99 } | 98 } |
100 | 99 |
101 void MobileYouTubePlugin::OpenYoutubeUrlCallback() { | 100 void MobileYouTubePlugin::OpenYoutubeUrlCallback() { |
102 std::string youtube("vnd.youtube:"); | 101 std::string youtube("vnd.youtube:"); |
103 GURL url(youtube.append(GetYoutubeVideoId(GetPluginParams()))); | 102 GURL url(youtube.append(GetYoutubeVideoId(GetPluginParams()))); |
104 WebURLRequest request; | 103 WebURLRequest request; |
105 request.initialize(); | 104 request.initialize(); |
106 request.setURL(url); | 105 request.setURL(url); |
107 render_frame()->LoadURLExternally( | 106 render_frame()->LoadURLExternally( |
108 GetFrame(), request, blink::WebNavigationPolicyNewForegroundTab); | 107 GetFrame(), request, blink::WebNavigationPolicyNewForegroundTab); |
(...skipping 11 matching lines...) Expand all Loading... |
120 gin::CreateHandle(isolate, this).ToV8()); | 119 gin::CreateHandle(isolate, this).ToV8()); |
121 } | 120 } |
122 | 121 |
123 gin::ObjectTemplateBuilder MobileYouTubePlugin::GetObjectTemplateBuilder( | 122 gin::ObjectTemplateBuilder MobileYouTubePlugin::GetObjectTemplateBuilder( |
124 v8::Isolate* isolate) { | 123 v8::Isolate* isolate) { |
125 return PluginPlaceholder::GetObjectTemplateBuilder(isolate) | 124 return PluginPlaceholder::GetObjectTemplateBuilder(isolate) |
126 .SetMethod("openYoutubeURL", &MobileYouTubePlugin::OpenYoutubeUrlCallback); | 125 .SetMethod("openYoutubeURL", &MobileYouTubePlugin::OpenYoutubeUrlCallback); |
127 } | 126 } |
128 | 127 |
129 } // namespace plugins | 128 } // namespace plugins |
OLD | NEW |