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