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

Side by Side Diff: content/renderer/pepper/pepper_webplugin_impl.cc

Issue 1483733002: Remove support for NPObjects. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 8 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 (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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 return container_; 90 return container_;
92 } 91 }
93 92
94 bool PepperWebPluginImpl::initialize(WebPluginContainer* container) { 93 bool PepperWebPluginImpl::initialize(WebPluginContainer* container) {
95 // The plugin delegate may have gone away. 94 // The plugin delegate may have gone away.
96 instance_ = init_data_->module->CreateInstance( 95 instance_ = init_data_->module->CreateInstance(
97 init_data_->render_frame, container, init_data_->url); 96 init_data_->render_frame, container, init_data_->url);
98 if (!instance_.get()) 97 if (!instance_.get())
99 return false; 98 return false;
100 99
101 // Enable script objects for this plugin.
102 container->allowScriptObjects();
103
104 auto weak_this = weak_factory_.GetWeakPtr(); 100 auto weak_this = weak_factory_.GetWeakPtr();
105 bool success = 101 bool success =
106 instance_->Initialize(init_data_->arg_names, init_data_->arg_values, 102 instance_->Initialize(init_data_->arg_names, init_data_->arg_values,
107 full_frame_, std::move(throttler_)); 103 full_frame_, std::move(throttler_));
108 // The above call to Initialize can result in re-entrancy and destruction of 104 // The above call to Initialize can result in re-entrancy and destruction of
109 // the plugin instance. In this case it's quite unclear whether this object 105 // the plugin instance. In this case it's quite unclear whether this object
110 // could also have been destroyed. We could return false here, but it would be 106 // could also have been destroyed. We could return false here, but it would be
111 // better if this object was guaranteed to outlast the recursive call. 107 // better if this object was guaranteed to outlast the recursive call.
112 // Otherwise, the caller of this function would also have to take care that, 108 // Otherwise, the caller of this function would also have to take care that,
113 // in the case of the object being deleted, we never access it again, and we 109 // in the case of the object being deleted, we never access it again, and we
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 CHECK(container->plugin() == this); 144 CHECK(container->plugin() == this);
149 container_ = container; 145 container_ = container;
150 return true; 146 return true;
151 } 147 }
152 148
153 void PepperWebPluginImpl::destroy() { 149 void PepperWebPluginImpl::destroy() {
154 // TODO(tommycli): Remove once we fix https://crbug.com/588624. 150 // TODO(tommycli): Remove once we fix https://crbug.com/588624.
155 CHECK(!destroyed_); 151 CHECK(!destroyed_);
156 destroyed_ = true; 152 destroyed_ = true;
157 153
158 // Tell |container_| to clear references to this plugin's script objects.
159 if (container_)
160 container_->clearScriptObjects();
161
162 container_ = nullptr;
163
164 if (instance_.get()) { 154 if (instance_.get()) {
165 ppapi::PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(instance_object_); 155 ppapi::PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(instance_object_);
166 instance_object_ = PP_MakeUndefined(); 156 instance_object_ = PP_MakeUndefined();
167 instance_->Delete(); 157 instance_->Delete();
168 instance_ = NULL; 158 instance_ = NULL;
169 } 159 }
170 160
171 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); 161 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
172 } 162 }
173 163
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 309
320 bool PepperWebPluginImpl::canRotateView() { return instance_->CanRotateView(); } 310 bool PepperWebPluginImpl::canRotateView() { return instance_->CanRotateView(); }
321 311
322 void PepperWebPluginImpl::rotateView(RotationType type) { 312 void PepperWebPluginImpl::rotateView(RotationType type) {
323 instance_->RotateView(type); 313 instance_->RotateView(type);
324 } 314 }
325 315
326 bool PepperWebPluginImpl::isPlaceholder() { return false; } 316 bool PepperWebPluginImpl::isPlaceholder() { return false; }
327 317
328 } // namespace content 318 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_plugin_instance_impl.cc ('k') | content/renderer/render_thread_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698