Commit 144eb284 authored by qinmin@chromium.org's avatar qinmin@chromium.org

Bypass android download manager if response is not yet received

When the InterceptDownloadResourceThrottle intercepts the download request, the response might not have been received yet.
As a result, we are not sure about the mime type and and other file informations.
Using android Download Manager at this stage is premature and risky.
This change bypasses android download manager in this case.

BUG=394092

Review URL: https://codereview.chromium.org/394993002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283748 0039d316-1c4b-4281-b951-d872f2087c98
parent a72d418f
......@@ -30,10 +30,6 @@ InterceptDownloadResourceThrottle::InterceptDownloadResourceThrottle(
InterceptDownloadResourceThrottle::~InterceptDownloadResourceThrottle() {
}
void InterceptDownloadResourceThrottle::WillStartRequest(bool* defer) {
ProcessDownloadRequest();
}
void InterceptDownloadResourceThrottle::WillProcessResponse(bool* defer) {
ProcessDownloadRequest();
}
......@@ -53,14 +49,16 @@ void InterceptDownloadResourceThrottle::ProcessDownloadRequest() {
if (request_->method() != net::HttpRequestHeaders::kGetMethod)
return;
net::HttpRequestHeaders headers;
if (!request_->GetFullRequestHeaders(&headers))
return;
// In general, if the request uses HTTP authorization, either with the origin
// or a proxy, then the network stack should handle the download. The one
// exception is a request that is fetched via the Chrome Proxy and does not
// authenticate with the origin.
if (request_->response_info().did_use_http_auth) {
#if defined(SPDY_PROXY_AUTH_ORIGIN)
net::HttpRequestHeaders headers;
request_->GetFullRequestHeaders(&headers);
if (headers.HasHeader(net::HttpRequestHeaders::kAuthorization) ||
!(request_->response_info().headers &&
data_reduction_proxy::HasDataReductionProxyViaHeader(
......@@ -75,7 +73,7 @@ void InterceptDownloadResourceThrottle::ProcessDownloadRequest() {
// For OMA DRM downloads, Android Download Manager doesn't handle them
// correctly. Use chromium network stack instead. http://crbug.com/382698.
std::string mime;
const_cast<net::URLRequest*>(request_)->GetMimeType(&mime);
request_->GetMimeType(&mime);
if (!mime.compare(kOmaDrmContentMime) || !mime.compare(kOmaDrmMessageMime))
return;
......
......@@ -25,7 +25,6 @@ class InterceptDownloadResourceThrottle : public content::ResourceThrottle {
int request_id);
// content::ResourceThrottle implementation:
virtual void WillStartRequest(bool* defer) OVERRIDE;
virtual void WillProcessResponse(bool* defer) OVERRIDE;
virtual const char* GetNameForLogging() const OVERRIDE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment