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