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 "gin/object_template_builder.h" |
17 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
18 #include "grit/renderer_resources.h" | 19 #include "grit/renderer_resources.h" |
19 #include "grit/webkit_strings.h" | 20 #include "grit/webkit_strings.h" |
20 #include "third_party/WebKit/public/web/WebDocument.h" | 21 #include "third_party/WebKit/public/web/WebDocument.h" |
21 #include "third_party/WebKit/public/web/WebFrame.h" | 22 #include "third_party/WebKit/public/web/WebFrame.h" |
22 #include "third_party/WebKit/public/web/WebInputEvent.h" | 23 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 24 #include "third_party/WebKit/public/web/WebKit.h" |
23 #include "third_party/WebKit/public/web/WebScriptSource.h" | 25 #include "third_party/WebKit/public/web/WebScriptSource.h" |
24 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
25 #include "ui/base/resource/resource_bundle.h" | 27 #include "ui/base/resource/resource_bundle.h" |
26 #include "ui/base/webui/jstemplate_builder.h" | 28 #include "ui/base/webui/jstemplate_builder.h" |
27 | 29 |
28 using content::RenderThread; | 30 using content::RenderThread; |
29 using content::RenderView; | 31 using content::RenderView; |
30 using content::UserMetricsAction; | 32 using content::UserMetricsAction; |
31 using blink::WebDocument; | 33 using blink::WebDocument; |
32 using blink::WebElement; | 34 using blink::WebElement; |
33 using blink::WebFrame; | 35 using blink::WebFrame; |
34 using blink::WebMouseEvent; | 36 using blink::WebMouseEvent; |
35 using blink::WebNode; | 37 using blink::WebNode; |
36 using blink::WebPlugin; | 38 using blink::WebPlugin; |
37 using blink::WebPluginContainer; | 39 using blink::WebPluginContainer; |
38 using blink::WebPluginParams; | 40 using blink::WebPluginParams; |
39 using webkit_glue::CppArgumentList; | |
40 using webkit_glue::CppVariant; | |
41 | 41 |
42 namespace { | 42 namespace { |
43 const plugins::PluginPlaceholder* g_last_active_menu = NULL; | 43 const plugins::PluginPlaceholder* g_last_active_menu = NULL; |
44 } // namespace | 44 } // namespace |
45 | 45 |
46 const char ChromePluginPlaceholder::kPluginPlaceholderDataURL[] = | 46 const char ChromePluginPlaceholder::kPluginPlaceholderDataURL[] = |
47 "chrome://pluginplaceholderdata/"; | 47 "chrome://pluginplaceholderdata/"; |
48 | 48 |
| 49 gin::ObjectTemplateBuilder ChromePluginPlaceholder::GetObjectTemplateBuilder( |
| 50 v8::Isolate* isolate) { |
| 51 return plugins::PluginPlaceholder::GetObjectTemplateBuilder(isolate) |
| 52 .SetMethod("openAboutPlugins", |
| 53 &ChromePluginPlaceholder::OpenAboutPluginsCallback); |
| 54 } |
| 55 |
49 ChromePluginPlaceholder::ChromePluginPlaceholder( | 56 ChromePluginPlaceholder::ChromePluginPlaceholder( |
50 content::RenderFrame* render_frame, | 57 content::RenderFrame* render_frame, |
51 blink::WebFrame* frame, | 58 blink::WebFrame* frame, |
52 const blink::WebPluginParams& params, | 59 const blink::WebPluginParams& params, |
53 const std::string& html_data, | 60 const std::string& html_data, |
54 const base::string16& title) | 61 const base::string16& title) |
55 : plugins::PluginPlaceholder(render_frame, | 62 : plugins::PluginPlaceholder(render_frame, |
56 frame, | 63 frame, |
57 params, | 64 params, |
58 html_data, | 65 html_data, |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 IPC_END_MESSAGE_MAP() | 218 IPC_END_MESSAGE_MAP() |
212 | 219 |
213 return false; | 220 return false; |
214 } | 221 } |
215 | 222 |
216 void ChromePluginPlaceholder::OnLoadBlockedPlugins( | 223 void ChromePluginPlaceholder::OnLoadBlockedPlugins( |
217 const std::string& identifier) { | 224 const std::string& identifier) { |
218 plugins::PluginPlaceholder::OnLoadBlockedPlugins(identifier); | 225 plugins::PluginPlaceholder::OnLoadBlockedPlugins(identifier); |
219 } | 226 } |
220 | 227 |
221 void ChromePluginPlaceholder::OpenAboutPluginsCallback( | 228 void ChromePluginPlaceholder::OpenAboutPluginsCallback() { |
222 const CppArgumentList& args, | |
223 CppVariant* result) { | |
224 RenderThread::Get()->Send( | 229 RenderThread::Get()->Send( |
225 new ChromeViewHostMsg_OpenAboutPlugins(routing_id())); | 230 new ChromeViewHostMsg_OpenAboutPlugins(routing_id())); |
226 } | 231 } |
227 | 232 |
228 void ChromePluginPlaceholder::OnSetIsPrerendering(bool is_prerendering) { | 233 void ChromePluginPlaceholder::OnSetIsPrerendering(bool is_prerendering) { |
229 plugins::PluginPlaceholder::OnSetIsPrerendering(is_prerendering); | 234 plugins::PluginPlaceholder::OnSetIsPrerendering(is_prerendering); |
230 } | 235 } |
231 | 236 |
232 #if defined(ENABLE_PLUGIN_INSTALLATION) | 237 #if defined(ENABLE_PLUGIN_INSTALLATION) |
233 void ChromePluginPlaceholder::OnDidNotFindMissingPlugin() { | 238 void ChromePluginPlaceholder::OnDidNotFindMissingPlugin() { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 params.custom_items.push_back(hide_item); | 352 params.custom_items.push_back(hide_item); |
348 | 353 |
349 params.x = event.windowX; | 354 params.x = event.windowX; |
350 params.y = event.windowY; | 355 params.y = event.windowY; |
351 | 356 |
352 context_menu_request_id_ = render_frame()->ShowContextMenu(this, params); | 357 context_menu_request_id_ = render_frame()->ShowContextMenu(this, params); |
353 g_last_active_menu = this; | 358 g_last_active_menu = this; |
354 } | 359 } |
355 | 360 |
356 void ChromePluginPlaceholder::BindWebFrame(blink::WebFrame* frame) { | 361 void ChromePluginPlaceholder::BindWebFrame(blink::WebFrame* frame) { |
357 plugins::PluginPlaceholder::BindWebFrame(frame); | 362 v8::Isolate* isolate = blink::mainThreadIsolate(); |
358 BindCallback("openAboutPlugins", | 363 v8::HandleScope handle_scope(isolate); |
359 base::Bind(&ChromePluginPlaceholder::OpenAboutPluginsCallback, | 364 v8::Handle<v8::Context> context = frame->mainWorldScriptContext(); |
360 base::Unretained(this))); | 365 DCHECK(!context.IsEmpty()); |
| 366 |
| 367 v8::Context::Scope context_scope(context); |
| 368 v8::Handle<v8::Object> global = context->Global(); |
| 369 global->Set(gin::StringToV8(isolate, "plugin"), |
| 370 gin::CreateHandle(isolate, this).ToV8()); |
361 } | 371 } |
OLD | NEW |