| 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" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "chrome/browser/renderer_host/download_throttling_resource_handler.h" | 12 #include "chrome/browser/renderer_host/download_throttling_resource_handler.h" |
| 13 #include "content/browser/browser_thread.h" | 13 #include "content/browser/browser_thread.h" |
| 14 #include "content/browser/content_browser_client.h" | 14 #include "content/browser/content_browser_client.h" |
| 15 #include "content/browser/plugin_service.h" |
| 15 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 16 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 16 #include "content/browser/renderer_host/resource_dispatcher_host_delegate.h" | 17 #include "content/browser/renderer_host/resource_dispatcher_host_delegate.h" |
| 17 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" | 18 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" |
| 18 #include "content/browser/renderer_host/x509_user_cert_resource_handler.h" | 19 #include "content/browser/renderer_host/x509_user_cert_resource_handler.h" |
| 19 #include "content/common/resource_response.h" | 20 #include "content/common/resource_response.h" |
| 20 #include "net/base/io_buffer.h" | 21 #include "net/base/io_buffer.h" |
| 21 #include "net/base/mime_sniffer.h" | 22 #include "net/base/mime_sniffer.h" |
| 22 #include "net/base/mime_util.h" | 23 #include "net/base/mime_util.h" |
| 23 #include "net/base/net_errors.h" | 24 #include "net/base/net_errors.h" |
| 24 #include "net/http/http_response_headers.h" | 25 #include "net/http/http_response_headers.h" |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 if (host_->delegate() && | 382 if (host_->delegate() && |
| 382 host_->delegate()->ShouldForceDownloadResource(request_->url(), type)) | 383 host_->delegate()->ShouldForceDownloadResource(request_->url(), type)) |
| 383 return true; | 384 return true; |
| 384 | 385 |
| 385 // MIME type checking. | 386 // MIME type checking. |
| 386 if (net::IsSupportedMimeType(type)) | 387 if (net::IsSupportedMimeType(type)) |
| 387 return false; | 388 return false; |
| 388 | 389 |
| 389 // Finally, check the plugin list. | 390 // Finally, check the plugin list. |
| 390 bool allow_wildcard = false; | 391 bool allow_wildcard = false; |
| 392 ResourceDispatcherHostRequestInfo* info = |
| 393 ResourceDispatcherHost::InfoForRequest(request_); |
| 394 content::PluginFilter* filter = |
| 395 content::GetContentClient()->browser()->CreatePluginFilter( |
| 396 info->child_id(), info->route_id(), *info->context(), |
| 397 request_->url(), GURL()); |
| 391 bool stale = false; | 398 bool stale = false; |
| 392 std::vector<webkit::npapi::WebPluginInfo> plugins; | 399 webkit::npapi::WebPluginInfo plugin; |
| 393 webkit::npapi::PluginList::Singleton()->GetPluginInfoArray( | 400 bool found = PluginService::GetInstance()->GetPluginInfo( |
| 394 request_->url(), type, allow_wildcard, &stale, &plugins, NULL); | 401 request_->url(), type, allow_wildcard, filter, |
| 402 &stale, &plugin, NULL); |
| 403 |
| 395 if (need_plugin_list) { | 404 if (need_plugin_list) { |
| 396 if (stale) { | 405 if (stale) { |
| 397 *need_plugin_list = true; | 406 *need_plugin_list = true; |
| 398 return true; | 407 return true; |
| 399 } | 408 } |
| 400 } else { | 409 } else { |
| 401 DCHECK(!stale); | 410 DCHECK(!stale); |
| 402 } | 411 } |
| 403 | 412 |
| 404 for (size_t i = 0; i < plugins.size(); ++i) { | 413 return !found; |
| 405 if (webkit::npapi::IsPluginEnabled(plugins[i])) | |
| 406 return false; | |
| 407 } | |
| 408 return true; | |
| 409 } | 414 } |
| 410 | 415 |
| 411 void BufferedResourceHandler::UseAlternateResourceHandler( | 416 void BufferedResourceHandler::UseAlternateResourceHandler( |
| 412 int request_id, | 417 int request_id, |
| 413 ResourceHandler* handler) { | 418 ResourceHandler* handler) { |
| 414 ResourceDispatcherHostRequestInfo* info = | 419 ResourceDispatcherHostRequestInfo* info = |
| 415 ResourceDispatcherHost::InfoForRequest(request_); | 420 ResourceDispatcherHost::InfoForRequest(request_); |
| 416 if (bytes_read_) { | 421 if (bytes_read_) { |
| 417 // A Read has already occured and we need to copy the data into the new | 422 // A Read has already occured and we need to copy the data into the new |
| 418 // ResourceHandler. | 423 // ResourceHandler. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 wait_for_plugins_ = false; | 457 wait_for_plugins_ = false; |
| 453 if (!request_) | 458 if (!request_) |
| 454 return; | 459 return; |
| 455 | 460 |
| 456 ResourceDispatcherHostRequestInfo* info = | 461 ResourceDispatcherHostRequestInfo* info = |
| 457 ResourceDispatcherHost::InfoForRequest(request_); | 462 ResourceDispatcherHost::InfoForRequest(request_); |
| 458 host_->PauseRequest(info->child_id(), info->request_id(), false); | 463 host_->PauseRequest(info->child_id(), info->request_id(), false); |
| 459 if (!CompleteResponseStarted(info->request_id(), false)) | 464 if (!CompleteResponseStarted(info->request_id(), false)) |
| 460 host_->CancelRequest(info->child_id(), info->request_id(), false); | 465 host_->CancelRequest(info->child_id(), info->request_id(), false); |
| 461 } | 466 } |
| OLD | NEW |