| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 IDR_BLOCKED_PLUGIN_HTML)); | 109 IDR_BLOCKED_PLUGIN_HTML)); |
| 110 | 110 |
| 111 DictionaryValue values; | 111 DictionaryValue values; |
| 112 #if defined(ENABLE_PLUGIN_INSTALLATION) | 112 #if defined(ENABLE_PLUGIN_INSTALLATION) |
| 113 values.SetString("message", l10n_util::GetStringUTF8(IDS_PLUGIN_SEARCHING)); | 113 values.SetString("message", l10n_util::GetStringUTF8(IDS_PLUGIN_SEARCHING)); |
| 114 #else | 114 #else |
| 115 values.SetString("message", | 115 values.SetString("message", |
| 116 l10n_util::GetStringUTF8(IDS_PLUGIN_NOT_SUPPORTED)); | 116 l10n_util::GetStringUTF8(IDS_PLUGIN_NOT_SUPPORTED)); |
| 117 #endif | 117 #endif |
| 118 | 118 |
| 119 std::string html_data = | 119 std::string html_data = webui::GetI18nTemplateHtml(template_html, &values); |
| 120 jstemplate_builder::GetI18nTemplateHtml(template_html, &values); | |
| 121 | 120 |
| 122 // |missing_plugin| will destroy itself when its WebViewPlugin is going away. | 121 // |missing_plugin| will destroy itself when its WebViewPlugin is going away. |
| 123 PluginPlaceholder* missing_plugin = new PluginPlaceholder( | 122 PluginPlaceholder* missing_plugin = new PluginPlaceholder( |
| 124 render_view, frame, params, html_data, params.mimeType); | 123 render_view, frame, params, html_data, params.mimeType); |
| 125 missing_plugin->set_allow_loading(true); | 124 missing_plugin->set_allow_loading(true); |
| 126 #if defined(ENABLE_PLUGIN_INSTALLATION) | 125 #if defined(ENABLE_PLUGIN_INSTALLATION) |
| 127 RenderThread::Get()->Send(new ChromeViewHostMsg_FindMissingPlugin( | 126 RenderThread::Get()->Send(new ChromeViewHostMsg_FindMissingPlugin( |
| 128 missing_plugin->routing_id(), missing_plugin->CreateRoutingId(), | 127 missing_plugin->routing_id(), missing_plugin->CreateRoutingId(), |
| 129 params.mimeType.utf8())); | 128 params.mimeType.utf8())); |
| 130 #endif | 129 #endif |
| 131 return missing_plugin; | 130 return missing_plugin; |
| 132 } | 131 } |
| 133 | 132 |
| 134 PluginPlaceholder* PluginPlaceholder::CreateErrorPlugin( | 133 PluginPlaceholder* PluginPlaceholder::CreateErrorPlugin( |
| 135 RenderView* render_view, | 134 RenderView* render_view, |
| 136 const FilePath& file_path) { | 135 const FilePath& file_path) { |
| 137 DictionaryValue values; | 136 DictionaryValue values; |
| 138 values.SetString("message", | 137 values.SetString("message", |
| 139 l10n_util::GetStringUTF8(IDS_PLUGIN_INITIALIZATION_ERROR)); | 138 l10n_util::GetStringUTF8(IDS_PLUGIN_INITIALIZATION_ERROR)); |
| 140 | 139 |
| 141 const base::StringPiece template_html( | 140 const base::StringPiece template_html( |
| 142 ResourceBundle::GetSharedInstance().GetRawDataResource( | 141 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 143 IDR_BLOCKED_PLUGIN_HTML)); | 142 IDR_BLOCKED_PLUGIN_HTML)); |
| 144 std::string html_data = | 143 std::string html_data = webui::GetI18nTemplateHtml(template_html, &values); |
| 145 jstemplate_builder::GetI18nTemplateHtml(template_html, &values); | |
| 146 | 144 |
| 147 WebPluginParams params; | 145 WebPluginParams params; |
| 148 // |missing_plugin| will destroy itself when its WebViewPlugin is going away. | 146 // |missing_plugin| will destroy itself when its WebViewPlugin is going away. |
| 149 PluginPlaceholder* plugin = new PluginPlaceholder( | 147 PluginPlaceholder* plugin = new PluginPlaceholder( |
| 150 render_view, NULL, params, html_data, params.mimeType); | 148 render_view, NULL, params, html_data, params.mimeType); |
| 151 | 149 |
| 152 RenderThread::Get()->Send( | 150 RenderThread::Get()->Send( |
| 153 new ChromeViewHostMsg_CouldNotLoadPlugin(plugin->routing_id(), | 151 new ChromeViewHostMsg_CouldNotLoadPlugin(plugin->routing_id(), |
| 154 file_path)); | 152 file_path)); |
| 155 return plugin; | 153 return plugin; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 169 values.SetString("message", message); | 167 values.SetString("message", message); |
| 170 values.SetString("name", name); | 168 values.SetString("name", name); |
| 171 values.SetString("hide", l10n_util::GetStringUTF8(IDS_PLUGIN_HIDE)); | 169 values.SetString("hide", l10n_util::GetStringUTF8(IDS_PLUGIN_HIDE)); |
| 172 | 170 |
| 173 const base::StringPiece template_html( | 171 const base::StringPiece template_html( |
| 174 ResourceBundle::GetSharedInstance().GetRawDataResource( | 172 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 175 template_id)); | 173 template_id)); |
| 176 | 174 |
| 177 DCHECK(!template_html.empty()) << "unable to load template. ID: " | 175 DCHECK(!template_html.empty()) << "unable to load template. ID: " |
| 178 << template_id; | 176 << template_id; |
| 179 std::string html_data = jstemplate_builder::GetI18nTemplateHtml( | 177 std::string html_data = webui::GetI18nTemplateHtml(template_html, &values); |
| 180 template_html, &values); | |
| 181 | 178 |
| 182 // |blocked_plugin| will destroy itself when its WebViewPlugin is going away. | 179 // |blocked_plugin| will destroy itself when its WebViewPlugin is going away. |
| 183 PluginPlaceholder* blocked_plugin = new PluginPlaceholder( | 180 PluginPlaceholder* blocked_plugin = new PluginPlaceholder( |
| 184 render_view, frame, params, html_data, name); | 181 render_view, frame, params, html_data, name); |
| 185 blocked_plugin->plugin_info_ = plugin; | 182 blocked_plugin->plugin_info_ = plugin; |
| 186 blocked_plugin->identifier_ = identifier; | 183 blocked_plugin->identifier_ = identifier; |
| 187 return blocked_plugin; | 184 return blocked_plugin; |
| 188 } | 185 } |
| 189 | 186 |
| 190 #if defined(ENABLE_MOBILE_YOUTUBE_PLUGIN) | 187 #if defined(ENABLE_MOBILE_YOUTUBE_PLUGIN) |
| 191 // static | 188 // static |
| 192 PluginPlaceholder* PluginPlaceholder::CreateMobileYoutubePlugin( | 189 PluginPlaceholder* PluginPlaceholder::CreateMobileYoutubePlugin( |
| 193 content::RenderView* render_view, | 190 content::RenderView* render_view, |
| 194 WebFrame* frame, | 191 WebFrame* frame, |
| 195 const WebPluginParams& params) { | 192 const WebPluginParams& params) { |
| 196 const base::StringPiece template_html( | 193 const base::StringPiece template_html( |
| 197 ResourceBundle::GetSharedInstance().GetRawDataResource( | 194 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 198 IDR_MOBILE_YOUTUBE_PLUGIN_HTML)); | 195 IDR_MOBILE_YOUTUBE_PLUGIN_HTML)); |
| 199 | 196 |
| 200 DictionaryValue values; | 197 DictionaryValue values; |
| 201 values.SetString("video_id", GetYoutubeVideoId(params)); | 198 values.SetString("video_id", GetYoutubeVideoId(params)); |
| 202 std::string html_data = jstemplate_builder::GetI18nTemplateHtml( | 199 std::string html_data = webui::GetI18nTemplateHtml(template_html, &values); |
| 203 template_html, &values); | |
| 204 | 200 |
| 205 // |youtube_plugin| will destroy itself when its WebViewPlugin is going away. | 201 // |youtube_plugin| will destroy itself when its WebViewPlugin is going away. |
| 206 PluginPlaceholder* youtube_plugin = new PluginPlaceholder( | 202 PluginPlaceholder* youtube_plugin = new PluginPlaceholder( |
| 207 render_view, frame, params, html_data, params.mimeType); | 203 render_view, frame, params, html_data, params.mimeType); |
| 208 return youtube_plugin; | 204 return youtube_plugin; |
| 209 } | 205 } |
| 210 #endif | 206 #endif |
| 211 | 207 |
| 212 PluginPlaceholder::PluginPlaceholder(content::RenderView* render_view, | 208 PluginPlaceholder::PluginPlaceholder(content::RenderView* render_view, |
| 213 WebFrame* frame, | 209 WebFrame* frame, |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 bool PluginPlaceholder::IsYouTubeURL(const GURL& url, | 644 bool PluginPlaceholder::IsYouTubeURL(const GURL& url, |
| 649 const std::string& mime_type) { | 645 const std::string& mime_type) { |
| 650 std::string host = url.host(); | 646 std::string host = url.host(); |
| 651 bool is_youtube = EndsWith(host, "youtube.com", true) || | 647 bool is_youtube = EndsWith(host, "youtube.com", true) || |
| 652 EndsWith(host, "youtube-nocookie.com", true); | 648 EndsWith(host, "youtube-nocookie.com", true); |
| 653 | 649 |
| 654 return is_youtube && IsValidYouTubeVideo(url.path()) && | 650 return is_youtube && IsValidYouTubeVideo(url.path()) && |
| 655 LowerCaseEqualsASCII(mime_type, kFlashPluginSwfMimeType); | 651 LowerCaseEqualsASCII(mime_type, kFlashPluginSwfMimeType); |
| 656 } | 652 } |
| 657 #endif | 653 #endif |
| OLD | NEW |