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 "chrome/browser/android/intercept_download_resource_throttle.h" | 5 #include "chrome/browser/android/intercept_download_resource_throttle.h" |
6 | 6 |
7 #include "components/data_reduction_proxy/common/data_reduction_proxy_headers.h" | 7 #include "components/data_reduction_proxy/common/data_reduction_proxy_headers.h" |
8 #include "content/public/browser/android/download_controller_android.h" | 8 #include "content/public/browser/android/download_controller_android.h" |
9 #include "content/public/browser/resource_controller.h" | 9 #include "content/public/browser/resource_controller.h" |
10 #include "net/http/http_request_headers.h" | 10 #include "net/http/http_request_headers.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 return; | 51 return; |
52 | 52 |
53 if (request_->method() != net::HttpRequestHeaders::kGetMethod) | 53 if (request_->method() != net::HttpRequestHeaders::kGetMethod) |
54 return; | 54 return; |
55 | 55 |
56 // In general, if the request uses HTTP authorization, either with the origin | 56 // In general, if the request uses HTTP authorization, either with the origin |
57 // or a proxy, then the network stack should handle the download. The one | 57 // or a proxy, then the network stack should handle the download. The one |
58 // exception is a request that is fetched via the Chrome Proxy and does not | 58 // exception is a request that is fetched via the Chrome Proxy and does not |
59 // authenticate with the origin. | 59 // authenticate with the origin. |
60 if (request_->response_info().did_use_http_auth) { | 60 if (request_->response_info().did_use_http_auth) { |
61 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
62 net::HttpRequestHeaders headers; | 61 net::HttpRequestHeaders headers; |
63 request_->GetFullRequestHeaders(&headers); | 62 request_->GetFullRequestHeaders(&headers); |
64 if (headers.HasHeader(net::HttpRequestHeaders::kAuthorization) || | 63 if (headers.HasHeader(net::HttpRequestHeaders::kAuthorization) || |
65 !(request_->response_info().headers && | 64 !(request_->response_info().headers && |
66 data_reduction_proxy::HasDataReductionProxyViaHeader( | 65 data_reduction_proxy::HasDataReductionProxyViaHeader( |
67 request_->response_info().headers))) { | 66 request_->response_info().headers))) { |
68 return; | 67 return; |
69 } | 68 } |
70 #else | 69 |
71 return; | |
72 #endif | |
73 } | 70 } |
74 | 71 |
75 // For OMA DRM downloads, Android Download Manager doesn't handle them | 72 // For OMA DRM downloads, Android Download Manager doesn't handle them |
76 // correctly. Use chromium network stack instead. http://crbug.com/382698. | 73 // correctly. Use chromium network stack instead. http://crbug.com/382698. |
77 std::string mime; | 74 std::string mime; |
78 const_cast<net::URLRequest*>(request_)->GetMimeType(&mime); | 75 const_cast<net::URLRequest*>(request_)->GetMimeType(&mime); |
79 if (!mime.compare(kOmaDrmContentMime) || !mime.compare(kOmaDrmMessageMime)) | 76 if (!mime.compare(kOmaDrmContentMime) || !mime.compare(kOmaDrmMessageMime)) |
80 return; | 77 return; |
81 | 78 |
82 content::DownloadControllerAndroid::Get()->CreateGETDownload( | 79 content::DownloadControllerAndroid::Get()->CreateGETDownload( |
83 render_process_id_, render_view_id_, request_id_); | 80 render_process_id_, render_view_id_, request_id_); |
84 controller()->Cancel(); | 81 controller()->Cancel(); |
85 } | 82 } |
86 | 83 |
87 } // namespace chrome | 84 } // namespace chrome |
OLD | NEW |