Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: chrome/renderer/plugins/chrome_plugin_placeholder.cc

Issue 116163008: Move the plugin placeholder from CppBoundClass to gin::Wrappable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // static
50 gin::WrapperInfo ChromePluginPlaceholder::kWrapperInfo = {
51 gin::kEmbedderNativeGin};
52
53 // static
54 v8::Local<v8::ObjectTemplate> ChromePluginPlaceholder::GetObjectTemplate(
55 v8::Isolate* isolate) {
56 return GetObjectTemplateBuilder(isolate)
57 .SetMethod("openAboutPlugins",
58 &ChromePluginPlaceholder::OpenAboutPluginsCallback)
59 .Build();
60 }
61
49 ChromePluginPlaceholder::ChromePluginPlaceholder( 62 ChromePluginPlaceholder::ChromePluginPlaceholder(
50 content::RenderFrame* render_frame, 63 content::RenderFrame* render_frame,
51 blink::WebFrame* frame, 64 blink::WebFrame* frame,
52 const blink::WebPluginParams& params, 65 const blink::WebPluginParams& params,
53 const std::string& html_data, 66 const std::string& html_data,
54 const base::string16& title) 67 const base::string16& title)
55 : plugins::PluginPlaceholder(render_frame, 68 : plugins::PluginPlaceholder(render_frame,
56 frame, 69 frame,
57 params, 70 params,
58 html_data, 71 html_data,
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 IPC_END_MESSAGE_MAP() 224 IPC_END_MESSAGE_MAP()
212 225
213 return false; 226 return false;
214 } 227 }
215 228
216 void ChromePluginPlaceholder::OnLoadBlockedPlugins( 229 void ChromePluginPlaceholder::OnLoadBlockedPlugins(
217 const std::string& identifier) { 230 const std::string& identifier) {
218 plugins::PluginPlaceholder::OnLoadBlockedPlugins(identifier); 231 plugins::PluginPlaceholder::OnLoadBlockedPlugins(identifier);
219 } 232 }
220 233
221 void ChromePluginPlaceholder::OpenAboutPluginsCallback( 234 void ChromePluginPlaceholder::OpenAboutPluginsCallback() {
222 const CppArgumentList& args,
223 CppVariant* result) {
224 RenderThread::Get()->Send( 235 RenderThread::Get()->Send(
225 new ChromeViewHostMsg_OpenAboutPlugins(routing_id())); 236 new ChromeViewHostMsg_OpenAboutPlugins(routing_id()));
226 } 237 }
227 238
228 void ChromePluginPlaceholder::OnSetIsPrerendering(bool is_prerendering) { 239 void ChromePluginPlaceholder::OnSetIsPrerendering(bool is_prerendering) {
229 plugins::PluginPlaceholder::OnSetIsPrerendering(is_prerendering); 240 plugins::PluginPlaceholder::OnSetIsPrerendering(is_prerendering);
230 } 241 }
231 242
232 #if defined(ENABLE_PLUGIN_INSTALLATION) 243 #if defined(ENABLE_PLUGIN_INSTALLATION)
233 void ChromePluginPlaceholder::OnDidNotFindMissingPlugin() { 244 void ChromePluginPlaceholder::OnDidNotFindMissingPlugin() {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 params.custom_items.push_back(hide_item); 358 params.custom_items.push_back(hide_item);
348 359
349 params.x = event.windowX; 360 params.x = event.windowX;
350 params.y = event.windowY; 361 params.y = event.windowY;
351 362
352 context_menu_request_id_ = render_frame()->ShowContextMenu(this, params); 363 context_menu_request_id_ = render_frame()->ShowContextMenu(this, params);
353 g_last_active_menu = this; 364 g_last_active_menu = this;
354 } 365 }
355 366
356 void ChromePluginPlaceholder::BindWebFrame(blink::WebFrame* frame) { 367 void ChromePluginPlaceholder::BindWebFrame(blink::WebFrame* frame) {
357 plugins::PluginPlaceholder::BindWebFrame(frame); 368 v8::Isolate* isolate = blink::mainThreadIsolate();
358 BindCallback("openAboutPlugins", 369 v8::HandleScope handle_scope(isolate);
359 base::Bind(&ChromePluginPlaceholder::OpenAboutPluginsCallback, 370 v8::Handle<v8::Context> context = frame->mainWorldScriptContext();
360 base::Unretained(this))); 371 DCHECK(!context.IsEmpty());
372
373 v8::Context::Scope context_scope(context);
374 v8::Handle<v8::Object> global = context->Global();
375 global->Set(gin::StringToV8(isolate, "plugin"),
376 gin::CreateHandle(isolate, this).ToV8());
361 } 377 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698