| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/logging.h" | 8 #include "base/logging.h" |
| 8 #include "base/memory/linked_ptr.h" | 9 #include "base/memory/linked_ptr.h" |
| 9 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 10 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 11 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 12 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
| 13 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 14 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
| 15 #include "googleurl/src/url_util.h" | 16 #include "googleurl/src/url_util.h" |
| 16 #include "net/base/escape.h" | 17 #include "net/base/escape.h" |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 // first update geometry sequence. We need to ensure that the plugin | 341 // first update geometry sequence. We need to ensure that the plugin |
| 341 // receives the geometry update before it starts receiving data. | 342 // receives the geometry update before it starts receiving data. |
| 342 if (first_geometry_update_) { | 343 if (first_geometry_update_) { |
| 343 // An empty url corresponds to an EMBED tag with no src attribute. | 344 // An empty url corresponds to an EMBED tag with no src attribute. |
| 344 if (!load_manually_ && plugin_url_.is_valid()) { | 345 if (!load_manually_ && plugin_url_.is_valid()) { |
| 345 // The Flash plugin hangs for a while if it receives data before | 346 // The Flash plugin hangs for a while if it receives data before |
| 346 // receiving valid plugin geometry. By valid geometry we mean the | 347 // receiving valid plugin geometry. By valid geometry we mean the |
| 347 // geometry received by a call to setFrameRect in the Webkit | 348 // geometry received by a call to setFrameRect in the Webkit |
| 348 // layout code path. To workaround this issue we download the | 349 // layout code path. To workaround this issue we download the |
| 349 // plugin source url on a timer. | 350 // plugin source url on a timer. |
| 350 MessageLoop::current()->PostDelayedTask( | 351 MessageLoop::current()->PostTask( |
| 351 FROM_HERE, method_factory_.NewRunnableMethod( | 352 FROM_HERE, base::Bind(&WebPluginImpl::OnDownloadPluginSrcUrl, |
| 352 &WebPluginImpl::OnDownloadPluginSrcUrl), 0); | 353 weak_factory_.GetWeakPtr())); |
| 353 } | 354 } |
| 354 } | 355 } |
| 355 | 356 |
| 356 #if defined(OS_WIN) | 357 #if defined(OS_WIN) |
| 357 // Don't cache the geometry during the first geometry update. The first | 358 // Don't cache the geometry during the first geometry update. The first |
| 358 // geometry update sequence is received when Widget::setParent is called. | 359 // geometry update sequence is received when Widget::setParent is called. |
| 359 // For plugins like media player which have a bug where they only honor | 360 // For plugins like media player which have a bug where they only honor |
| 360 // the first geometry update, we have a quirk which ignores the first | 361 // the first geometry update, we have a quirk which ignores the first |
| 361 // geometry update. To ensure that these plugins work correctly in cases | 362 // geometry update. To ensure that these plugins work correctly in cases |
| 362 // where we receive only one geometry update from webkit, we also force | 363 // where we receive only one geometry update from webkit, we also force |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 page_delegate_(page_delegate), | 468 page_delegate_(page_delegate), |
| 468 webframe_(webframe), | 469 webframe_(webframe), |
| 469 delegate_(NULL), | 470 delegate_(NULL), |
| 470 container_(NULL), | 471 container_(NULL), |
| 471 plugin_url_(params.url), | 472 plugin_url_(params.url), |
| 472 load_manually_(params.loadManually), | 473 load_manually_(params.loadManually), |
| 473 first_geometry_update_(true), | 474 first_geometry_update_(true), |
| 474 ignore_response_error_(false), | 475 ignore_response_error_(false), |
| 475 file_path_(file_path), | 476 file_path_(file_path), |
| 476 mime_type_(UTF16ToASCII(params.mimeType)), | 477 mime_type_(UTF16ToASCII(params.mimeType)), |
| 477 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { | 478 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
| 478 DCHECK_EQ(params.attributeNames.size(), params.attributeValues.size()); | 479 DCHECK_EQ(params.attributeNames.size(), params.attributeValues.size()); |
| 479 StringToLowerASCII(&mime_type_); | 480 StringToLowerASCII(&mime_type_); |
| 480 | 481 |
| 481 for (size_t i = 0; i < params.attributeNames.size(); ++i) { | 482 for (size_t i = 0; i < params.attributeNames.size(); ++i) { |
| 482 arg_names_.push_back(params.attributeNames[i].utf8()); | 483 arg_names_.push_back(params.attributeNames[i].utf8()); |
| 483 arg_values_.push_back(params.attributeValues[i].utf8()); | 484 arg_values_.push_back(params.attributeValues[i].utf8()); |
| 484 } | 485 } |
| 485 } | 486 } |
| 486 | 487 |
| 487 WebPluginImpl::~WebPluginImpl() { | 488 WebPluginImpl::~WebPluginImpl() { |
| (...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1343 | 1344 |
| 1344 if (client_info.loader.get()) | 1345 if (client_info.loader.get()) |
| 1345 client_info.loader->cancel(); | 1346 client_info.loader->cancel(); |
| 1346 | 1347 |
| 1347 client_index = clients_.erase(client_index); | 1348 client_index = clients_.erase(client_index); |
| 1348 } | 1349 } |
| 1349 | 1350 |
| 1350 // This needs to be called now and not in the destructor since the | 1351 // This needs to be called now and not in the destructor since the |
| 1351 // webframe_ might not be valid anymore. | 1352 // webframe_ might not be valid anymore. |
| 1352 webframe_ = NULL; | 1353 webframe_ = NULL; |
| 1353 method_factory_.RevokeAll(); | 1354 weak_factory_.InvalidateWeakPtrs(); |
| 1354 } | 1355 } |
| 1355 | 1356 |
| 1356 void WebPluginImpl::SetReferrer(WebKit::WebURLRequest* request, | 1357 void WebPluginImpl::SetReferrer(WebKit::WebURLRequest* request, |
| 1357 Referrer referrer_flag) { | 1358 Referrer referrer_flag) { |
| 1358 switch (referrer_flag) { | 1359 switch (referrer_flag) { |
| 1359 case DOCUMENT_URL: | 1360 case DOCUMENT_URL: |
| 1360 webframe_->setReferrerForRequest(*request, GURL()); | 1361 webframe_->setReferrerForRequest(*request, GURL()); |
| 1361 break; | 1362 break; |
| 1362 | 1363 |
| 1363 case PLUGIN_SRC: | 1364 case PLUGIN_SRC: |
| 1364 webframe_->setReferrerForRequest(*request, plugin_url_); | 1365 webframe_->setReferrerForRequest(*request, plugin_url_); |
| 1365 break; | 1366 break; |
| 1366 | 1367 |
| 1367 default: | 1368 default: |
| 1368 break; | 1369 break; |
| 1369 } | 1370 } |
| 1370 } | 1371 } |
| 1371 | 1372 |
| 1372 } // namespace npapi | 1373 } // namespace npapi |
| 1373 } // namespace webkit | 1374 } // namespace webkit |
| OLD | NEW |