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

Side by Side Diff: webkit/plugins/npapi/webplugin_impl.cc

Issue 17208003: Track NPObject ownership by the originating plugins' NPP identifier. [4/6] (Chrome) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove DCHECKs on proxy and stub maps. 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 | « content/renderer/webplugin_delegate_proxy.cc ('k') | webkit/renderer/cpp_variant_unittest.cc » ('j') | 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/npapi/webplugin_impl.h" 5 #include "webkit/plugins/npapi/webplugin_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/crash_logging.h" 8 #include "base/debug/crash_logging.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/linked_ptr.h" 10 #include "base/memory/linked_ptr.h"
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 SetContainer(container); 253 SetContainer(container);
254 254
255 bool ok = plugin_delegate->Initialize( 255 bool ok = plugin_delegate->Initialize(
256 plugin_url_, arg_names_, arg_values_, this, load_manually_); 256 plugin_url_, arg_names_, arg_values_, this, load_manually_);
257 if (!ok) { 257 if (!ok) {
258 LOG(ERROR) << "Couldn't initialize plug-in"; 258 LOG(ERROR) << "Couldn't initialize plug-in";
259 plugin_delegate->PluginDestroyed(); 259 plugin_delegate->PluginDestroyed();
260 260
261 WebKit::WebPlugin* replacement_plugin = 261 WebKit::WebPlugin* replacement_plugin =
262 page_delegate_->CreatePluginReplacement(file_path_); 262 page_delegate_->CreatePluginReplacement(file_path_);
263 if (!replacement_plugin || !replacement_plugin->initialize(container)) 263 if (!replacement_plugin)
264 return false; 264 return false;
265 265
266 // Disable scripting by this plugin before replacing it with the new
267 // one. This plugin also needs destroying, so use destroy(), which will
268 // implicitly disable scripting while un-setting the container.
269 destroy();
270
271 // Inform the container of the replacement plugin, then initialize it.
266 container->setPlugin(replacement_plugin); 272 container->setPlugin(replacement_plugin);
267 destroy(); 273 return replacement_plugin->initialize(container);
268 return true;
269 } 274 }
270 275
271 delegate_ = plugin_delegate; 276 delegate_ = plugin_delegate;
272 277
273 return true; 278 return true;
274 } 279 }
275 280
276 void WebPluginImpl::destroy() { 281 void WebPluginImpl::destroy() {
277 SetContainer(NULL); 282 SetContainer(NULL);
278 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); 283 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
(...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 1318
1314 // Destroy the current plugin instance. 1319 // Destroy the current plugin instance.
1315 TearDownPluginInstance(loader); 1320 TearDownPluginInstance(loader);
1316 1321
1317 container_ = container_widget; 1322 container_ = container_widget;
1318 webframe_ = webframe; 1323 webframe_ = webframe;
1319 1324
1320 WebPluginDelegate* plugin_delegate = page_delegate_->CreatePluginDelegate( 1325 WebPluginDelegate* plugin_delegate = page_delegate_->CreatePluginDelegate(
1321 file_path_, mime_type_); 1326 file_path_, mime_type_);
1322 1327
1328 // Store the plugin's unique identifier, used by the container to track its
1329 // script objects, and enable script objects (since Initialize may use them
1330 // even if it fails).
1331 npp_ = plugin_delegate->GetPluginNPP();
1332 container_->allowScriptObjects();
1333
1323 bool ok = plugin_delegate && plugin_delegate->Initialize( 1334 bool ok = plugin_delegate && plugin_delegate->Initialize(
1324 plugin_url_, arg_names_, arg_values_, this, load_manually_); 1335 plugin_url_, arg_names_, arg_values_, this, load_manually_);
1325 1336
1326 if (!ok) { 1337 if (!ok) {
1338 container_->clearScriptObjects();
1327 container_ = NULL; 1339 container_ = NULL;
1328 // TODO(iyengar) Should we delete the current plugin instance here? 1340 // TODO(iyengar) Should we delete the current plugin instance here?
1329 return false; 1341 return false;
1330 } 1342 }
1331 1343
1332 delegate_ = plugin_delegate; 1344 delegate_ = plugin_delegate;
1333 1345
1334 // Force a geometry update to occur to ensure that the plugin becomes 1346 // Force a geometry update to occur to ensure that the plugin becomes
1335 // visible. 1347 // visible.
1336 container_->reportGeometry(); 1348 container_->reportGeometry();
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 webframe_->setReferrerForRequest(*request, plugin_url_); 1418 webframe_->setReferrerForRequest(*request, plugin_url_);
1407 break; 1419 break;
1408 1420
1409 default: 1421 default:
1410 break; 1422 break;
1411 } 1423 }
1412 } 1424 }
1413 1425
1414 } // namespace npapi 1426 } // namespace npapi
1415 } // namespace webkit 1427 } // namespace webkit
OLDNEW
« no previous file with comments | « content/renderer/webplugin_delegate_proxy.cc ('k') | webkit/renderer/cpp_variant_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698