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

Unified Diff: content/browser/download/download_resource_handler.cc

Issue 351863002: Added SERVER_UNAUTHORIZED download interrupt reason. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added new download interrupt reason SERVER_CERT_PROBLEM. Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/download/download_resource_handler.cc
diff --git a/content/browser/download/download_resource_handler.cc b/content/browser/download/download_resource_handler.cc
index 0a19163c9c3f8ae40a9532e13780c89acac15fab..e24914043d268632599fea825caa20483bc552dc 100644
--- a/content/browser/download/download_resource_handler.cc
+++ b/content/browser/download/download_resource_handler.cc
@@ -20,6 +20,7 @@
#include "content/browser/download/download_stats.h"
#include "content/browser/loader/resource_dispatcher_host_impl.h"
#include "content/browser/loader/resource_request_info_impl.h"
+#include "content/common/ssl_status_serialization.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/download_interrupt_reasons.h"
#include "content/public/browser/download_item.h"
@@ -97,6 +98,22 @@ void InitializeDownloadTabInfoOnUIThread(
}
}
+bool IsSSLCertificateError(const std::string& security_info) {
+ int ssl_cert_id;
+ net::CertStatus ssl_cert_status;
+ int ssl_security_bits;
+ int ssl_connection_status;
+ SignedCertificateTimestampIDStatusList ssl_signed_certificate_timestamp_ids;
+ if (!DeserializeSecurityInfo(security_info,
+ &ssl_cert_id,
+ &ssl_cert_status,
+ &ssl_security_bits,
+ &ssl_connection_status,
+ &ssl_signed_certificate_timestamp_ids))
asanka 2014/07/11 18:13:53 Nit: Formatting seems off. "git cl format" ? Note
+ return false;
+ return net::IsCertStatusError(ssl_cert_status);
+}
+
} // namespace
const int DownloadResourceHandler::kDownloadByteStreamSize = 100 * 1024;
@@ -383,7 +400,10 @@ void DownloadResourceHandler::OnResponseCompleted(
// to a user action.
// TODO(ahendrickson) -- Find a better set of codes to use here, as
// CANCELED/ERR_ABORTED can occur for reasons other than user cancel.
- reason = DOWNLOAD_INTERRUPT_REASON_USER_CANCELED;
+ if (IsSSLCertificateError(security_info))
asanka 2014/07/11 18:13:53 if (net::IsCertStatusError(request()->ssl_info().c
+ reason = DOWNLOAD_INTERRUPT_REASON_SERVER_CERT_PROBLEM;
+ else
+ reason = DOWNLOAD_INTERRUPT_REASON_USER_CANCELED;
}
if (status.is_success() &&
@@ -414,6 +434,10 @@ void DownloadResourceHandler::OnResponseCompleted(
// If we haven't received data when we get this error, we won't.
reason = DOWNLOAD_INTERRUPT_REASON_SERVER_NO_RANGE;
break;
+ case net::HTTP_UNAUTHORIZED:
+ // Server didn't authorize this request.
+ reason = DOWNLOAD_INTERRUPT_REASON_SERVER_UNAUTHORIZED;
+ break;
default: // All other errors.
// Redirection and informational codes should have been handled earlier
// in the stack.

Powered by Google App Engine
This is Rietveld 408576698