Return Windows error code when create-process fails.
[chromium-blink-merge.git] / chrome / renderer / plugins / non_loadable_plugin_placeholder.cc
blob598ad1692e7852bb592632dfb63571aa8a984b59
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.
5 #include "chrome/renderer/plugins/non_loadable_plugin_placeholder.h"
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"
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));
29 base::DictionaryValue values;
30 values.SetString("message",
31 l10n_util::GetStringUTF8(IDS_PLUGIN_NOT_SUPPORTED));
33 std::string html_data = webui::GetI18nTemplateHtml(template_html, &values);
35 // PluginPlaceholder will destroy itself when its WebViewPlugin is going away.
36 return new plugins::PluginPlaceholder(render_frame, frame, params, html_data);
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));
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);
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);
57 content::RenderThread::Get()->Send(new ChromeViewHostMsg_CouldNotLoadPlugin(
58 plugin->routing_id(), file_path));
59 return plugin;