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 LowerCaseEqualsASCII(mime_type, content::kFlashPluginSwfMimeType); | 97 base::LowerCaseEqualsASCII(mime_type, |
| 98 content::kFlashPluginSwfMimeType); |
98 } | 99 } |
99 | 100 |
100 void MobileYouTubePlugin::OpenYoutubeUrlCallback() { | 101 void MobileYouTubePlugin::OpenYoutubeUrlCallback() { |
101 std::string youtube("vnd.youtube:"); | 102 std::string youtube("vnd.youtube:"); |
102 GURL url(youtube.append(GetYoutubeVideoId(GetPluginParams()))); | 103 GURL url(youtube.append(GetYoutubeVideoId(GetPluginParams()))); |
103 WebURLRequest request; | 104 WebURLRequest request; |
104 request.initialize(); | 105 request.initialize(); |
105 request.setURL(url); | 106 request.setURL(url); |
106 render_frame()->LoadURLExternally( | 107 render_frame()->LoadURLExternally( |
107 GetFrame(), request, blink::WebNavigationPolicyNewForegroundTab); | 108 GetFrame(), request, blink::WebNavigationPolicyNewForegroundTab); |
(...skipping 11 matching lines...) Expand all Loading... |
119 gin::CreateHandle(isolate, this).ToV8()); | 120 gin::CreateHandle(isolate, this).ToV8()); |
120 } | 121 } |
121 | 122 |
122 gin::ObjectTemplateBuilder MobileYouTubePlugin::GetObjectTemplateBuilder( | 123 gin::ObjectTemplateBuilder MobileYouTubePlugin::GetObjectTemplateBuilder( |
123 v8::Isolate* isolate) { | 124 v8::Isolate* isolate) { |
124 return PluginPlaceholder::GetObjectTemplateBuilder(isolate) | 125 return PluginPlaceholder::GetObjectTemplateBuilder(isolate) |
125 .SetMethod("openYoutubeURL", &MobileYouTubePlugin::OpenYoutubeUrlCallback); | 126 .SetMethod("openYoutubeURL", &MobileYouTubePlugin::OpenYoutubeUrlCallback); |
126 } | 127 } |
127 | 128 |
128 } // namespace plugins | 129 } // namespace plugins |
OLD | NEW |