| 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 "content/browser/browser_thread.h" | 12 #include "content/browser/browser_thread.h" |
| 13 #include "content/browser/content_browser_client.h" | 13 #include "content/browser/content_browser_client.h" |
| 14 #include "content/browser/download/download_resource_handler.h" | 14 #include "content/browser/download/download_resource_handler.h" |
| 15 #include "content/browser/plugin_service.h" | 15 #include "content/browser/plugin_service.h" |
| 16 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 16 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 17 #include "content/browser/renderer_host/resource_dispatcher_host_delegate.h" | 17 #include "content/browser/renderer_host/resource_dispatcher_host_delegate.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/common/resource_response.h" | 21 #include "content/common/resource_response.h" |
| 21 #include "net/base/io_buffer.h" | 22 #include "net/base/io_buffer.h" |
| 22 #include "net/base/mime_sniffer.h" | 23 #include "net/base/mime_sniffer.h" |
| 23 #include "net/base/mime_util.h" | 24 #include "net/base/mime_util.h" |
| 24 #include "net/base/net_errors.h" | 25 #include "net/base/net_errors.h" |
| 25 #include "net/http/http_response_headers.h" | 26 #include "net/http/http_response_headers.h" |
| 26 #include "webkit/plugins/npapi/plugin_list.h" | 27 #include "webkit/plugins/npapi/plugin_list.h" |
| 27 | 28 |
| 28 namespace { | 29 namespace { |
| 29 | 30 |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 // know how to display the content. We follow Firefox here and show our | 303 // know how to display the content. We follow Firefox here and show our |
| 303 // own error page instead of triggering a download. | 304 // own error page instead of triggering a download. |
| 304 // TODO(abarth): We should abstract the response_code test, but this kind | 305 // TODO(abarth): We should abstract the response_code test, but this kind |
| 305 // of check is scattered throughout our codebase. | 306 // of check is scattered throughout our codebase. |
| 306 request_->SimulateError(net::ERR_FILE_NOT_FOUND); | 307 request_->SimulateError(net::ERR_FILE_NOT_FOUND); |
| 307 return false; | 308 return false; |
| 308 } | 309 } |
| 309 | 310 |
| 310 info->set_is_download(true); | 311 info->set_is_download(true); |
| 311 | 312 |
| 313 DownloadId dl_id = info->context()->next_download_id_thunk().Run(); |
| 314 |
| 312 scoped_refptr<ResourceHandler> handler( | 315 scoped_refptr<ResourceHandler> handler( |
| 313 new DownloadResourceHandler(host_, | 316 new DownloadResourceHandler(host_, |
| 314 info->child_id(), | 317 info->child_id(), |
| 315 info->route_id(), | 318 info->route_id(), |
| 316 info->request_id(), | 319 info->request_id(), |
| 317 request_->url(), | 320 request_->url(), |
| 321 dl_id, |
| 318 host_->download_file_manager(), | 322 host_->download_file_manager(), |
| 319 request_, | 323 request_, |
| 320 false, | 324 false, |
| 321 DownloadSaveInfo())); | 325 DownloadSaveInfo())); |
| 322 | 326 |
| 323 if (host_->delegate()) { | 327 if (host_->delegate()) { |
| 324 handler = host_->delegate()->DownloadStarting( | 328 handler = host_->delegate()->DownloadStarting( |
| 325 handler, *info->context(), request_, info->child_id(), | 329 handler, *info->context(), request_, info->child_id(), |
| 326 info->route_id(), info->request_id(), false, in_complete); | 330 info->route_id(), info->request_id(), false, in_complete); |
| 327 } | 331 } |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 wait_for_plugins_ = false; | 467 wait_for_plugins_ = false; |
| 464 if (!request_) | 468 if (!request_) |
| 465 return; | 469 return; |
| 466 | 470 |
| 467 ResourceDispatcherHostRequestInfo* info = | 471 ResourceDispatcherHostRequestInfo* info = |
| 468 ResourceDispatcherHost::InfoForRequest(request_); | 472 ResourceDispatcherHost::InfoForRequest(request_); |
| 469 host_->PauseRequest(info->child_id(), info->request_id(), false); | 473 host_->PauseRequest(info->child_id(), info->request_id(), false); |
| 470 if (!CompleteResponseStarted(info->request_id(), false)) | 474 if (!CompleteResponseStarted(info->request_id(), false)) |
| 471 host_->CancelRequest(info->child_id(), info->request_id(), false); | 475 host_->CancelRequest(info->child_id(), info->request_id(), false); |
| 472 } | 476 } |
| OLD | NEW |