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" |
(...skipping 17 matching lines...) Expand all Loading... |
28 using content::RenderThread; | 28 using content::RenderThread; |
29 using content::RenderView; | 29 using content::RenderView; |
30 using blink::WebDocument; | 30 using blink::WebDocument; |
31 using blink::WebElement; | 31 using blink::WebElement; |
32 using blink::WebFrame; | 32 using blink::WebFrame; |
33 using blink::WebMouseEvent; | 33 using blink::WebMouseEvent; |
34 using blink::WebNode; | 34 using blink::WebNode; |
35 using blink::WebPlugin; | 35 using blink::WebPlugin; |
36 using blink::WebPluginContainer; | 36 using blink::WebPluginContainer; |
37 using blink::WebPluginParams; | 37 using blink::WebPluginParams; |
38 using webkit_glue::CppArgumentList; | |
39 using webkit_glue::CppVariant; | |
40 | 38 |
41 namespace { | 39 namespace { |
42 const plugins::PluginPlaceholder* g_last_active_menu = NULL; | 40 const plugins::PluginPlaceholder* g_last_active_menu = NULL; |
43 } // namespace | 41 } // namespace |
44 | 42 |
45 const char ChromePluginPlaceholder::kPluginPlaceholderDataURL[] = | 43 const char ChromePluginPlaceholder::kPluginPlaceholderDataURL[] = |
46 "chrome://pluginplaceholderdata/"; | 44 "chrome://pluginplaceholderdata/"; |
47 | 45 |
48 ChromePluginPlaceholder::ChromePluginPlaceholder( | 46 ChromePluginPlaceholder::ChromePluginPlaceholder( |
49 content::RenderView* render_view, | 47 content::RenderView* render_view, |
50 blink::WebFrame* frame, | 48 blink::WebFrame* frame, |
51 const blink::WebPluginParams& params, | 49 const blink::WebPluginParams& params, |
52 const std::string& html_data, | 50 const std::string& html_data, |
53 const string16& title) | 51 const string16& title) |
54 : plugins::PluginPlaceholder(render_view, | 52 : plugins::PluginPlaceholder(render_view, |
55 frame, | 53 frame, |
56 params, | 54 params, |
57 html_data, | 55 html_data, |
58 GURL(kPluginPlaceholderDataURL)), | 56 GURL(kPluginPlaceholderDataURL)), |
59 status_(new ChromeViewHostMsg_GetPluginInfo_Status), | 57 status_(new ChromeViewHostMsg_GetPluginInfo_Status), |
60 title_(title), | 58 title_(title), |
61 #if defined(ENABLE_PLUGIN_INSTALLATION) | 59 #if defined(ENABLE_PLUGIN_INSTALLATION) |
62 placeholder_routing_id_(MSG_ROUTING_NONE), | 60 placeholder_routing_id_(MSG_ROUTING_NONE), |
63 #endif | 61 #endif |
64 has_host_(false), | 62 has_host_(false), |
65 context_menu_request_id_(0) { | 63 context_menu_request_id_(0), |
| 64 weak_factory_(this) { |
66 RenderThread::Get()->AddObserver(this); | 65 RenderThread::Get()->AddObserver(this); |
| 66 RegisterCallback( |
| 67 "openAboutPlugins", |
| 68 base::Bind(&ChromePluginPlaceholder::OpenAboutPluginsCallback, |
| 69 weak_factory_.GetWeakPtr())); |
67 } | 70 } |
68 | 71 |
69 ChromePluginPlaceholder::~ChromePluginPlaceholder() { | 72 ChromePluginPlaceholder::~ChromePluginPlaceholder() { |
70 RenderThread::Get()->RemoveObserver(this); | 73 RenderThread::Get()->RemoveObserver(this); |
71 if (context_menu_request_id_) | 74 if (context_menu_request_id_) |
72 render_view()->CancelContextMenu(context_menu_request_id_); | 75 render_view()->CancelContextMenu(context_menu_request_id_); |
73 | 76 |
74 #if defined(ENABLE_PLUGIN_INSTALLATION) | 77 #if defined(ENABLE_PLUGIN_INSTALLATION) |
75 if (placeholder_routing_id_ == MSG_ROUTING_NONE) | 78 if (placeholder_routing_id_ == MSG_ROUTING_NONE) |
76 return; | 79 return; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 IPC_END_MESSAGE_MAP() | 213 IPC_END_MESSAGE_MAP() |
211 | 214 |
212 return false; | 215 return false; |
213 } | 216 } |
214 | 217 |
215 void ChromePluginPlaceholder::OnLoadBlockedPlugins( | 218 void ChromePluginPlaceholder::OnLoadBlockedPlugins( |
216 const std::string& identifier) { | 219 const std::string& identifier) { |
217 plugins::PluginPlaceholder::OnLoadBlockedPlugins(identifier); | 220 plugins::PluginPlaceholder::OnLoadBlockedPlugins(identifier); |
218 } | 221 } |
219 | 222 |
220 void ChromePluginPlaceholder::OpenAboutPluginsCallback( | 223 void ChromePluginPlaceholder::OpenAboutPluginsCallback() { |
221 const CppArgumentList& args, | |
222 CppVariant* result) { | |
223 RenderThread::Get()->Send( | 224 RenderThread::Get()->Send( |
224 new ChromeViewHostMsg_OpenAboutPlugins(routing_id())); | 225 new ChromeViewHostMsg_OpenAboutPlugins(routing_id())); |
225 } | 226 } |
226 | 227 |
227 void ChromePluginPlaceholder::OnSetIsPrerendering(bool is_prerendering) { | 228 void ChromePluginPlaceholder::OnSetIsPrerendering(bool is_prerendering) { |
228 plugins::PluginPlaceholder::OnSetIsPrerendering(is_prerendering); | 229 plugins::PluginPlaceholder::OnSetIsPrerendering(is_prerendering); |
229 } | 230 } |
230 | 231 |
231 #if defined(ENABLE_PLUGIN_INSTALLATION) | 232 #if defined(ENABLE_PLUGIN_INSTALLATION) |
232 void ChromePluginPlaceholder::OnDidNotFindMissingPlugin() { | 233 void ChromePluginPlaceholder::OnDidNotFindMissingPlugin() { |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 hide_item.enabled = true; | 345 hide_item.enabled = true; |
345 hide_item.label = l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLUGIN_HIDE); | 346 hide_item.label = l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLUGIN_HIDE); |
346 params.custom_items.push_back(hide_item); | 347 params.custom_items.push_back(hide_item); |
347 | 348 |
348 params.x = event.windowX; | 349 params.x = event.windowX; |
349 params.y = event.windowY; | 350 params.y = event.windowY; |
350 | 351 |
351 context_menu_request_id_ = render_view()->ShowContextMenu(this, params); | 352 context_menu_request_id_ = render_view()->ShowContextMenu(this, params); |
352 g_last_active_menu = this; | 353 g_last_active_menu = this; |
353 } | 354 } |
354 | |
355 void ChromePluginPlaceholder::BindWebFrame(blink::WebFrame* frame) { | |
356 plugins::PluginPlaceholder::BindWebFrame(frame); | |
357 BindCallback("openAboutPlugins", | |
358 base::Bind(&ChromePluginPlaceholder::OpenAboutPluginsCallback, | |
359 base::Unretained(this))); | |
360 } | |
OLD | NEW |