OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/pepper/pepper_webplugin_impl.h" | 5 #include "content/renderer/pepper/pepper_webplugin_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/debug/crash_logging.h" | 9 #include "base/debug/crash_logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "content/public/common/page_zoom.h" | 11 #include "content/public/common/page_zoom.h" |
12 #include "content/public/renderer/content_renderer_client.h" | 12 #include "content/public/renderer/content_renderer_client.h" |
13 #include "content/renderer/pepper/message_channel.h" | 13 #include "content/renderer/pepper/message_channel.h" |
14 #include "content/renderer/pepper/npobject_var.h" | |
15 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 14 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
16 #include "content/renderer/pepper/plugin_module.h" | 15 #include "content/renderer/pepper/plugin_module.h" |
| 16 #include "content/renderer/pepper/v8object_var.h" |
17 #include "content/renderer/render_frame_impl.h" | 17 #include "content/renderer/render_frame_impl.h" |
18 #include "ppapi/shared_impl/ppapi_globals.h" | 18 #include "ppapi/shared_impl/ppapi_globals.h" |
19 #include "ppapi/shared_impl/var_tracker.h" | 19 #include "ppapi/shared_impl/var_tracker.h" |
20 #include "third_party/WebKit/public/platform/WebPoint.h" | 20 #include "third_party/WebKit/public/platform/WebPoint.h" |
21 #include "third_party/WebKit/public/platform/WebRect.h" | 21 #include "third_party/WebKit/public/platform/WebRect.h" |
22 #include "third_party/WebKit/public/platform/WebSize.h" | 22 #include "third_party/WebKit/public/platform/WebSize.h" |
23 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" | 23 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" |
24 #include "third_party/WebKit/public/web/WebBindings.h" | 24 #include "third_party/WebKit/public/web/WebBindings.h" |
25 #include "third_party/WebKit/public/web/WebDocument.h" | 25 #include "third_party/WebKit/public/web/WebDocument.h" |
26 #include "third_party/WebKit/public/web/WebElement.h" | 26 #include "third_party/WebKit/public/web/WebElement.h" |
27 #include "third_party/WebKit/public/web/WebFrame.h" | 27 #include "third_party/WebKit/public/web/WebFrame.h" |
28 #include "third_party/WebKit/public/web/WebPluginContainer.h" | 28 #include "third_party/WebKit/public/web/WebPluginContainer.h" |
29 #include "third_party/WebKit/public/web/WebPluginParams.h" | 29 #include "third_party/WebKit/public/web/WebPluginParams.h" |
30 #include "third_party/WebKit/public/web/WebPrintParams.h" | 30 #include "third_party/WebKit/public/web/WebPrintParams.h" |
31 #include "third_party/WebKit/public/web/WebPrintScalingOption.h" | 31 #include "third_party/WebKit/public/web/WebPrintScalingOption.h" |
32 #include "url/gurl.h" | 32 #include "url/gurl.h" |
33 | 33 |
34 using ppapi::NPObjectVar; | 34 using ppapi::V8ObjectVar; |
35 using blink::WebCanvas; | 35 using blink::WebCanvas; |
36 using blink::WebPlugin; | 36 using blink::WebPlugin; |
37 using blink::WebPluginContainer; | 37 using blink::WebPluginContainer; |
38 using blink::WebPluginParams; | 38 using blink::WebPluginParams; |
39 using blink::WebPoint; | 39 using blink::WebPoint; |
40 using blink::WebPrintParams; | 40 using blink::WebPrintParams; |
41 using blink::WebRect; | 41 using blink::WebRect; |
42 using blink::WebSize; | 42 using blink::WebSize; |
43 using blink::WebString; | 43 using blink::WebString; |
44 using blink::WebURL; | 44 using blink::WebURL; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 if (instance_.get()) { | 119 if (instance_.get()) { |
120 ppapi::PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(instance_object_); | 120 ppapi::PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(instance_object_); |
121 instance_object_ = PP_MakeUndefined(); | 121 instance_object_ = PP_MakeUndefined(); |
122 instance_->Delete(); | 122 instance_->Delete(); |
123 instance_ = NULL; | 123 instance_ = NULL; |
124 } | 124 } |
125 | 125 |
126 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 126 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
127 } | 127 } |
128 | 128 |
129 NPObject* PepperWebPluginImpl::scriptableObject() { | 129 bool PepperWebPluginImpl::getScriptableObject(v8::Isolate* isolate, |
| 130 v8::Local<v8::Object>* object) { |
130 // Call through the plugin to get its instance object. The plugin should pass | 131 // Call through the plugin to get its instance object. The plugin should pass |
131 // us a reference which we release in destroy(). | 132 // us a reference which we release in destroy(). |
132 if (instance_object_.type == PP_VARTYPE_UNDEFINED) | 133 if (instance_object_.type == PP_VARTYPE_UNDEFINED) |
133 instance_object_ = instance_->GetInstanceObject(); | 134 instance_object_ = instance_->GetInstanceObject(isolate); |
134 // GetInstanceObject talked to the plugin which may have removed the instance | 135 // GetInstanceObject talked to the plugin which may have removed the instance |
135 // from the DOM, in which case instance_ would be NULL now. | 136 // from the DOM, in which case instance_ would be NULL now. |
136 if (!instance_.get()) | 137 if (!instance_.get()) |
137 return NULL; | 138 return false; |
138 | 139 |
139 scoped_refptr<NPObjectVar> object(NPObjectVar::FromPPVar(instance_object_)); | 140 scoped_refptr<V8ObjectVar> object_var( |
| 141 V8ObjectVar::FromPPVar(instance_object_)); |
140 // If there's an InstanceObject, tell the Instance's MessageChannel to pass | 142 // If there's an InstanceObject, tell the Instance's MessageChannel to pass |
141 // any non-postMessage calls to it. | 143 // any non-postMessage calls to it. |
142 if (object.get()) { | 144 if (object_var.get()) { |
143 instance_->message_channel().SetPassthroughObject(object->np_object()); | 145 instance_->GetMessageChannel()->SetPassthroughObject( |
| 146 object_var->GetHandle()); |
144 } | 147 } |
145 NPObject* message_channel_np_object(instance_->message_channel().np_object()); | 148 v8::Handle<v8::Object> result = instance_->GetMessageChannelObject(); |
146 // The object is expected to be retained before it is returned. | 149 if (result.IsEmpty()) |
147 blink::WebBindings::retainObject(message_channel_np_object); | 150 return false; |
148 return message_channel_np_object; | 151 *object = result; |
| 152 return true; |
149 } | 153 } |
150 | 154 |
151 NPP PepperWebPluginImpl::pluginNPP() { return instance_->instanceNPP(); } | |
152 | |
153 bool PepperWebPluginImpl::getFormValue(WebString& value) { return false; } | 155 bool PepperWebPluginImpl::getFormValue(WebString& value) { return false; } |
154 | 156 |
155 void PepperWebPluginImpl::paint(WebCanvas* canvas, const WebRect& rect) { | 157 void PepperWebPluginImpl::paint(WebCanvas* canvas, const WebRect& rect) { |
156 if (!instance_->FlashIsFullscreenOrPending()) | 158 if (!instance_->FlashIsFullscreenOrPending()) |
157 instance_->Paint(canvas, plugin_rect_, rect); | 159 instance_->Paint(canvas, plugin_rect_, rect); |
158 } | 160 } |
159 | 161 |
160 void PepperWebPluginImpl::updateGeometry( | 162 void PepperWebPluginImpl::updateGeometry( |
161 const WebRect& window_rect, | 163 const WebRect& window_rect, |
162 const WebRect& clip_rect, | 164 const WebRect& clip_rect, |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 | 273 |
272 bool PepperWebPluginImpl::canRotateView() { return instance_->CanRotateView(); } | 274 bool PepperWebPluginImpl::canRotateView() { return instance_->CanRotateView(); } |
273 | 275 |
274 void PepperWebPluginImpl::rotateView(RotationType type) { | 276 void PepperWebPluginImpl::rotateView(RotationType type) { |
275 instance_->RotateView(type); | 277 instance_->RotateView(type); |
276 } | 278 } |
277 | 279 |
278 bool PepperWebPluginImpl::isPlaceholder() { return false; } | 280 bool PepperWebPluginImpl::isPlaceholder() { return false; } |
279 | 281 |
280 } // namespace content | 282 } // namespace content |
OLD | NEW |