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