OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/chrome_plugin_placeholder.h" | 5 #include "chrome/renderer/plugins/chrome_plugin_placeholder.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/common/prerender_messages.h" | 9 #include "chrome/common/prerender_messages.h" |
10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
11 #include "chrome/renderer/chrome_content_renderer_client.h" | 11 #include "chrome/renderer/chrome_content_renderer_client.h" |
12 #include "chrome/renderer/custom_menu_commands.h" | 12 #include "chrome/renderer/custom_menu_commands.h" |
13 #include "chrome/renderer/plugins/plugin_uma.h" | 13 #include "chrome/renderer/plugins/plugin_uma.h" |
14 #include "content/public/common/context_menu_params.h" | 14 #include "content/public/common/context_menu_params.h" |
15 #include "content/public/renderer/render_frame.h" | 15 #include "content/public/renderer/render_frame.h" |
16 #include "content/public/renderer/render_thread.h" | 16 #include "content/public/renderer/render_thread.h" |
17 #include "content/public/renderer/render_view_observer.h" | |
18 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
19 #include "grit/renderer_resources.h" | 18 #include "grit/renderer_resources.h" |
20 #include "grit/webkit_strings.h" | 19 #include "grit/webkit_strings.h" |
21 #include "third_party/WebKit/public/web/WebDocument.h" | 20 #include "third_party/WebKit/public/web/WebDocument.h" |
22 #include "third_party/WebKit/public/web/WebFrame.h" | 21 #include "third_party/WebKit/public/web/WebFrame.h" |
23 #include "third_party/WebKit/public/web/WebInputEvent.h" | 22 #include "third_party/WebKit/public/web/WebInputEvent.h" |
24 #include "third_party/WebKit/public/web/WebScriptSource.h" | 23 #include "third_party/WebKit/public/web/WebScriptSource.h" |
25 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
26 #include "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
27 #include "ui/base/webui/jstemplate_builder.h" | 26 #include "ui/base/webui/jstemplate_builder.h" |
(...skipping 12 matching lines...) Expand all Loading... |
40 using webkit_glue::CppArgumentList; | 39 using webkit_glue::CppArgumentList; |
41 using webkit_glue::CppVariant; | 40 using webkit_glue::CppVariant; |
42 | 41 |
43 namespace { | 42 namespace { |
44 const plugins::PluginPlaceholder* g_last_active_menu = NULL; | 43 const plugins::PluginPlaceholder* g_last_active_menu = NULL; |
45 } // namespace | 44 } // namespace |
46 | 45 |
47 const char ChromePluginPlaceholder::kPluginPlaceholderDataURL[] = | 46 const char ChromePluginPlaceholder::kPluginPlaceholderDataURL[] = |
48 "chrome://pluginplaceholderdata/"; | 47 "chrome://pluginplaceholderdata/"; |
49 | 48 |
50 class ChromePluginPlaceholder::RenderViewObserver | |
51 : public content::RenderViewObserver { | |
52 public: | |
53 explicit RenderViewObserver(ChromePluginPlaceholder* placeholder) | |
54 : content::RenderViewObserver( | |
55 placeholder->render_frame()->GetRenderView()), | |
56 placeholder_(placeholder) {} | |
57 | |
58 // content::RenderViewObserver implementation: | |
59 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { | |
60 // We don't swallow these messages because multiple blocked plugins and | |
61 // other objects have an interest in them. | |
62 IPC_BEGIN_MESSAGE_MAP(ChromePluginPlaceholder, message) | |
63 IPC_MESSAGE_FORWARD(ChromeViewMsg_LoadBlockedPlugins, placeholder_, | |
64 ChromePluginPlaceholder::OnLoadBlockedPlugins) | |
65 IPC_END_MESSAGE_MAP() | |
66 | |
67 return false; | |
68 } | |
69 | |
70 private: | |
71 ChromePluginPlaceholder* placeholder_; | |
72 }; | |
73 | |
74 ChromePluginPlaceholder::ChromePluginPlaceholder( | 49 ChromePluginPlaceholder::ChromePluginPlaceholder( |
75 content::RenderFrame* render_frame, | 50 content::RenderFrame* render_frame, |
76 blink::WebFrame* frame, | 51 blink::WebFrame* frame, |
77 const blink::WebPluginParams& params, | 52 const blink::WebPluginParams& params, |
78 const std::string& html_data, | 53 const std::string& html_data, |
79 const base::string16& title) | 54 const base::string16& title) |
80 : plugins::PluginPlaceholder(render_frame, | 55 : plugins::PluginPlaceholder(render_frame, |
81 frame, | 56 frame, |
82 params, | 57 params, |
83 html_data, | 58 html_data, |
84 GURL(kPluginPlaceholderDataURL)), | 59 GURL(kPluginPlaceholderDataURL)), |
85 status_(new ChromeViewHostMsg_GetPluginInfo_Status), | 60 status_(new ChromeViewHostMsg_GetPluginInfo_Status), |
86 title_(title), | 61 title_(title), |
87 #if defined(ENABLE_PLUGIN_INSTALLATION) | 62 #if defined(ENABLE_PLUGIN_INSTALLATION) |
88 placeholder_routing_id_(MSG_ROUTING_NONE), | 63 placeholder_routing_id_(MSG_ROUTING_NONE), |
89 #endif | 64 #endif |
90 has_host_(false), | 65 has_host_(false), |
91 context_menu_request_id_(0) { | 66 context_menu_request_id_(0) { |
92 RenderThread::Get()->AddObserver(this); | 67 RenderThread::Get()->AddObserver(this); |
93 | |
94 view_observer_.reset(new RenderViewObserver(this)); | |
95 } | 68 } |
96 | 69 |
97 ChromePluginPlaceholder::~ChromePluginPlaceholder() { | 70 ChromePluginPlaceholder::~ChromePluginPlaceholder() { |
98 RenderThread::Get()->RemoveObserver(this); | 71 RenderThread::Get()->RemoveObserver(this); |
99 if (context_menu_request_id_) | 72 if (context_menu_request_id_) |
100 render_frame()->CancelContextMenu(context_menu_request_id_); | 73 render_frame()->CancelContextMenu(context_menu_request_id_); |
101 | 74 |
102 #if defined(ENABLE_PLUGIN_INSTALLATION) | 75 #if defined(ENABLE_PLUGIN_INSTALLATION) |
103 if (placeholder_routing_id_ == MSG_ROUTING_NONE) | 76 if (placeholder_routing_id_ == MSG_ROUTING_NONE) |
104 return; | 77 return; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 placeholder_routing_id_ = RenderThread::Get()->GenerateRoutingID(); | 178 placeholder_routing_id_ = RenderThread::Get()->GenerateRoutingID(); |
206 RenderThread::Get()->AddRoute(placeholder_routing_id_, this); | 179 RenderThread::Get()->AddRoute(placeholder_routing_id_, this); |
207 return placeholder_routing_id_; | 180 return placeholder_routing_id_; |
208 } | 181 } |
209 #endif | 182 #endif |
210 | 183 |
211 bool ChromePluginPlaceholder::OnMessageReceived(const IPC::Message& message) { | 184 bool ChromePluginPlaceholder::OnMessageReceived(const IPC::Message& message) { |
212 #if defined(ENABLE_PLUGIN_INSTALLATION) | 185 #if defined(ENABLE_PLUGIN_INSTALLATION) |
213 bool handled = true; | 186 bool handled = true; |
214 IPC_BEGIN_MESSAGE_MAP(ChromePluginPlaceholder, message) | 187 IPC_BEGIN_MESSAGE_MAP(ChromePluginPlaceholder, message) |
215 IPC_MESSAGE_HANDLER(ChromeViewMsg_FoundMissingPlugin, OnFoundMissingPlugin) | 188 IPC_MESSAGE_HANDLER(ChromeViewMsg_FoundMissingPlugin, OnFoundMissingPlugin) |
216 IPC_MESSAGE_HANDLER(ChromeViewMsg_DidNotFindMissingPlugin, | 189 IPC_MESSAGE_HANDLER(ChromeViewMsg_DidNotFindMissingPlugin, |
217 OnDidNotFindMissingPlugin) | 190 OnDidNotFindMissingPlugin) |
218 IPC_MESSAGE_HANDLER(ChromeViewMsg_StartedDownloadingPlugin, | 191 IPC_MESSAGE_HANDLER(ChromeViewMsg_StartedDownloadingPlugin, |
219 OnStartedDownloadingPlugin) | 192 OnStartedDownloadingPlugin) |
220 IPC_MESSAGE_HANDLER(ChromeViewMsg_FinishedDownloadingPlugin, | 193 IPC_MESSAGE_HANDLER(ChromeViewMsg_FinishedDownloadingPlugin, |
221 OnFinishedDownloadingPlugin) | 194 OnFinishedDownloadingPlugin) |
222 IPC_MESSAGE_HANDLER(ChromeViewMsg_ErrorDownloadingPlugin, | 195 IPC_MESSAGE_HANDLER(ChromeViewMsg_ErrorDownloadingPlugin, |
223 OnErrorDownloadingPlugin) | 196 OnErrorDownloadingPlugin) |
224 IPC_MESSAGE_HANDLER(ChromeViewMsg_CancelledDownloadingPlugin, | 197 IPC_MESSAGE_HANDLER(ChromeViewMsg_CancelledDownloadingPlugin, |
225 OnCancelledDownloadingPlugin) | 198 OnCancelledDownloadingPlugin) |
226 IPC_MESSAGE_UNHANDLED(handled = false) | 199 IPC_MESSAGE_HANDLER(ChromeViewMsg_LoadBlockedPlugins, OnLoadBlockedPlugins) |
| 200 IPC_MESSAGE_UNHANDLED(handled = false) |
227 IPC_END_MESSAGE_MAP() | 201 IPC_END_MESSAGE_MAP() |
228 | 202 |
229 if (handled) | 203 if (handled) |
230 return true; | 204 return true; |
231 #endif | 205 #endif |
232 | 206 |
233 // We don't swallow these messages because multiple blocked plugins and other | 207 // We don't swallow these messages because multiple blocked plugins and other |
234 // objects have an interest in them. | 208 // objects have an interest in them. |
235 IPC_BEGIN_MESSAGE_MAP(ChromePluginPlaceholder, message) | 209 IPC_BEGIN_MESSAGE_MAP(ChromePluginPlaceholder, message) |
236 IPC_MESSAGE_HANDLER(PrerenderMsg_SetIsPrerendering, OnSetIsPrerendering) | 210 IPC_MESSAGE_HANDLER(PrerenderMsg_SetIsPrerendering, OnSetIsPrerendering) |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 context_menu_request_id_ = render_frame()->ShowContextMenu(this, params); | 352 context_menu_request_id_ = render_frame()->ShowContextMenu(this, params); |
379 g_last_active_menu = this; | 353 g_last_active_menu = this; |
380 } | 354 } |
381 | 355 |
382 void ChromePluginPlaceholder::BindWebFrame(blink::WebFrame* frame) { | 356 void ChromePluginPlaceholder::BindWebFrame(blink::WebFrame* frame) { |
383 plugins::PluginPlaceholder::BindWebFrame(frame); | 357 plugins::PluginPlaceholder::BindWebFrame(frame); |
384 BindCallback("openAboutPlugins", | 358 BindCallback("openAboutPlugins", |
385 base::Bind(&ChromePluginPlaceholder::OpenAboutPluginsCallback, | 359 base::Bind(&ChromePluginPlaceholder::OpenAboutPluginsCallback, |
386 base::Unretained(this))); | 360 base::Unretained(this))); |
387 } | 361 } |
OLD | NEW |