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

Side by Side Diff: webkit/plugins/ppapi/ppapi_webplugin_impl.cc

Issue 15941006: Track NPObject ownership by the originating plugins' NPP identifier. [2/3] (Chrome) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix CppBoundClass. Created 7 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 | Annotate | Revision Log
« no previous file with comments | « webkit/plugins/ppapi/ppapi_webplugin_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "webkit/plugins/ppapi/ppapi_webplugin_impl.h" 5 #include "webkit/plugins/ppapi/ppapi_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.h" 10 #include "base/message_loop.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // The plugin delegate may have gone away. 86 // The plugin delegate may have gone away.
87 if (!init_data_->delegate) 87 if (!init_data_->delegate)
88 return false; 88 return false;
89 89
90 instance_ = init_data_->module->CreateInstance(init_data_->delegate, 90 instance_ = init_data_->module->CreateInstance(init_data_->delegate,
91 container, 91 container,
92 init_data_->url); 92 init_data_->url);
93 if (!instance_) 93 if (!instance_)
94 return false; 94 return false;
95 95
96 // Enable script objects for this plugin.
97 container->allowScriptObjects();
98
96 bool success = instance_->Initialize(init_data_->arg_names, 99 bool success = instance_->Initialize(init_data_->arg_names,
97 init_data_->arg_values, 100 init_data_->arg_values,
98 full_frame_); 101 full_frame_);
99 if (!success) { 102 if (!success) {
100 instance_->Delete(); 103 instance_->Delete();
101 instance_ = NULL; 104 instance_ = NULL;
102 105
103 WebKit::WebPlugin* replacement_plugin = 106 WebKit::WebPlugin* replacement_plugin =
104 init_data_->delegate->CreatePluginReplacement( 107 init_data_->delegate->CreatePluginReplacement(
105 init_data_->module->path()); 108 init_data_->module->path());
106 if (!replacement_plugin || !replacement_plugin->initialize(container)) 109 if (!replacement_plugin || !replacement_plugin->initialize(container))
107 return false; 110 return false;
108 111
109 container->setPlugin(replacement_plugin); 112 container->setPlugin(replacement_plugin);
110 return true; 113 return true;
111 } 114 }
112 115
113 init_data_.reset(); 116 init_data_.reset();
114 container_ = container; 117 container_ = container;
115 return true; 118 return true;
116 } 119 }
117 120
118 void WebPluginImpl::destroy() { 121 void WebPluginImpl::destroy() {
122 // Tell |container_| to clear references to this plugin's script objects.
123 container_->clearScriptObjects();
124
119 if (instance_) { 125 if (instance_) {
120 ::ppapi::PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(instance_object_); 126 ::ppapi::PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(instance_object_);
121 instance_object_ = PP_MakeUndefined(); 127 instance_object_ = PP_MakeUndefined();
122 instance_->Delete(); 128 instance_->Delete();
123 instance_ = NULL; 129 instance_ = NULL;
124 } 130 }
125 131
126 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); 132 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
127 } 133 }
128 134
(...skipping 12 matching lines...) Expand all
141 // any non-postMessage calls to it. 147 // any non-postMessage calls to it.
142 if (object) { 148 if (object) {
143 instance_->message_channel().SetPassthroughObject(object->np_object()); 149 instance_->message_channel().SetPassthroughObject(object->np_object());
144 } 150 }
145 NPObject* message_channel_np_object(instance_->message_channel().np_object()); 151 NPObject* message_channel_np_object(instance_->message_channel().np_object());
146 // The object is expected to be retained before it is returned. 152 // The object is expected to be retained before it is returned.
147 WebKit::WebBindings::retainObject(message_channel_np_object); 153 WebKit::WebBindings::retainObject(message_channel_np_object);
148 return message_channel_np_object; 154 return message_channel_np_object;
149 } 155 }
150 156
157 NPP WebPluginImpl::pluginNPP() {
158 return instance_->instanceNPP();
159 }
160
151 bool WebPluginImpl::getFormValue(WebString& value) { 161 bool WebPluginImpl::getFormValue(WebString& value) {
152 return false; 162 return false;
153 } 163 }
154 164
155 void WebPluginImpl::paint(WebCanvas* canvas, const WebRect& rect) { 165 void WebPluginImpl::paint(WebCanvas* canvas, const WebRect& rect) {
156 if (!instance_->FlashIsFullscreenOrPending()) 166 if (!instance_->FlashIsFullscreenOrPending())
157 instance_->Paint(canvas, plugin_rect_, rect); 167 instance_->Paint(canvas, plugin_rect_, rect);
158 } 168 }
159 169
160 void WebPluginImpl::updateGeometry( 170 void WebPluginImpl::updateGeometry(
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 void WebPluginImpl::rotateView(RotationType type) { 295 void WebPluginImpl::rotateView(RotationType type) {
286 instance_->RotateView(type); 296 instance_->RotateView(type);
287 } 297 }
288 298
289 bool WebPluginImpl::isPlaceholder() { 299 bool WebPluginImpl::isPlaceholder() {
290 return false; 300 return false;
291 } 301 }
292 302
293 } // namespace ppapi 303 } // namespace ppapi
294 } // namespace webkit 304 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppapi_webplugin_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698