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

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: addressing comments 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 | « no previous file | 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 13 matching lines...) Expand all
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) { 33 void InterceptDownloadResourceThrottle::WillStartRequest(bool* defer) {
34 ProcessDownloadRequest();
35 } 34 }
asanka 2014/07/16 19:14:18 Nit: You can remove the implementation here and in
qinmin 2014/07/16 19:18:19 Done.
36 35
37 void InterceptDownloadResourceThrottle::WillProcessResponse(bool* defer) { 36 void InterceptDownloadResourceThrottle::WillProcessResponse(bool* defer) {
38 ProcessDownloadRequest(); 37 ProcessDownloadRequest();
39 } 38 }
40 39
41 const char* InterceptDownloadResourceThrottle::GetNameForLogging() const { 40 const char* InterceptDownloadResourceThrottle::GetNameForLogging() const {
42 return "InterceptDownloadResourceThrottle"; 41 return "InterceptDownloadResourceThrottle";
43 } 42 }
44 43
45 void InterceptDownloadResourceThrottle::ProcessDownloadRequest() { 44 void InterceptDownloadResourceThrottle::ProcessDownloadRequest() {
46 if (request_->url_chain().empty()) 45 if (request_->url_chain().empty())
47 return; 46 return;
48 47
49 GURL url = request_->url_chain().back(); 48 GURL url = request_->url_chain().back();
50 if (!url.SchemeIsHTTPOrHTTPS()) 49 if (!url.SchemeIsHTTPOrHTTPS())
51 return; 50 return;
52 51
53 if (request_->method() != net::HttpRequestHeaders::kGetMethod) 52 if (request_->method() != net::HttpRequestHeaders::kGetMethod)
54 return; 53 return;
55 54
55 net::HttpRequestHeaders headers;
56 if (!request_->GetFullRequestHeaders(&headers))
57 return;
58
56 // In general, if the request uses HTTP authorization, either with the origin 59 // 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 60 // 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 61 // exception is a request that is fetched via the Chrome Proxy and does not
59 // authenticate with the origin. 62 // authenticate with the origin.
60 if (request_->response_info().did_use_http_auth) { 63 if (request_->response_info().did_use_http_auth) {
61 #if defined(SPDY_PROXY_AUTH_ORIGIN) 64 #if defined(SPDY_PROXY_AUTH_ORIGIN)
62 net::HttpRequestHeaders headers;
63 request_->GetFullRequestHeaders(&headers);
64 if (headers.HasHeader(net::HttpRequestHeaders::kAuthorization) || 65 if (headers.HasHeader(net::HttpRequestHeaders::kAuthorization) ||
65 !(request_->response_info().headers && 66 !(request_->response_info().headers &&
66 data_reduction_proxy::HasDataReductionProxyViaHeader( 67 data_reduction_proxy::HasDataReductionProxyViaHeader(
67 request_->response_info().headers))) { 68 request_->response_info().headers))) {
68 return; 69 return;
69 } 70 }
70 #else 71 #else
71 return; 72 return;
72 #endif 73 #endif
73 } 74 }
74 75
75 // For OMA DRM downloads, Android Download Manager doesn't handle them 76 // For OMA DRM downloads, Android Download Manager doesn't handle them
76 // correctly. Use chromium network stack instead. http://crbug.com/382698. 77 // correctly. Use chromium network stack instead. http://crbug.com/382698.
77 std::string mime; 78 std::string mime;
78 const_cast<net::URLRequest*>(request_)->GetMimeType(&mime); 79 request_->GetMimeType(&mime);
79 if (!mime.compare(kOmaDrmContentMime) || !mime.compare(kOmaDrmMessageMime)) 80 if (!mime.compare(kOmaDrmContentMime) || !mime.compare(kOmaDrmMessageMime))
80 return; 81 return;
81 82
82 content::DownloadControllerAndroid::Get()->CreateGETDownload( 83 content::DownloadControllerAndroid::Get()->CreateGETDownload(
83 render_process_id_, render_view_id_, request_id_); 84 render_process_id_, render_view_id_, request_id_);
84 controller()->Cancel(); 85 controller()->Cancel();
85 } 86 }
86 87
87 } // namespace chrome 88 } // namespace chrome
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698