Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Side by Side Diff: chrome/renderer/plugins/plugin_placeholder.cc

Issue 10093011: Show a replacement plug-in for loading errors. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/common/jstemplate_builder.h" 14 #include "chrome/common/jstemplate_builder.h"
15 #include "chrome/common/render_messages.h" 15 #include "chrome/common/render_messages.h"
16 #include "chrome/common/prerender_messages.h" 16 #include "chrome/common/prerender_messages.h"
17 #include "chrome/renderer/chrome_content_renderer_client.h" 17 #include "chrome/renderer/chrome_content_renderer_client.h"
18 #include "chrome/renderer/custom_menu_commands.h" 18 #include "chrome/renderer/custom_menu_commands.h"
19 #include "chrome/renderer/plugins/plugin_uma.h" 19 #include "chrome/renderer/plugins/plugin_uma.h"
20 #include "content/public/renderer/render_thread.h" 20 #include "content/public/renderer/render_thread.h"
21 #include "content/public/renderer/render_view.h" 21 #include "content/public/renderer/render_view.h"
22 #include "grit/generated_resources.h" 22 #include "grit/generated_resources.h"
23 #include "grit/renderer_resources.h" 23 #include "grit/renderer_resources.h"
24 #include "grit/webkit_strings.h"
24 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebData.h" 25 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebData.h"
25 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h" 26 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h"
26 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" 27 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h"
27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h"
28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMenuItemInfo.h" 33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMenuItemInfo.h"
33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" 34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h"
34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRegularExpression. h" 35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRegularExpression. h"
35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" 36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h"
36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCaseSensitivit y.h" 37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCaseSensitivit y.h"
37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 38 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
38 #include "ui/base/l10n/l10n_util.h" 39 #include "ui/base/l10n/l10n_util.h"
39 #include "ui/base/resource/resource_bundle.h" 40 #include "ui/base/resource/resource_bundle.h"
40 #include "webkit/glue/webpreferences.h" 41 #include "webkit/glue/webpreferences.h"
41 #include "webkit/plugins/npapi/plugin_group.h" 42 #include "webkit/plugins/npapi/plugin_group.h"
43 #include "webkit/plugins/npapi/plugin_list.h"
42 #include "webkit/plugins/webview_plugin.h" 44 #include "webkit/plugins/webview_plugin.h"
43 45
44 using content::RenderThread; 46 using content::RenderThread;
45 using content::RenderView; 47 using content::RenderView;
46 using WebKit::WebContextMenuData; 48 using WebKit::WebContextMenuData;
47 using WebKit::WebElement; 49 using WebKit::WebElement;
48 using WebKit::WebFrame; 50 using WebKit::WebFrame;
49 using WebKit::WebMenuItemInfo; 51 using WebKit::WebMenuItemInfo;
50 using WebKit::WebMouseEvent; 52 using WebKit::WebMouseEvent;
51 using WebKit::WebNode; 53 using WebKit::WebNode;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 #if defined(ENABLE_PLUGIN_INSTALLATION) 92 #if defined(ENABLE_PLUGIN_INSTALLATION)
91 RenderThread::Get()->Send(new ChromeViewHostMsg_FindMissingPlugin( 93 RenderThread::Get()->Send(new ChromeViewHostMsg_FindMissingPlugin(
92 missing_plugin->routing_id(), missing_plugin->CreateRoutingId(), 94 missing_plugin->routing_id(), missing_plugin->CreateRoutingId(),
93 params.mimeType.utf8())); 95 params.mimeType.utf8()));
94 #else 96 #else
95 missing_plugin->OnDidNotFindMissingPlugin(); 97 missing_plugin->OnDidNotFindMissingPlugin();
96 #endif 98 #endif
97 return missing_plugin; 99 return missing_plugin;
98 } 100 }
99 101
102 PluginPlaceholder* PluginPlaceholder::CreateErrorPlugin(
103 RenderView* render_view,
104 const FilePath& file_path) {
105 DictionaryValue values;
106 values.SetString("message",
107 l10n_util::GetStringUTF8(IDS_PLUGIN_INITIALIZATION_ERROR));
108
109 const base::StringPiece template_html(
110 ResourceBundle::GetSharedInstance().GetRawDataResource(
111 IDR_BLOCKED_PLUGIN_HTML));
112 std::string html_data =
113 jstemplate_builder::GetI18nTemplateHtml(template_html, &values);
114
115 WebPluginParams params;
116 // |missing_plugin| will destroy itself when its WebViewPlugin is going away.
117 PluginPlaceholder* plugin = new PluginPlaceholder(
118 render_view, NULL, params, html_data, params.mimeType);
119 plugin->set_allow_loading(true);
120
121 return plugin;
122 }
123
100 // static 124 // static
101 PluginPlaceholder* PluginPlaceholder::CreateBlockedPlugin( 125 PluginPlaceholder* PluginPlaceholder::CreateBlockedPlugin(
102 RenderView* render_view, 126 RenderView* render_view,
103 WebFrame* frame, 127 WebFrame* frame,
104 const WebPluginParams& params, 128 const WebPluginParams& params,
105 const WebPluginInfo& plugin, 129 const WebPluginInfo& plugin,
106 const string16& name, 130 const string16& name,
107 int template_id, 131 int template_id,
108 int message_id) { 132 int message_id) {
109 string16 message = l10n_util::GetStringFUTF16(message_id, name); 133 string16 message = l10n_util::GetStringFUTF16(message_id, name);
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 RenderThread::Get()->Send( 502 RenderThread::Get()->Send(
479 new ChromeViewHostMsg_OpenAboutPlugins(routing_id())); 503 new ChromeViewHostMsg_OpenAboutPlugins(routing_id()));
480 } 504 }
481 505
482 void PluginPlaceholder::DidFinishLoadingCallback(const CppArgumentList& args, 506 void PluginPlaceholder::DidFinishLoadingCallback(const CppArgumentList& args,
483 CppVariant* result) { 507 CppVariant* result) {
484 finished_loading_ = true; 508 finished_loading_ = true;
485 if (message_.length() > 0) 509 if (message_.length() > 0)
486 UpdateMessage(); 510 UpdateMessage();
487 } 511 }
OLDNEW
« no previous file with comments | « chrome/renderer/plugins/plugin_placeholder.h ('k') | content/public/renderer/content_renderer_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698