| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/renderer/plugins/plugin_placeholder.h" | 5 #include "chrome/renderer/plugins/plugin_placeholder.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/json/string_escape.h" | 9 #include "base/json/string_escape.h" |
| 10 #include "base/string_piece.h" | 10 #include "base/string_piece.h" |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 } | 183 } |
| 184 | 184 |
| 185 #if defined(ENABLE_MOBILE_YOUTUBE_PLUGIN) | 185 #if defined(ENABLE_MOBILE_YOUTUBE_PLUGIN) |
| 186 // static | 186 // static |
| 187 PluginPlaceholder* PluginPlaceholder::CreateMobileYoutubePlugin( | 187 PluginPlaceholder* PluginPlaceholder::CreateMobileYoutubePlugin( |
| 188 content::RenderView* render_view, | 188 content::RenderView* render_view, |
| 189 WebFrame* frame, | 189 WebFrame* frame, |
| 190 const WebPluginParams& params) { | 190 const WebPluginParams& params) { |
| 191 const base::StringPiece template_html( | 191 const base::StringPiece template_html( |
| 192 ResourceBundle::GetSharedInstance().GetRawDataResource( | 192 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 193 IDR_YOUTUBE_PLUGIN_HTML, ui::SCALE_FACTOR_NONE)); | 193 IDR_MOBILE_YOUTUBE_PLUGIN_HTML, ui::SCALE_FACTOR_NONE)); |
| 194 | 194 |
| 195 DictionaryValue values; | 195 DictionaryValue values; |
| 196 values.SetString("video_id", GetYoutubeVideoId(params)); | 196 values.SetString("video_id", GetYoutubeVideoId(params)); |
| 197 std::string html_data = jstemplate_builder::GetI18nTemplateHtml( | 197 std::string html_data = jstemplate_builder::GetI18nTemplateHtml( |
| 198 template_html, &values); | 198 template_html, &values); |
| 199 | 199 |
| 200 // |youtube_plugin| will destroy itself when its WebViewPlugin is going away. | 200 // |youtube_plugin| will destroy itself when its WebViewPlugin is going away. |
| 201 PluginPlaceholder* youtube_plugin = new PluginPlaceholder( | 201 PluginPlaceholder* youtube_plugin = new PluginPlaceholder( |
| 202 render_view, frame, params, html_data, params.mimeType); | 202 render_view, frame, params, html_data, params.mimeType); |
| 203 return youtube_plugin; | 203 return youtube_plugin; |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 bool PluginPlaceholder::IsYouTubeURL(const GURL& url, | 629 bool PluginPlaceholder::IsYouTubeURL(const GURL& url, |
| 630 const std::string& mime_type) { | 630 const std::string& mime_type) { |
| 631 std::string host = url.host(); | 631 std::string host = url.host(); |
| 632 bool is_youtube = EndsWith(host, "youtube.com", true) || | 632 bool is_youtube = EndsWith(host, "youtube.com", true) || |
| 633 EndsWith(host, "youtube-nocookie.com", true); | 633 EndsWith(host, "youtube-nocookie.com", true); |
| 634 | 634 |
| 635 return is_youtube && IsValidYouTubeVideo(url.path()) && | 635 return is_youtube && IsValidYouTubeVideo(url.path()) && |
| 636 LowerCaseEqualsASCII(mime_type, "application/x-shockwave-flash"); | 636 LowerCaseEqualsASCII(mime_type, "application/x-shockwave-flash"); |
| 637 } | 637 } |
| 638 #endif | 638 #endif |
| OLD | NEW |