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

Side by Side Diff: components/plugins/renderer/plugin_placeholder.cc

Issue 1148223004: Plugin Placeholders: Factor out common BindWebFrame method into base class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months 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
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 "components/plugins/renderer/plugin_placeholder.h" 5 #include "components/plugins/renderer/plugin_placeholder.h"
6 6
7 #include "content/public/renderer/render_frame.h" 7 #include "content/public/renderer/render_frame.h"
8 #include "gin/handle.h"
9 #include "third_party/WebKit/public/web/WebKit.h"
8 10
9 namespace plugins { 11 namespace plugins {
10 12
11 gin::WrapperInfo PluginPlaceholder::kWrapperInfo = {gin::kEmbedderNativeGin}; 13 gin::WrapperInfo PluginPlaceholder::kWrapperInfo = {gin::kEmbedderNativeGin};
12 14
13 PluginPlaceholder::PluginPlaceholder(content::RenderFrame* render_frame, 15 PluginPlaceholder::PluginPlaceholder(content::RenderFrame* render_frame,
14 blink::WebLocalFrame* frame, 16 blink::WebLocalFrame* frame,
15 const blink::WebPluginParams& params, 17 const blink::WebPluginParams& params,
16 const std::string& html_data, 18 const std::string& html_data,
17 GURL placeholderDataUrl) 19 GURL placeholderDataUrl)
18 : content::RenderFrameObserver(render_frame), 20 : content::RenderFrameObserver(render_frame),
19 frame_(frame), 21 frame_(frame),
20 plugin_params_(params), 22 plugin_params_(params),
21 plugin_(WebViewPlugin::Create(this, 23 plugin_(WebViewPlugin::Create(this,
22 render_frame->GetWebkitPreferences(), 24 render_frame->GetWebkitPreferences(),
23 html_data, 25 html_data,
24 placeholderDataUrl)) { 26 placeholderDataUrl)) {
25 DCHECK(placeholderDataUrl.is_valid()) 27 DCHECK(placeholderDataUrl.is_valid())
26 << "Blink requires the placeholder to have a valid URL."; 28 << "Blink requires the placeholder to have a valid URL.";
27 } 29 }
28 30
29 PluginPlaceholder::~PluginPlaceholder() {} 31 PluginPlaceholder::~PluginPlaceholder() {}
30 32
31 const blink::WebPluginParams& PluginPlaceholder::GetPluginParams() const { 33 const blink::WebPluginParams& PluginPlaceholder::GetPluginParams() const {
32 return plugin_params_; 34 return plugin_params_;
33 } 35 }
34 36
37 void PluginPlaceholder::BindWebFrame(blink::WebFrame* frame) {
38 v8::Isolate* isolate = blink::mainThreadIsolate();
39 v8::HandleScope handle_scope(isolate);
40 v8::Local<v8::Context> context = frame->mainWorldScriptContext();
41 DCHECK(!context.IsEmpty());
42
43 v8::Context::Scope context_scope(context);
44 v8::Local<v8::Object> global = context->Global();
45 global->Set(gin::StringToV8(isolate, "plugin"),
46 gin::CreateHandle(isolate, this).ToV8());
47 }
48
35 void PluginPlaceholder::ShowContextMenu(const blink::WebMouseEvent& event) { 49 void PluginPlaceholder::ShowContextMenu(const blink::WebMouseEvent& event) {
36 // Does nothing by default. Will be overridden if a specific browser wants 50 // Does nothing by default. Will be overridden if a specific browser wants
37 // a context menu. 51 // a context menu.
38 return; 52 return;
39 } 53 }
40 54
41 void PluginPlaceholder::PluginDestroyed() { 55 void PluginPlaceholder::PluginDestroyed() {
42 plugin_ = NULL; 56 plugin_ = NULL;
43 } 57 }
44 58
45 v8::Local<v8::Object> PluginPlaceholder::GetV8ScriptableObject( 59 v8::Local<v8::Object> PluginPlaceholder::GetV8ScriptableObject(
46 v8::Isolate* isolate) const { 60 v8::Isolate* isolate) const {
47 return v8::Local<v8::Object>(); 61 return v8::Local<v8::Object>();
48 } 62 }
49 63
50 void PluginPlaceholder::OnDestruct() { 64 void PluginPlaceholder::OnDestruct() {
51 frame_ = NULL; 65 frame_ = NULL;
52 } 66 }
53 67
54 blink::WebLocalFrame* PluginPlaceholder::GetFrame() { return frame_; } 68 blink::WebLocalFrame* PluginPlaceholder::GetFrame() { return frame_; }
55 69
56 } // namespace plugins 70 } // namespace plugins
OLDNEW
« no previous file with comments | « components/plugins/renderer/plugin_placeholder.h ('k') | components/plugins/renderer/webview_plugin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698