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) { |
66 RenderThread::Get()->AddObserver(this); | 64 RenderThread::Get()->AddObserver(this); |
| 65 RegisterCallback("openAboutPlugins"); |
67 } | 66 } |
68 | 67 |
69 ChromePluginPlaceholder::~ChromePluginPlaceholder() { | 68 ChromePluginPlaceholder::~ChromePluginPlaceholder() { |
70 RenderThread::Get()->RemoveObserver(this); | 69 RenderThread::Get()->RemoveObserver(this); |
71 if (context_menu_request_id_) | 70 if (context_menu_request_id_) |
72 render_view()->CancelContextMenu(context_menu_request_id_); | 71 render_view()->CancelContextMenu(context_menu_request_id_); |
73 | 72 |
74 #if defined(ENABLE_PLUGIN_INSTALLATION) | 73 #if defined(ENABLE_PLUGIN_INSTALLATION) |
75 if (placeholder_routing_id_ == MSG_ROUTING_NONE) | 74 if (placeholder_routing_id_ == MSG_ROUTING_NONE) |
76 return; | 75 return; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 IPC_END_MESSAGE_MAP() | 209 IPC_END_MESSAGE_MAP() |
211 | 210 |
212 return false; | 211 return false; |
213 } | 212 } |
214 | 213 |
215 void ChromePluginPlaceholder::OnLoadBlockedPlugins( | 214 void ChromePluginPlaceholder::OnLoadBlockedPlugins( |
216 const std::string& identifier) { | 215 const std::string& identifier) { |
217 plugins::PluginPlaceholder::OnLoadBlockedPlugins(identifier); | 216 plugins::PluginPlaceholder::OnLoadBlockedPlugins(identifier); |
218 } | 217 } |
219 | 218 |
220 void ChromePluginPlaceholder::OpenAboutPluginsCallback( | |
221 const CppArgumentList& args, | |
222 CppVariant* result) { | |
223 RenderThread::Get()->Send( | |
224 new ChromeViewHostMsg_OpenAboutPlugins(routing_id())); | |
225 } | |
226 | |
227 void ChromePluginPlaceholder::OnSetIsPrerendering(bool is_prerendering) { | 219 void ChromePluginPlaceholder::OnSetIsPrerendering(bool is_prerendering) { |
228 plugins::PluginPlaceholder::OnSetIsPrerendering(is_prerendering); | 220 plugins::PluginPlaceholder::OnSetIsPrerendering(is_prerendering); |
229 } | 221 } |
230 | 222 |
231 #if defined(ENABLE_PLUGIN_INSTALLATION) | 223 #if defined(ENABLE_PLUGIN_INSTALLATION) |
232 void ChromePluginPlaceholder::OnDidNotFindMissingPlugin() { | 224 void ChromePluginPlaceholder::OnDidNotFindMissingPlugin() { |
233 SetMessage(l10n_util::GetStringUTF16(IDS_PLUGIN_NOT_FOUND)); | 225 SetMessage(l10n_util::GetStringUTF16(IDS_PLUGIN_NOT_FOUND)); |
234 } | 226 } |
235 | 227 |
236 void ChromePluginPlaceholder::OnFoundMissingPlugin( | 228 void ChromePluginPlaceholder::OnFoundMissingPlugin( |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 hide_item.label = l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLUGIN_HIDE); | 337 hide_item.label = l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLUGIN_HIDE); |
346 params.custom_items.push_back(hide_item); | 338 params.custom_items.push_back(hide_item); |
347 | 339 |
348 params.x = event.windowX; | 340 params.x = event.windowX; |
349 params.y = event.windowY; | 341 params.y = event.windowY; |
350 | 342 |
351 context_menu_request_id_ = render_view()->ShowContextMenu(this, params); | 343 context_menu_request_id_ = render_view()->ShowContextMenu(this, params); |
352 g_last_active_menu = this; | 344 g_last_active_menu = this; |
353 } | 345 } |
354 | 346 |
355 void ChromePluginPlaceholder::BindWebFrame(blink::WebFrame* frame) { | 347 void ChromePluginPlaceholder::Observe(const std::string& callback) { |
356 plugins::PluginPlaceholder::BindWebFrame(frame); | 348 DCHECK_EQ("openAboutPlugins", callback); |
357 BindCallback("openAboutPlugins", | 349 RenderThread::Get()->Send( |
358 base::Bind(&ChromePluginPlaceholder::OpenAboutPluginsCallback, | 350 new ChromeViewHostMsg_OpenAboutPlugins(routing_id())); |
359 base::Unretained(this))); | |
360 } | 351 } |
OLD | NEW |