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 | 51 |
52 net::HttpRequestHeaders headers; | 52 net::HttpRequestHeaders headers; |
53 if (!request_->GetFullRequestHeaders(&headers)) | 53 if (!request_->GetFullRequestHeaders(&headers)) |
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 if (headers.HasHeader(net::HttpRequestHeaders::kAuthorization) || | 61 if (headers.HasHeader(net::HttpRequestHeaders::kAuthorization) || |
63 !(request_->response_info().headers && | 62 !(request_->response_info().headers && |
64 data_reduction_proxy::HasDataReductionProxyViaHeader( | 63 data_reduction_proxy::HasDataReductionProxyViaHeader( |
65 request_->response_info().headers))) { | 64 request_->response_info().headers))) { |
66 return; | 65 return; |
67 } | 66 } |
68 #else | 67 |
69 return; | |
70 #endif | |
71 } | 68 } |
72 | 69 |
73 // For OMA DRM downloads, Android Download Manager doesn't handle them | 70 // For OMA DRM downloads, Android Download Manager doesn't handle them |
74 // correctly. Use chromium network stack instead. http://crbug.com/382698. | 71 // correctly. Use chromium network stack instead. http://crbug.com/382698. |
75 std::string mime; | 72 std::string mime; |
76 request_->GetMimeType(&mime); | 73 request_->GetMimeType(&mime); |
77 if (!mime.compare(kOmaDrmContentMime) || !mime.compare(kOmaDrmMessageMime)) | 74 if (!mime.compare(kOmaDrmContentMime) || !mime.compare(kOmaDrmMessageMime)) |
78 return; | 75 return; |
79 | 76 |
80 content::DownloadControllerAndroid::Get()->CreateGETDownload( | 77 content::DownloadControllerAndroid::Get()->CreateGETDownload( |
81 render_process_id_, render_view_id_, request_id_); | 78 render_process_id_, render_view_id_, request_id_); |
82 controller()->Cancel(); | 79 controller()->Cancel(); |
83 } | 80 } |
84 | 81 |
85 } // namespace chrome | 82 } // namespace chrome |
OLD | NEW |