| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/loader/buffered_resource_handler.h" | 5 #include "content/browser/loader/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/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "content/browser/download/download_resource_handler.h" | 13 #include "content/browser/download/download_resource_handler.h" |
| 14 #include "content/browser/download/download_stats.h" | 14 #include "content/browser/download/download_stats.h" |
| 15 #include "content/browser/loader/certificate_resource_handler.h" | 15 #include "content/browser/loader/certificate_resource_handler.h" |
| 16 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 16 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 17 #include "content/browser/loader/resource_request_info_impl.h" | 17 #include "content/browser/loader/resource_request_info_impl.h" |
| 18 #include "content/browser/loader/stream_resource_handler.h" | 18 #include "content/browser/loader/stream_resource_handler.h" |
| 19 #include "content/browser/plugin_service_impl.h" | 19 #include "content/browser/plugin_service_impl.h" |
| 20 #include "content/common/mime_util.h" |
| 20 #include "content/public/browser/content_browser_client.h" | 21 #include "content/public/browser/content_browser_client.h" |
| 21 #include "content/public/browser/download_item.h" | 22 #include "content/public/browser/download_item.h" |
| 22 #include "content/public/browser/download_save_info.h" | 23 #include "content/public/browser/download_save_info.h" |
| 23 #include "content/public/browser/download_url_parameters.h" | 24 #include "content/public/browser/download_url_parameters.h" |
| 24 #include "content/public/browser/resource_context.h" | 25 #include "content/public/browser/resource_context.h" |
| 25 #include "content/public/browser/resource_dispatcher_host_delegate.h" | 26 #include "content/public/browser/resource_dispatcher_host_delegate.h" |
| 26 #include "content/public/common/resource_response.h" | 27 #include "content/public/common/resource_response.h" |
| 27 #include "content/public/common/webplugininfo.h" | 28 #include "content/public/common/webplugininfo.h" |
| 28 #include "net/base/io_buffer.h" | 29 #include "net/base/io_buffer.h" |
| 29 #include "net/base/mime_sniffer.h" | 30 #include "net/base/mime_sniffer.h" |
| 30 #include "net/base/mime_util.h" | |
| 31 #include "net/base/net_errors.h" | 31 #include "net/base/net_errors.h" |
| 32 #include "net/http/http_content_disposition.h" | 32 #include "net/http/http_content_disposition.h" |
| 33 #include "net/http/http_response_headers.h" | 33 #include "net/http/http_response_headers.h" |
| 34 | 34 |
| 35 namespace content { | 35 namespace content { |
| 36 | 36 |
| 37 namespace { | 37 namespace { |
| 38 | 38 |
| 39 void RecordSnifferMetrics(bool sniffing_blocked, | 39 void RecordSnifferMetrics(bool sniffing_blocked, |
| 40 bool we_would_like_to_sniff, | 40 bool we_would_like_to_sniff, |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 scoped_ptr<ResourceHandler> handler( | 307 scoped_ptr<ResourceHandler> handler( |
| 308 new CertificateResourceHandler(request())); | 308 new CertificateResourceHandler(request())); |
| 309 return UseAlternateNextHandler(handler.Pass(), std::string()); | 309 return UseAlternateNextHandler(handler.Pass(), std::string()); |
| 310 } | 310 } |
| 311 | 311 |
| 312 if (!info->allow_download()) | 312 if (!info->allow_download()) |
| 313 return true; | 313 return true; |
| 314 | 314 |
| 315 bool must_download = MustDownload(); | 315 bool must_download = MustDownload(); |
| 316 if (!must_download) { | 316 if (!must_download) { |
| 317 if (net::IsSupportedMimeType(mime_type)) | 317 if (content::IsSupportedMimeType(mime_type)) |
| 318 return true; | 318 return true; |
| 319 | 319 |
| 320 std::string payload; | 320 std::string payload; |
| 321 scoped_ptr<ResourceHandler> handler( | 321 scoped_ptr<ResourceHandler> handler( |
| 322 host_->MaybeInterceptAsStream(request(), response_.get(), &payload)); | 322 host_->MaybeInterceptAsStream(request(), response_.get(), &payload)); |
| 323 if (handler) { | 323 if (handler) { |
| 324 return UseAlternateNextHandler(handler.Pass(), payload); | 324 return UseAlternateNextHandler(handler.Pass(), payload); |
| 325 } | 325 } |
| 326 | 326 |
| 327 #if defined(ENABLE_PLUGINS) | 327 #if defined(ENABLE_PLUGINS) |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 request()->LogUnblocked(); | 491 request()->LogUnblocked(); |
| 492 bool defer = false; | 492 bool defer = false; |
| 493 if (!ProcessResponse(&defer)) { | 493 if (!ProcessResponse(&defer)) { |
| 494 controller()->Cancel(); | 494 controller()->Cancel(); |
| 495 } else if (!defer) { | 495 } else if (!defer) { |
| 496 controller()->Resume(); | 496 controller()->Resume(); |
| 497 } | 497 } |
| 498 } | 498 } |
| 499 | 499 |
| 500 } // namespace content | 500 } // namespace content |
| OLD | NEW |