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 | |
mmenke
2013/12/10 20:56:41
nit: Blank lines at the start of function bodies
jam
2013/12/10 21:14:17
Done.
| |
61 // We don't swallow these messages because multiple blocked plugins have an | |
62 // interest in them. | |
mmenke
2013/12/10 20:56:41
May want to replace "multiple blocked plugins" wit
jam
2013/12/10 21:14:17
I just copied this code, but ok.
| |
63 IPC_BEGIN_MESSAGE_MAP(ChromePluginPlaceholder, message) | |
64 IPC_MESSAGE_FORWARD(PrerenderMsg_SetIsPrerendering, placeholder_, | |
65 ChromePluginPlaceholder::OnSetIsPrerendering) | |
66 IPC_END_MESSAGE_MAP() | |
67 | |
68 return false; | |
69 } | |
70 | |
71 private: | |
72 ChromePluginPlaceholder* placeholder_; | |
73 }; | |
74 | |
50 ChromePluginPlaceholder::ChromePluginPlaceholder( | 75 ChromePluginPlaceholder::ChromePluginPlaceholder( |
51 content::RenderView* render_view, | 76 content::RenderView* render_view, |
52 content::RenderFrame* render_frame, | 77 content::RenderFrame* render_frame, |
53 blink::WebFrame* frame, | 78 blink::WebFrame* frame, |
54 const blink::WebPluginParams& params, | 79 const blink::WebPluginParams& params, |
55 const std::string& html_data, | 80 const std::string& html_data, |
56 const base::string16& title) | 81 const base::string16& title) |
57 : plugins::PluginPlaceholder(render_view, | 82 : plugins::PluginPlaceholder(render_view, |
58 render_frame, | 83 render_frame, |
59 frame, | 84 frame, |
60 params, | 85 params, |
61 html_data, | 86 html_data, |
62 GURL(kPluginPlaceholderDataURL)), | 87 GURL(kPluginPlaceholderDataURL)), |
63 status_(new ChromeViewHostMsg_GetPluginInfo_Status), | 88 status_(new ChromeViewHostMsg_GetPluginInfo_Status), |
64 title_(title), | 89 title_(title), |
65 #if defined(ENABLE_PLUGIN_INSTALLATION) | 90 #if defined(ENABLE_PLUGIN_INSTALLATION) |
66 placeholder_routing_id_(MSG_ROUTING_NONE), | 91 placeholder_routing_id_(MSG_ROUTING_NONE), |
67 #endif | 92 #endif |
68 has_host_(false), | 93 has_host_(false), |
69 context_menu_request_id_(0) { | 94 context_menu_request_id_(0) { |
70 RenderThread::Get()->AddObserver(this); | 95 RenderThread::Get()->AddObserver(this); |
96 | |
97 frame_observer_.reset(new RenderFrameObserver(this)); | |
71 } | 98 } |
72 | 99 |
73 ChromePluginPlaceholder::~ChromePluginPlaceholder() { | 100 ChromePluginPlaceholder::~ChromePluginPlaceholder() { |
74 RenderThread::Get()->RemoveObserver(this); | 101 RenderThread::Get()->RemoveObserver(this); |
75 if (context_menu_request_id_) | 102 if (context_menu_request_id_) |
76 render_view()->CancelContextMenu(context_menu_request_id_); | 103 render_view()->CancelContextMenu(context_menu_request_id_); |
77 | 104 |
78 #if defined(ENABLE_PLUGIN_INSTALLATION) | 105 #if defined(ENABLE_PLUGIN_INSTALLATION) |
79 if (placeholder_routing_id_ == MSG_ROUTING_NONE) | 106 if (placeholder_routing_id_ == MSG_ROUTING_NONE) |
80 return; | 107 return; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
206 IPC_END_MESSAGE_MAP() | 233 IPC_END_MESSAGE_MAP() |
207 | 234 |
208 if (handled) | 235 if (handled) |
209 return true; | 236 return true; |
210 #endif | 237 #endif |
211 | 238 |
212 // We don't swallow these messages because multiple blocked plugins have an | 239 // We don't swallow these messages because multiple blocked plugins have an |
213 // interest in them. | 240 // interest in them. |
214 IPC_BEGIN_MESSAGE_MAP(ChromePluginPlaceholder, message) | 241 IPC_BEGIN_MESSAGE_MAP(ChromePluginPlaceholder, message) |
215 IPC_MESSAGE_HANDLER(ChromeViewMsg_LoadBlockedPlugins, OnLoadBlockedPlugins) | 242 IPC_MESSAGE_HANDLER(ChromeViewMsg_LoadBlockedPlugins, OnLoadBlockedPlugins) |
216 IPC_MESSAGE_HANDLER(PrerenderMsg_SetIsPrerendering, OnSetIsPrerendering) | |
217 IPC_END_MESSAGE_MAP() | 243 IPC_END_MESSAGE_MAP() |
218 | 244 |
219 return false; | 245 return false; |
220 } | 246 } |
221 | 247 |
222 void ChromePluginPlaceholder::OnLoadBlockedPlugins( | 248 void ChromePluginPlaceholder::OnLoadBlockedPlugins( |
223 const std::string& identifier) { | 249 const std::string& identifier) { |
224 plugins::PluginPlaceholder::OnLoadBlockedPlugins(identifier); | 250 plugins::PluginPlaceholder::OnLoadBlockedPlugins(identifier); |
225 } | 251 } |
226 | 252 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
358 context_menu_request_id_ = render_view()->ShowContextMenu(this, params); | 384 context_menu_request_id_ = render_view()->ShowContextMenu(this, params); |
359 g_last_active_menu = this; | 385 g_last_active_menu = this; |
360 } | 386 } |
361 | 387 |
362 void ChromePluginPlaceholder::BindWebFrame(blink::WebFrame* frame) { | 388 void ChromePluginPlaceholder::BindWebFrame(blink::WebFrame* frame) { |
363 plugins::PluginPlaceholder::BindWebFrame(frame); | 389 plugins::PluginPlaceholder::BindWebFrame(frame); |
364 BindCallback("openAboutPlugins", | 390 BindCallback("openAboutPlugins", |
365 base::Bind(&ChromePluginPlaceholder::OpenAboutPluginsCallback, | 391 base::Bind(&ChromePluginPlaceholder::OpenAboutPluginsCallback, |
366 base::Unretained(this))); | 392 base::Unretained(this))); |
367 } | 393 } |
OLD | NEW |