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" |
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" | |
25 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebData.h" | 24 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebData.h" |
26 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h" | 25 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h" |
27 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" | 26 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" |
28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" | 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" |
29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" | 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMenuItemInfo.h" | 32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMenuItemInfo.h" |
34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" | 33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" |
35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRegularExpression.
h" | 34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRegularExpression.
h" |
36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" | 35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" |
37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCaseSensitivit
y.h" | 36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCaseSensitivit
y.h" |
38 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
39 #include "ui/base/l10n/l10n_util.h" | 38 #include "ui/base/l10n/l10n_util.h" |
40 #include "ui/base/resource/resource_bundle.h" | 39 #include "ui/base/resource/resource_bundle.h" |
41 #include "webkit/glue/webpreferences.h" | 40 #include "webkit/glue/webpreferences.h" |
42 #include "webkit/plugins/npapi/plugin_group.h" | 41 #include "webkit/plugins/npapi/plugin_group.h" |
43 #include "webkit/plugins/npapi/plugin_list.h" | |
44 #include "webkit/plugins/webview_plugin.h" | 42 #include "webkit/plugins/webview_plugin.h" |
45 | 43 |
46 using content::RenderThread; | 44 using content::RenderThread; |
47 using content::RenderView; | 45 using content::RenderView; |
48 using WebKit::WebContextMenuData; | 46 using WebKit::WebContextMenuData; |
49 using WebKit::WebElement; | 47 using WebKit::WebElement; |
50 using WebKit::WebFrame; | 48 using WebKit::WebFrame; |
51 using WebKit::WebMenuItemInfo; | 49 using WebKit::WebMenuItemInfo; |
52 using WebKit::WebMouseEvent; | 50 using WebKit::WebMouseEvent; |
53 using WebKit::WebNode; | 51 using WebKit::WebNode; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 #if defined(ENABLE_PLUGIN_INSTALLATION) | 90 #if defined(ENABLE_PLUGIN_INSTALLATION) |
93 RenderThread::Get()->Send(new ChromeViewHostMsg_FindMissingPlugin( | 91 RenderThread::Get()->Send(new ChromeViewHostMsg_FindMissingPlugin( |
94 missing_plugin->routing_id(), missing_plugin->CreateRoutingId(), | 92 missing_plugin->routing_id(), missing_plugin->CreateRoutingId(), |
95 params.mimeType.utf8())); | 93 params.mimeType.utf8())); |
96 #else | 94 #else |
97 missing_plugin->OnDidNotFindMissingPlugin(); | 95 missing_plugin->OnDidNotFindMissingPlugin(); |
98 #endif | 96 #endif |
99 return missing_plugin; | 97 return missing_plugin; |
100 } | 98 } |
101 | 99 |
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 | |
124 // static | 100 // static |
125 PluginPlaceholder* PluginPlaceholder::CreateBlockedPlugin( | 101 PluginPlaceholder* PluginPlaceholder::CreateBlockedPlugin( |
126 RenderView* render_view, | 102 RenderView* render_view, |
127 WebFrame* frame, | 103 WebFrame* frame, |
128 const WebPluginParams& params, | 104 const WebPluginParams& params, |
129 const WebPluginInfo& plugin, | 105 const WebPluginInfo& plugin, |
130 const string16& name, | 106 const string16& name, |
131 int template_id, | 107 int template_id, |
132 int message_id) { | 108 int message_id) { |
133 string16 message = l10n_util::GetStringFUTF16(message_id, name); | 109 string16 message = l10n_util::GetStringFUTF16(message_id, name); |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 RenderThread::Get()->Send( | 478 RenderThread::Get()->Send( |
503 new ChromeViewHostMsg_OpenAboutPlugins(routing_id())); | 479 new ChromeViewHostMsg_OpenAboutPlugins(routing_id())); |
504 } | 480 } |
505 | 481 |
506 void PluginPlaceholder::DidFinishLoadingCallback(const CppArgumentList& args, | 482 void PluginPlaceholder::DidFinishLoadingCallback(const CppArgumentList& args, |
507 CppVariant* result) { | 483 CppVariant* result) { |
508 finished_loading_ = true; | 484 finished_loading_ = true; |
509 if (message_.length() > 0) | 485 if (message_.length() > 0) |
510 UpdateMessage(); | 486 UpdateMessage(); |
511 } | 487 } |
OLD | NEW |