| 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/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/linked_ptr.h" | 9 #include "base/memory/linked_ptr.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 }; | 249 }; |
| 250 | 250 |
| 251 bool WebPluginImpl::initialize(WebPluginContainer* container) { | 251 bool WebPluginImpl::initialize(WebPluginContainer* container) { |
| 252 if (!page_delegate_) { | 252 if (!page_delegate_) { |
| 253 LOG(ERROR) << "No page delegate"; | 253 LOG(ERROR) << "No page delegate"; |
| 254 return false; | 254 return false; |
| 255 } | 255 } |
| 256 | 256 |
| 257 WebPluginDelegate* plugin_delegate = page_delegate_->CreatePluginDelegate( | 257 WebPluginDelegate* plugin_delegate = page_delegate_->CreatePluginDelegate( |
| 258 file_path_, mime_type_); | 258 file_path_, mime_type_); |
| 259 if (!plugin_delegate) { | 259 if (!plugin_delegate) |
| 260 LOG(ERROR) << "Couldn't create plug-in delegate"; | |
| 261 return false; | 260 return false; |
| 262 } | |
| 263 | 261 |
| 264 // Set the container before Initialize because the plugin may | 262 // Set the container before Initialize because the plugin may |
| 265 // synchronously call NPN_GetValue to get its container during its | 263 // synchronously call NPN_GetValue to get its container during its |
| 266 // initialization. | 264 // initialization. |
| 267 SetContainer(container); | 265 SetContainer(container); |
| 268 bool ok = plugin_delegate->Initialize( | 266 bool ok = plugin_delegate->Initialize( |
| 269 plugin_url_, arg_names_, arg_values_, this, load_manually_); | 267 plugin_url_, arg_names_, arg_values_, this, load_manually_); |
| 270 if (!ok) { | 268 if (!ok) { |
| 271 LOG(ERROR) << "Couldn't initialize plug-in"; | 269 LOG(ERROR) << "Couldn't initialize plug-in"; |
| 272 plugin_delegate->PluginDestroyed(); | 270 plugin_delegate->PluginDestroyed(); |
| 273 return false; | 271 |
| 272 WebKit::WebPlugin* replacement_plugin = |
| 273 page_delegate_->CreatePluginReplacement(file_path_); |
| 274 if (!replacement_plugin || !replacement_plugin->initialize(container)) |
| 275 return false; |
| 276 |
| 277 container->setPlugin(replacement_plugin); |
| 278 return true; |
| 274 } | 279 } |
| 275 | 280 |
| 276 delegate_ = plugin_delegate; | 281 delegate_ = plugin_delegate; |
| 277 | 282 |
| 278 return true; | 283 return true; |
| 279 } | 284 } |
| 280 | 285 |
| 281 void WebPluginImpl::destroy() { | 286 void WebPluginImpl::destroy() { |
| 282 SetContainer(NULL); | 287 SetContainer(NULL); |
| 283 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 288 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| (...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1422 webframe_->setReferrerForRequest(*request, plugin_url_); | 1427 webframe_->setReferrerForRequest(*request, plugin_url_); |
| 1423 break; | 1428 break; |
| 1424 | 1429 |
| 1425 default: | 1430 default: |
| 1426 break; | 1431 break; |
| 1427 } | 1432 } |
| 1428 } | 1433 } |
| 1429 | 1434 |
| 1430 } // namespace npapi | 1435 } // namespace npapi |
| 1431 } // namespace webkit | 1436 } // namespace webkit |
| OLD | NEW |