OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/renderer/plugins/non_loadable_plugin_placeholder.h" |
| 6 |
| 7 #include "base/files/file_path.h" |
| 8 #include "base/values.h" |
| 9 #include "chrome/common/render_messages.h" |
| 10 #include "chrome/grit/generated_resources.h" |
| 11 #include "chrome/grit/renderer_resources.h" |
| 12 #include "components/plugins/renderer/plugin_placeholder.h" |
| 13 #include "content/app/strings/grit/content_strings.h" |
| 14 #include "content/public/renderer/render_thread.h" |
| 15 #include "ui/base/l10n/l10n_util.h" |
| 16 #include "ui/base/resource/resource_bundle.h" |
| 17 #include "ui/base/webui/jstemplate_builder.h" |
| 18 |
| 19 // static |
| 20 plugins::PluginPlaceholder* |
| 21 NonLoadablePluginPlaceholder::CreateNotSupportedPlugin( |
| 22 content::RenderFrame* render_frame, |
| 23 blink::WebLocalFrame* frame, |
| 24 const blink::WebPluginParams& params) { |
| 25 const base::StringPiece template_html( |
| 26 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 27 IDR_BLOCKED_PLUGIN_HTML)); |
| 28 |
| 29 base::DictionaryValue values; |
| 30 values.SetString("message", |
| 31 l10n_util::GetStringUTF8(IDS_PLUGIN_NOT_SUPPORTED)); |
| 32 |
| 33 std::string html_data = webui::GetI18nTemplateHtml(template_html, &values); |
| 34 |
| 35 // PluginPlaceholder will destroy itself when its WebViewPlugin is going away. |
| 36 return new plugins::PluginPlaceholder(render_frame, frame, params, html_data); |
| 37 } |
| 38 |
| 39 // static |
| 40 plugins::PluginPlaceholder* NonLoadablePluginPlaceholder::CreateErrorPlugin( |
| 41 content::RenderFrame* render_frame, |
| 42 const base::FilePath& file_path) { |
| 43 base::DictionaryValue values; |
| 44 values.SetString("message", |
| 45 l10n_util::GetStringUTF8(IDS_PLUGIN_INITIALIZATION_ERROR)); |
| 46 |
| 47 const base::StringPiece template_html( |
| 48 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 49 IDR_BLOCKED_PLUGIN_HTML)); |
| 50 std::string html_data = webui::GetI18nTemplateHtml(template_html, &values); |
| 51 |
| 52 blink::WebPluginParams params; |
| 53 // PluginPlaceholder will destroy itself when its WebViewPlugin is going away. |
| 54 plugins::PluginPlaceholder* plugin = |
| 55 new plugins::PluginPlaceholder(render_frame, nullptr, params, html_data); |
| 56 |
| 57 content::RenderThread::Get()->Send(new ChromeViewHostMsg_CouldNotLoadPlugin( |
| 58 plugin->routing_id(), file_path)); |
| 59 return plugin; |
| 60 } |
OLD | NEW |