Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: chrome/browser/android/intercept_download_resource_throttle.cc

Issue 394993002: Bypass android download manager if response is not yet received (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/android/intercept_download_resource_throttle.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 12 matching lines...) Expand all
23 int request_id) 23 int request_id)
24 : request_(request), 24 : request_(request),
25 render_process_id_(render_process_id), 25 render_process_id_(render_process_id),
26 render_view_id_(render_view_id), 26 render_view_id_(render_view_id),
27 request_id_(request_id) { 27 request_id_(request_id) {
28 } 28 }
29 29
30 InterceptDownloadResourceThrottle::~InterceptDownloadResourceThrottle() { 30 InterceptDownloadResourceThrottle::~InterceptDownloadResourceThrottle() {
31 } 31 }
32 32
33 void InterceptDownloadResourceThrottle::WillStartRequest(bool* defer) {
34 ProcessDownloadRequest();
35 }
36
37 void InterceptDownloadResourceThrottle::WillProcessResponse(bool* defer) { 33 void InterceptDownloadResourceThrottle::WillProcessResponse(bool* defer) {
38 ProcessDownloadRequest(); 34 ProcessDownloadRequest();
39 } 35 }
40 36
41 const char* InterceptDownloadResourceThrottle::GetNameForLogging() const { 37 const char* InterceptDownloadResourceThrottle::GetNameForLogging() const {
42 return "InterceptDownloadResourceThrottle"; 38 return "InterceptDownloadResourceThrottle";
43 } 39 }
44 40
45 void InterceptDownloadResourceThrottle::ProcessDownloadRequest() { 41 void InterceptDownloadResourceThrottle::ProcessDownloadRequest() {
46 if (request_->url_chain().empty()) 42 if (request_->url_chain().empty())
47 return; 43 return;
48 44
49 GURL url = request_->url_chain().back(); 45 GURL url = request_->url_chain().back();
50 if (!url.SchemeIsHTTPOrHTTPS()) 46 if (!url.SchemeIsHTTPOrHTTPS())
51 return; 47 return;
52 48
53 if (request_->method() != net::HttpRequestHeaders::kGetMethod) 49 if (request_->method() != net::HttpRequestHeaders::kGetMethod)
54 return; 50 return;
55 51
52 net::HttpRequestHeaders headers;
53 if (!request_->GetFullRequestHeaders(&headers))
54 return;
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) 61 #if defined(SPDY_PROXY_AUTH_ORIGIN)
62 net::HttpRequestHeaders headers;
63 request_->GetFullRequestHeaders(&headers);
64 if (headers.HasHeader(net::HttpRequestHeaders::kAuthorization) || 62 if (headers.HasHeader(net::HttpRequestHeaders::kAuthorization) ||
65 !(request_->response_info().headers && 63 !(request_->response_info().headers &&
66 data_reduction_proxy::HasDataReductionProxyViaHeader( 64 data_reduction_proxy::HasDataReductionProxyViaHeader(
67 request_->response_info().headers))) { 65 request_->response_info().headers))) {
68 return; 66 return;
69 } 67 }
70 #else 68 #else
71 return; 69 return;
72 #endif 70 #endif
73 } 71 }
74 72
75 // For OMA DRM downloads, Android Download Manager doesn't handle them 73 // For OMA DRM downloads, Android Download Manager doesn't handle them
76 // correctly. Use chromium network stack instead. http://crbug.com/382698. 74 // correctly. Use chromium network stack instead. http://crbug.com/382698.
77 std::string mime; 75 std::string mime;
78 const_cast<net::URLRequest*>(request_)->GetMimeType(&mime); 76 request_->GetMimeType(&mime);
79 if (!mime.compare(kOmaDrmContentMime) || !mime.compare(kOmaDrmMessageMime)) 77 if (!mime.compare(kOmaDrmContentMime) || !mime.compare(kOmaDrmMessageMime))
80 return; 78 return;
81 79
82 content::DownloadControllerAndroid::Get()->CreateGETDownload( 80 content::DownloadControllerAndroid::Get()->CreateGETDownload(
83 render_process_id_, render_view_id_, request_id_); 81 render_process_id_, render_view_id_, request_id_);
84 controller()->Cancel(); 82 controller()->Cancel();
85 } 83 }
86 84
87 } // namespace chrome 85 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/android/intercept_download_resource_throttle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698