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 "content/browser/renderer_host/buffered_resource_handler.h" | 5 #include "content/browser/renderer_host/buffered_resource_handler.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 } | 379 } |
380 | 380 |
381 if (host_->delegate() && | 381 if (host_->delegate() && |
382 host_->delegate()->ShouldForceDownloadResource(request_->url(), type)) | 382 host_->delegate()->ShouldForceDownloadResource(request_->url(), type)) |
383 return true; | 383 return true; |
384 | 384 |
385 // MIME type checking. | 385 // MIME type checking. |
386 if (net::IsSupportedMimeType(type)) | 386 if (net::IsSupportedMimeType(type)) |
387 return false; | 387 return false; |
388 | 388 |
| 389 // Finally, check the plugin list. |
| 390 bool allow_wildcard = false; |
| 391 bool stale = false; |
| 392 std::vector<webkit::npapi::WebPluginInfo> plugins; |
| 393 webkit::npapi::PluginList::Singleton()->GetPluginInfoArray( |
| 394 request_->url(), type, allow_wildcard, &stale, &plugins, NULL); |
389 if (need_plugin_list) { | 395 if (need_plugin_list) { |
390 if (webkit::npapi::PluginList::Singleton()->stale()) { | 396 if (stale) { |
391 *need_plugin_list = true; | 397 *need_plugin_list = true; |
392 return true; | 398 return true; |
393 } | 399 } |
394 } else { | 400 } else { |
395 DCHECK(!webkit::npapi::PluginList::Singleton()->stale()); | 401 DCHECK(!stale); |
396 } | 402 } |
397 | 403 |
398 // Finally, check the plugin list. | 404 for (size_t i = 0; i < plugins.size(); ++i) { |
399 webkit::npapi::WebPluginInfo info; | 405 if (webkit::npapi::IsPluginEnabled(plugins[i])) |
400 bool allow_wildcard = false; | 406 return false; |
401 return !webkit::npapi::PluginList::Singleton()->GetPluginInfo( | 407 } |
402 GURL(), type, allow_wildcard, &info, NULL) || | 408 return true; |
403 !webkit::npapi::IsPluginEnabled(info); | |
404 } | 409 } |
405 | 410 |
406 void BufferedResourceHandler::UseAlternateResourceHandler( | 411 void BufferedResourceHandler::UseAlternateResourceHandler( |
407 int request_id, | 412 int request_id, |
408 ResourceHandler* handler) { | 413 ResourceHandler* handler) { |
409 ResourceDispatcherHostRequestInfo* info = | 414 ResourceDispatcherHostRequestInfo* info = |
410 ResourceDispatcherHost::InfoForRequest(request_); | 415 ResourceDispatcherHost::InfoForRequest(request_); |
411 if (bytes_read_) { | 416 if (bytes_read_) { |
412 // A Read has already occured and we need to copy the data into the new | 417 // A Read has already occured and we need to copy the data into the new |
413 // ResourceHandler. | 418 // ResourceHandler. |
(...skipping 15 matching lines...) Expand all Loading... |
429 // the original ResourceHandler chain) will be deleted by the next statement. | 434 // the original ResourceHandler chain) will be deleted by the next statement. |
430 info->set_cross_site_handler(NULL); | 435 info->set_cross_site_handler(NULL); |
431 | 436 |
432 // This is handled entirely within the new ResourceHandler, so just reset the | 437 // This is handled entirely within the new ResourceHandler, so just reset the |
433 // original ResourceHandler. | 438 // original ResourceHandler. |
434 real_handler_ = handler; | 439 real_handler_ = handler; |
435 } | 440 } |
436 | 441 |
437 void BufferedResourceHandler::LoadPlugins() { | 442 void BufferedResourceHandler::LoadPlugins() { |
438 std::vector<webkit::npapi::WebPluginInfo> plugins; | 443 std::vector<webkit::npapi::WebPluginInfo> plugins; |
439 webkit::npapi::PluginList::Singleton()->GetPlugins(false, &plugins); | 444 webkit::npapi::PluginList::Singleton()->GetPlugins(&plugins); |
440 | 445 |
441 BrowserThread::PostTask( | 446 BrowserThread::PostTask( |
442 BrowserThread::IO, FROM_HERE, | 447 BrowserThread::IO, FROM_HERE, |
443 NewRunnableMethod(this, &BufferedResourceHandler::OnPluginsLoaded)); | 448 NewRunnableMethod(this, &BufferedResourceHandler::OnPluginsLoaded)); |
444 } | 449 } |
445 | 450 |
446 void BufferedResourceHandler::OnPluginsLoaded() { | 451 void BufferedResourceHandler::OnPluginsLoaded() { |
447 wait_for_plugins_ = false; | 452 wait_for_plugins_ = false; |
448 if (!request_) | 453 if (!request_) |
449 return; | 454 return; |
450 | 455 |
451 ResourceDispatcherHostRequestInfo* info = | 456 ResourceDispatcherHostRequestInfo* info = |
452 ResourceDispatcherHost::InfoForRequest(request_); | 457 ResourceDispatcherHost::InfoForRequest(request_); |
453 host_->PauseRequest(info->child_id(), info->request_id(), false); | 458 host_->PauseRequest(info->child_id(), info->request_id(), false); |
454 if (!CompleteResponseStarted(info->request_id(), false)) | 459 if (!CompleteResponseStarted(info->request_id(), false)) |
455 host_->CancelRequest(info->child_id(), info->request_id(), false); | 460 host_->CancelRequest(info->child_id(), info->request_id(), false); |
456 } | 461 } |
OLD | NEW |