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 "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 Loading... | |
| 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) |
|
darin (slow to review)
2013/06/18 23:26:24
It is not clear to me why you are making this chan
Wez
2013/06/19 05:17:54
Reworded comment to try to make that clearer.
| |
| 264 return false; | 264 return false; |
| 265 | 265 |
| 266 // Schedule ourself for asynchronous destruction, and and swap ourself out | |
|
darin (slow to review)
2013/06/18 23:26:24
nit: "and and"
Wez
2013/06/19 05:17:54
Done.
| |
| 267 // for the replacement plugin. | |
| 268 destroy(); | |
| 266 container->setPlugin(replacement_plugin); | 269 container->setPlugin(replacement_plugin); |
| 267 destroy(); | 270 |
| 268 return true; | 271 return replacement_plugin->initialize(container); |
| 269 } | 272 } |
| 270 | 273 |
| 271 delegate_ = plugin_delegate; | 274 delegate_ = plugin_delegate; |
| 272 | 275 |
| 273 return true; | 276 return true; |
| 274 } | 277 } |
| 275 | 278 |
| 276 void WebPluginImpl::destroy() { | 279 void WebPluginImpl::destroy() { |
| 277 SetContainer(NULL); | 280 SetContainer(NULL); |
| 278 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 281 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| (...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1313 | 1316 |
| 1314 // Destroy the current plugin instance. | 1317 // Destroy the current plugin instance. |
| 1315 TearDownPluginInstance(loader); | 1318 TearDownPluginInstance(loader); |
| 1316 | 1319 |
| 1317 container_ = container_widget; | 1320 container_ = container_widget; |
| 1318 webframe_ = webframe; | 1321 webframe_ = webframe; |
| 1319 | 1322 |
| 1320 WebPluginDelegate* plugin_delegate = page_delegate_->CreatePluginDelegate( | 1323 WebPluginDelegate* plugin_delegate = page_delegate_->CreatePluginDelegate( |
| 1321 file_path_, mime_type_); | 1324 file_path_, mime_type_); |
| 1322 | 1325 |
| 1326 // Store the plugin's unique identifier, used by the container to track its | |
| 1327 // script objects, and enable script objects (since Initialize may use them | |
| 1328 // even if it fails). | |
| 1329 npp_ = plugin_delegate->GetPluginNPP(); | |
| 1330 container_->allowScriptObjects(); | |
| 1331 | |
| 1323 bool ok = plugin_delegate && plugin_delegate->Initialize( | 1332 bool ok = plugin_delegate && plugin_delegate->Initialize( |
| 1324 plugin_url_, arg_names_, arg_values_, this, load_manually_); | 1333 plugin_url_, arg_names_, arg_values_, this, load_manually_); |
| 1325 | 1334 |
| 1326 if (!ok) { | 1335 if (!ok) { |
| 1336 container_->clearScriptObjects(); | |
| 1327 container_ = NULL; | 1337 container_ = NULL; |
| 1328 // TODO(iyengar) Should we delete the current plugin instance here? | 1338 // TODO(iyengar) Should we delete the current plugin instance here? |
| 1329 return false; | 1339 return false; |
| 1330 } | 1340 } |
| 1331 | 1341 |
| 1332 delegate_ = plugin_delegate; | 1342 delegate_ = plugin_delegate; |
| 1333 | 1343 |
| 1334 // Force a geometry update to occur to ensure that the plugin becomes | 1344 // Force a geometry update to occur to ensure that the plugin becomes |
| 1335 // visible. | 1345 // visible. |
| 1336 container_->reportGeometry(); | 1346 container_->reportGeometry(); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1406 webframe_->setReferrerForRequest(*request, plugin_url_); | 1416 webframe_->setReferrerForRequest(*request, plugin_url_); |
| 1407 break; | 1417 break; |
| 1408 | 1418 |
| 1409 default: | 1419 default: |
| 1410 break; | 1420 break; |
| 1411 } | 1421 } |
| 1412 } | 1422 } |
| 1413 | 1423 |
| 1414 } // namespace npapi | 1424 } // namespace npapi |
| 1415 } // namespace webkit | 1425 } // namespace webkit |
| OLD | NEW |