Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/debug/crash_logging.h" | 11 #include "base/debug/crash_logging.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "content/public/renderer/content_renderer_client.h" | 13 #include "content/public/renderer/content_renderer_client.h" |
| 14 #include "content/renderer/pepper/message_channel.h" | 14 #include "content/renderer/pepper/message_channel.h" |
| 15 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 15 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 16 #include "content/renderer/pepper/plugin_instance_throttler_impl.h" | 16 #include "content/renderer/pepper/plugin_instance_throttler_impl.h" |
| 17 #include "content/renderer/pepper/plugin_module.h" | 17 #include "content/renderer/pepper/plugin_module.h" |
| 18 #include "content/renderer/pepper/v8object_var.h" | 18 #include "content/renderer/pepper/v8object_var.h" |
| 19 #include "content/renderer/render_frame_impl.h" | 19 #include "content/renderer/render_frame_impl.h" |
| 20 #include "ppapi/shared_impl/ppapi_globals.h" | 20 #include "ppapi/shared_impl/ppapi_globals.h" |
| 21 #include "ppapi/shared_impl/var_tracker.h" | 21 #include "ppapi/shared_impl/var_tracker.h" |
| 22 #include "third_party/WebKit/public/platform/WebPoint.h" | 22 #include "third_party/WebKit/public/platform/WebPoint.h" |
| 23 #include "third_party/WebKit/public/platform/WebRect.h" | 23 #include "third_party/WebKit/public/platform/WebRect.h" |
| 24 #include "third_party/WebKit/public/platform/WebSize.h" | 24 #include "third_party/WebKit/public/platform/WebSize.h" |
| 25 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" | 25 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" |
| 26 #include "third_party/WebKit/public/web/WebBindings.h" | |
| 27 #include "third_party/WebKit/public/web/WebDocument.h" | 26 #include "third_party/WebKit/public/web/WebDocument.h" |
| 28 #include "third_party/WebKit/public/web/WebElement.h" | 27 #include "third_party/WebKit/public/web/WebElement.h" |
| 29 #include "third_party/WebKit/public/web/WebFrame.h" | 28 #include "third_party/WebKit/public/web/WebFrame.h" |
| 30 #include "third_party/WebKit/public/web/WebPluginContainer.h" | 29 #include "third_party/WebKit/public/web/WebPluginContainer.h" |
| 31 #include "third_party/WebKit/public/web/WebPluginParams.h" | 30 #include "third_party/WebKit/public/web/WebPluginParams.h" |
| 32 #include "third_party/WebKit/public/web/WebPrintParams.h" | 31 #include "third_party/WebKit/public/web/WebPrintParams.h" |
| 33 #include "third_party/WebKit/public/web/WebPrintPresetOptions.h" | 32 #include "third_party/WebKit/public/web/WebPrintPresetOptions.h" |
| 34 #include "third_party/WebKit/public/web/WebPrintScalingOption.h" | 33 #include "third_party/WebKit/public/web/WebPrintScalingOption.h" |
| 35 #include "url/gurl.h" | 34 #include "url/gurl.h" |
| 36 | 35 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 return container_; | 89 return container_; |
| 91 } | 90 } |
| 92 | 91 |
| 93 bool PepperWebPluginImpl::initialize(WebPluginContainer* container) { | 92 bool PepperWebPluginImpl::initialize(WebPluginContainer* container) { |
| 94 // The plugin delegate may have gone away. | 93 // The plugin delegate may have gone away. |
| 95 instance_ = init_data_->module->CreateInstance( | 94 instance_ = init_data_->module->CreateInstance( |
| 96 init_data_->render_frame, container, init_data_->url); | 95 init_data_->render_frame, container, init_data_->url); |
| 97 if (!instance_.get()) | 96 if (!instance_.get()) |
| 98 return false; | 97 return false; |
| 99 | 98 |
| 100 // Enable script objects for this plugin. | |
| 101 container->allowScriptObjects(); | |
|
Wez
2016/01/14 21:57:08
We should also remove pp::deprecated::ScriptableOb
dcheng
2016/01/14 22:05:50
I thought Flash used it. I could be wrong.
| |
| 102 | |
| 103 auto weak_this = weak_factory_.GetWeakPtr(); | 99 auto weak_this = weak_factory_.GetWeakPtr(); |
| 104 bool success = | 100 bool success = |
| 105 instance_->Initialize(init_data_->arg_names, init_data_->arg_values, | 101 instance_->Initialize(init_data_->arg_names, init_data_->arg_values, |
| 106 full_frame_, std::move(throttler_)); | 102 full_frame_, std::move(throttler_)); |
| 107 // The above call to Initialize can result in re-entrancy and destruction of | 103 // The above call to Initialize can result in re-entrancy and destruction of |
| 108 // the plugin instance. In this case it's quite unclear whether this object | 104 // the plugin instance. In this case it's quite unclear whether this object |
| 109 // could also have been destroyed. We could return false here, but it would be | 105 // could also have been destroyed. We could return false here, but it would be |
| 110 // better if this object was guaranteed to outlast the recursive call. | 106 // better if this object was guaranteed to outlast the recursive call. |
| 111 // Otherwise, the caller of this function would also have to take care that, | 107 // Otherwise, the caller of this function would also have to take care that, |
| 112 // in the case of the object being deleted, we never access it again, and we | 108 // in the case of the object being deleted, we never access it again, and we |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 143 return true; | 139 return true; |
| 144 } | 140 } |
| 145 | 141 |
| 146 init_data_.reset(); | 142 init_data_.reset(); |
| 147 CHECK(container->plugin() == this); | 143 CHECK(container->plugin() == this); |
| 148 container_ = container; | 144 container_ = container; |
| 149 return true; | 145 return true; |
| 150 } | 146 } |
| 151 | 147 |
| 152 void PepperWebPluginImpl::destroy() { | 148 void PepperWebPluginImpl::destroy() { |
| 153 // Tell |container_| to clear references to this plugin's script objects. | |
| 154 if (container_) | |
| 155 container_->clearScriptObjects(); | |
| 156 | |
| 157 container_ = nullptr; | |
| 158 | |
| 159 if (instance_.get()) { | 149 if (instance_.get()) { |
| 160 ppapi::PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(instance_object_); | 150 ppapi::PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(instance_object_); |
| 161 instance_object_ = PP_MakeUndefined(); | 151 instance_object_ = PP_MakeUndefined(); |
| 162 instance_->Delete(); | 152 instance_->Delete(); |
| 163 instance_ = NULL; | 153 instance_ = NULL; |
| 164 } | 154 } |
| 165 | 155 |
| 166 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 156 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 167 } | 157 } |
| 168 | 158 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 314 | 304 |
| 315 bool PepperWebPluginImpl::canRotateView() { return instance_->CanRotateView(); } | 305 bool PepperWebPluginImpl::canRotateView() { return instance_->CanRotateView(); } |
| 316 | 306 |
| 317 void PepperWebPluginImpl::rotateView(RotationType type) { | 307 void PepperWebPluginImpl::rotateView(RotationType type) { |
| 318 instance_->RotateView(type); | 308 instance_->RotateView(type); |
| 319 } | 309 } |
| 320 | 310 |
| 321 bool PepperWebPluginImpl::isPlaceholder() { return false; } | 311 bool PepperWebPluginImpl::isPlaceholder() { return false; } |
| 322 | 312 |
| 323 } // namespace content | 313 } // namespace content |
| OLD | NEW |