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 "content/public/browser/android/download_controller_android.h" | 7 #include "content/public/browser/android/download_controller_android.h" |
8 #include "content/public/browser/resource_controller.h" | 8 #include "content/public/browser/resource_controller.h" |
9 #include "net/http/http_request_headers.h" | 9 #include "net/http/http_request_headers.h" |
10 #include "net/http/http_response_headers.h" | 10 #include "net/http/http_response_headers.h" |
11 #include "net/url_request/url_request.h" | 11 #include "net/url_request/url_request.h" |
12 | 12 |
13 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
14 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_settings.h" | |
15 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) | |
16 | |
17 namespace chrome { | 13 namespace chrome { |
18 | 14 |
19 InterceptDownloadResourceThrottle::InterceptDownloadResourceThrottle( | 15 InterceptDownloadResourceThrottle::InterceptDownloadResourceThrottle( |
20 net::URLRequest* request, | 16 net::URLRequest* request, |
21 int render_process_id, | 17 int render_process_id, |
22 int render_view_id, | 18 int render_view_id, |
23 int request_id) | 19 int request_id) |
24 : request_(request), | 20 : request_(request), |
25 render_process_id_(render_process_id), | 21 render_process_id_(render_process_id), |
26 render_view_id_(render_view_id), | 22 render_view_id_(render_view_id), |
(...skipping 21 matching lines...) Expand all Loading... |
48 | 44 |
49 // In general, if the request uses HTTP authorization, either with the origin | 45 // In general, if the request uses HTTP authorization, either with the origin |
50 // or a proxy, then the network stack should handle the download. The one | 46 // or a proxy, then the network stack should handle the download. The one |
51 // exception is a request that is fetched via the Chrome Proxy and does not | 47 // exception is a request that is fetched via the Chrome Proxy and does not |
52 // authenticate with the origin. | 48 // authenticate with the origin. |
53 if (request_->response_info().did_use_http_auth) { | 49 if (request_->response_info().did_use_http_auth) { |
54 #if defined(SPDY_PROXY_AUTH_ORIGIN) | 50 #if defined(SPDY_PROXY_AUTH_ORIGIN) |
55 net::HttpRequestHeaders headers; | 51 net::HttpRequestHeaders headers; |
56 request_->GetFullRequestHeaders(&headers); | 52 request_->GetFullRequestHeaders(&headers); |
57 if (headers.HasHeader(net::HttpRequestHeaders::kAuthorization) || | 53 if (headers.HasHeader(net::HttpRequestHeaders::kAuthorization) || |
58 !DataReductionProxySettings::WasFetchedViaProxy( | 54 !(request_->response_info().headers && |
59 request_->response_info().headers)) { | 55 request_->response_info().headers->IsChromeProxyResponse())) { |
60 return; | 56 return; |
61 } | 57 } |
62 #else | 58 #else |
63 return; | 59 return; |
64 #endif | 60 #endif |
65 } | 61 } |
66 | 62 |
67 if (request_->url_chain().empty()) | 63 if (request_->url_chain().empty()) |
68 return; | 64 return; |
69 | 65 |
70 GURL url = request_->url_chain().back(); | 66 GURL url = request_->url_chain().back(); |
71 if (!url.SchemeIsHTTPOrHTTPS()) | 67 if (!url.SchemeIsHTTPOrHTTPS()) |
72 return; | 68 return; |
73 | 69 |
74 content::DownloadControllerAndroid::Get()->CreateGETDownload( | 70 content::DownloadControllerAndroid::Get()->CreateGETDownload( |
75 render_process_id_, render_view_id_, request_id_); | 71 render_process_id_, render_view_id_, request_id_); |
76 controller()->Cancel(); | 72 controller()->Cancel(); |
77 } | 73 } |
78 | 74 |
79 } // namespace chrome | 75 } // namespace chrome |
OLD | NEW |