| 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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "content/browser/download/download_id_factory.h" | 13 #include "content/browser/download/download_id_factory.h" |
| 14 #include "content/browser/download/download_resource_handler.h" | 14 #include "content/browser/download/download_resource_handler.h" |
| 15 #include "content/browser/download/download_types.h" | 15 #include "content/browser/download/download_types.h" |
| 16 #include "content/browser/plugin_service.h" | 16 #include "content/browser/plugin_service_impl.h" |
| 17 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 17 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 18 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" | 18 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" |
| 19 #include "content/browser/renderer_host/x509_user_cert_resource_handler.h" | 19 #include "content/browser/renderer_host/x509_user_cert_resource_handler.h" |
| 20 #include "content/browser/resource_context.h" | 20 #include "content/browser/resource_context.h" |
| 21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 22 #include "content/public/browser/content_browser_client.h" | 22 #include "content/public/browser/content_browser_client.h" |
| 23 #include "content/public/browser/resource_dispatcher_host_delegate.h" | 23 #include "content/public/browser/resource_dispatcher_host_delegate.h" |
| 24 #include "content/public/common/resource_response.h" | 24 #include "content/public/common/resource_response.h" |
| 25 #include "net/base/io_buffer.h" | 25 #include "net/base/io_buffer.h" |
| 26 #include "net/base/mime_sniffer.h" | 26 #include "net/base/mime_sniffer.h" |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 bool need_plugin_list; | 350 bool need_plugin_list; |
| 351 if (!ShouldDownload(&need_plugin_list) || !need_plugin_list) | 351 if (!ShouldDownload(&need_plugin_list) || !need_plugin_list) |
| 352 return false; | 352 return false; |
| 353 | 353 |
| 354 // We don't want to keep buffering as our buffer will fill up. | 354 // We don't want to keep buffering as our buffer will fill up. |
| 355 ResourceDispatcherHostRequestInfo* info = | 355 ResourceDispatcherHostRequestInfo* info = |
| 356 ResourceDispatcherHost::InfoForRequest(request_); | 356 ResourceDispatcherHost::InfoForRequest(request_); |
| 357 host_->PauseRequest(info->child_id(), info->request_id(), true); | 357 host_->PauseRequest(info->child_id(), info->request_id(), true); |
| 358 | 358 |
| 359 // Get the plugins asynchronously. | 359 // Get the plugins asynchronously. |
| 360 PluginService::GetInstance()->GetPlugins( | 360 PluginServiceImpl::GetInstance()->GetPlugins( |
| 361 base::Bind(&BufferedResourceHandler::OnPluginsLoaded, this)); | 361 base::Bind(&BufferedResourceHandler::OnPluginsLoaded, this)); |
| 362 return true; | 362 return true; |
| 363 } | 363 } |
| 364 | 364 |
| 365 // This test mirrors the decision that WebKit makes in | 365 // This test mirrors the decision that WebKit makes in |
| 366 // WebFrameLoaderClient::dispatchDecidePolicyForMIMEType. | 366 // WebFrameLoaderClient::dispatchDecidePolicyForMIMEType. |
| 367 bool BufferedResourceHandler::ShouldDownload(bool* need_plugin_list) { | 367 bool BufferedResourceHandler::ShouldDownload(bool* need_plugin_list) { |
| 368 if (need_plugin_list) | 368 if (need_plugin_list) |
| 369 *need_plugin_list = false; | 369 *need_plugin_list = false; |
| 370 std::string type = StringToLowerASCII(response_->mime_type); | 370 std::string type = StringToLowerASCII(response_->mime_type); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 // MIME type checking. | 409 // MIME type checking. |
| 410 if (net::IsSupportedMimeType(type)) | 410 if (net::IsSupportedMimeType(type)) |
| 411 return false; | 411 return false; |
| 412 | 412 |
| 413 // Finally, check the plugin list. | 413 // Finally, check the plugin list. |
| 414 bool allow_wildcard = false; | 414 bool allow_wildcard = false; |
| 415 ResourceDispatcherHostRequestInfo* info = | 415 ResourceDispatcherHostRequestInfo* info = |
| 416 ResourceDispatcherHost::InfoForRequest(request_); | 416 ResourceDispatcherHost::InfoForRequest(request_); |
| 417 bool stale = false; | 417 bool stale = false; |
| 418 webkit::WebPluginInfo plugin; | 418 webkit::WebPluginInfo plugin; |
| 419 bool found = PluginService::GetInstance()->GetPluginInfo( | 419 bool found = PluginServiceImpl::GetInstance()->GetPluginInfo( |
| 420 info->child_id(), info->route_id(), *info->context(), | 420 info->child_id(), info->route_id(), *info->context(), |
| 421 request_->url(), GURL(), type, allow_wildcard, | 421 request_->url(), GURL(), type, allow_wildcard, |
| 422 &stale, &plugin, NULL); | 422 &stale, &plugin, NULL); |
| 423 | 423 |
| 424 if (need_plugin_list) { | 424 if (need_plugin_list) { |
| 425 if (stale) { | 425 if (stale) { |
| 426 *need_plugin_list = true; | 426 *need_plugin_list = true; |
| 427 return true; | 427 return true; |
| 428 } | 428 } |
| 429 } else { | 429 } else { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 wait_for_plugins_ = false; | 469 wait_for_plugins_ = false; |
| 470 if (!request_) | 470 if (!request_) |
| 471 return; | 471 return; |
| 472 | 472 |
| 473 ResourceDispatcherHostRequestInfo* info = | 473 ResourceDispatcherHostRequestInfo* info = |
| 474 ResourceDispatcherHost::InfoForRequest(request_); | 474 ResourceDispatcherHost::InfoForRequest(request_); |
| 475 host_->PauseRequest(info->child_id(), info->request_id(), false); | 475 host_->PauseRequest(info->child_id(), info->request_id(), false); |
| 476 if (!CompleteResponseStarted(info->request_id(), false)) | 476 if (!CompleteResponseStarted(info->request_id(), false)) |
| 477 host_->CancelRequest(info->child_id(), info->request_id(), false); | 477 host_->CancelRequest(info->child_id(), info->request_id(), false); |
| 478 } | 478 } |
| OLD | NEW |