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_frame_observer.h" |
16 #include "content/public/renderer/render_thread.h" | 17 #include "content/public/renderer/render_thread.h" |
17 #include "content/public/renderer/render_view.h" | 18 #include "content/public/renderer/render_view.h" |
18 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
19 #include "grit/renderer_resources.h" | 20 #include "grit/renderer_resources.h" |
20 #include "grit/webkit_strings.h" | 21 #include "grit/webkit_strings.h" |
21 #include "third_party/WebKit/public/web/WebDocument.h" | 22 #include "third_party/WebKit/public/web/WebDocument.h" |
22 #include "third_party/WebKit/public/web/WebFrame.h" | 23 #include "third_party/WebKit/public/web/WebFrame.h" |
23 #include "third_party/WebKit/public/web/WebInputEvent.h" | 24 #include "third_party/WebKit/public/web/WebInputEvent.h" |
24 #include "third_party/WebKit/public/web/WebScriptSource.h" | 25 #include "third_party/WebKit/public/web/WebScriptSource.h" |
25 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
(...skipping 14 matching lines...) Expand all Loading... |
40 using webkit_glue::CppArgumentList; | 41 using webkit_glue::CppArgumentList; |
41 using webkit_glue::CppVariant; | 42 using webkit_glue::CppVariant; |
42 | 43 |
43 namespace { | 44 namespace { |
44 const plugins::PluginPlaceholder* g_last_active_menu = NULL; | 45 const plugins::PluginPlaceholder* g_last_active_menu = NULL; |
45 } // namespace | 46 } // namespace |
46 | 47 |
47 const char ChromePluginPlaceholder::kPluginPlaceholderDataURL[] = | 48 const char ChromePluginPlaceholder::kPluginPlaceholderDataURL[] = |
48 "chrome://pluginplaceholderdata/"; | 49 "chrome://pluginplaceholderdata/"; |
49 | 50 |
| 51 class ChromePluginPlaceholder::RenderFrameObserver |
| 52 : public content::RenderFrameObserver { |
| 53 public: |
| 54 explicit RenderFrameObserver(ChromePluginPlaceholder* placeholder) |
| 55 : content::RenderFrameObserver(placeholder->GetRenderFrame()), |
| 56 placeholder_(placeholder) {} |
| 57 |
| 58 // content::RenderFrameObserver 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(PrerenderMsg_SetIsPrerendering, placeholder_, |
| 64 ChromePluginPlaceholder::OnSetIsPrerendering) |
| 65 IPC_END_MESSAGE_MAP() |
| 66 |
| 67 return false; |
| 68 } |
| 69 |
| 70 private: |
| 71 ChromePluginPlaceholder* placeholder_; |
| 72 }; |
| 73 |
50 ChromePluginPlaceholder::ChromePluginPlaceholder( | 74 ChromePluginPlaceholder::ChromePluginPlaceholder( |
51 content::RenderView* render_view, | 75 content::RenderView* render_view, |
52 content::RenderFrame* render_frame, | 76 content::RenderFrame* render_frame, |
53 blink::WebFrame* frame, | 77 blink::WebFrame* frame, |
54 const blink::WebPluginParams& params, | 78 const blink::WebPluginParams& params, |
55 const std::string& html_data, | 79 const std::string& html_data, |
56 const base::string16& title) | 80 const base::string16& title) |
57 : plugins::PluginPlaceholder(render_view, | 81 : plugins::PluginPlaceholder(render_view, |
58 render_frame, | 82 render_frame, |
59 frame, | 83 frame, |
60 params, | 84 params, |
61 html_data, | 85 html_data, |
62 GURL(kPluginPlaceholderDataURL)), | 86 GURL(kPluginPlaceholderDataURL)), |
63 status_(new ChromeViewHostMsg_GetPluginInfo_Status), | 87 status_(new ChromeViewHostMsg_GetPluginInfo_Status), |
64 title_(title), | 88 title_(title), |
65 #if defined(ENABLE_PLUGIN_INSTALLATION) | 89 #if defined(ENABLE_PLUGIN_INSTALLATION) |
66 placeholder_routing_id_(MSG_ROUTING_NONE), | 90 placeholder_routing_id_(MSG_ROUTING_NONE), |
67 #endif | 91 #endif |
68 has_host_(false), | 92 has_host_(false), |
69 context_menu_request_id_(0) { | 93 context_menu_request_id_(0) { |
70 RenderThread::Get()->AddObserver(this); | 94 RenderThread::Get()->AddObserver(this); |
| 95 |
| 96 frame_observer_.reset(new RenderFrameObserver(this)); |
71 } | 97 } |
72 | 98 |
73 ChromePluginPlaceholder::~ChromePluginPlaceholder() { | 99 ChromePluginPlaceholder::~ChromePluginPlaceholder() { |
74 RenderThread::Get()->RemoveObserver(this); | 100 RenderThread::Get()->RemoveObserver(this); |
75 if (context_menu_request_id_) | 101 if (context_menu_request_id_) |
76 render_view()->CancelContextMenu(context_menu_request_id_); | 102 render_view()->CancelContextMenu(context_menu_request_id_); |
77 | 103 |
78 #if defined(ENABLE_PLUGIN_INSTALLATION) | 104 #if defined(ENABLE_PLUGIN_INSTALLATION) |
79 if (placeholder_routing_id_ == MSG_ROUTING_NONE) | 105 if (placeholder_routing_id_ == MSG_ROUTING_NONE) |
80 return; | 106 return; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 OnErrorDownloadingPlugin) | 228 OnErrorDownloadingPlugin) |
203 IPC_MESSAGE_HANDLER(ChromeViewMsg_CancelledDownloadingPlugin, | 229 IPC_MESSAGE_HANDLER(ChromeViewMsg_CancelledDownloadingPlugin, |
204 OnCancelledDownloadingPlugin) | 230 OnCancelledDownloadingPlugin) |
205 IPC_MESSAGE_UNHANDLED(handled = false) | 231 IPC_MESSAGE_UNHANDLED(handled = false) |
206 IPC_END_MESSAGE_MAP() | 232 IPC_END_MESSAGE_MAP() |
207 | 233 |
208 if (handled) | 234 if (handled) |
209 return true; | 235 return true; |
210 #endif | 236 #endif |
211 | 237 |
212 // We don't swallow these messages because multiple blocked plugins have an | 238 // We don't swallow these messages because multiple blocked plugins and other |
213 // interest in them. | 239 // objects have an interest in them. |
214 IPC_BEGIN_MESSAGE_MAP(ChromePluginPlaceholder, message) | 240 IPC_BEGIN_MESSAGE_MAP(ChromePluginPlaceholder, message) |
215 IPC_MESSAGE_HANDLER(ChromeViewMsg_LoadBlockedPlugins, OnLoadBlockedPlugins) | 241 IPC_MESSAGE_HANDLER(ChromeViewMsg_LoadBlockedPlugins, OnLoadBlockedPlugins) |
216 IPC_MESSAGE_HANDLER(PrerenderMsg_SetIsPrerendering, OnSetIsPrerendering) | |
217 IPC_END_MESSAGE_MAP() | 242 IPC_END_MESSAGE_MAP() |
218 | 243 |
219 return false; | 244 return false; |
220 } | 245 } |
221 | 246 |
222 void ChromePluginPlaceholder::OnLoadBlockedPlugins( | 247 void ChromePluginPlaceholder::OnLoadBlockedPlugins( |
223 const std::string& identifier) { | 248 const std::string& identifier) { |
224 plugins::PluginPlaceholder::OnLoadBlockedPlugins(identifier); | 249 plugins::PluginPlaceholder::OnLoadBlockedPlugins(identifier); |
225 } | 250 } |
226 | 251 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 context_menu_request_id_ = render_view()->ShowContextMenu(this, params); | 383 context_menu_request_id_ = render_view()->ShowContextMenu(this, params); |
359 g_last_active_menu = this; | 384 g_last_active_menu = this; |
360 } | 385 } |
361 | 386 |
362 void ChromePluginPlaceholder::BindWebFrame(blink::WebFrame* frame) { | 387 void ChromePluginPlaceholder::BindWebFrame(blink::WebFrame* frame) { |
363 plugins::PluginPlaceholder::BindWebFrame(frame); | 388 plugins::PluginPlaceholder::BindWebFrame(frame); |
364 BindCallback("openAboutPlugins", | 389 BindCallback("openAboutPlugins", |
365 base::Bind(&ChromePluginPlaceholder::OpenAboutPluginsCallback, | 390 base::Bind(&ChromePluginPlaceholder::OpenAboutPluginsCallback, |
366 base::Unretained(this))); | 391 base::Unretained(this))); |
367 } | 392 } |
OLD | NEW |