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

Unified Diff: chrome/browser/net/certificate_error_reporter.cc

Issue 1076273002: Add interstitial info to certificate reports (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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: chrome/browser/net/certificate_error_reporter.cc
diff --git a/chrome/browser/net/certificate_error_reporter.cc b/chrome/browser/net/certificate_error_reporter.cc
index 15dad135b373587ed318c3ac384c801275367e4b..702d19a783982b38b255c77dfc54ca7d5d0430fb 100644
--- a/chrome/browser/net/certificate_error_reporter.cc
+++ b/chrome/browser/net/certificate_error_reporter.cc
@@ -37,63 +37,26 @@ CertificateErrorReporter::~CertificateErrorReporter() {
void CertificateErrorReporter::SendReport(ReportType type,
const std::string& hostname,
const net::SSLInfo& ssl_info) {
- CertLoggerRequest request;
- std::string out;
-
- BuildReport(hostname, ssl_info, &request);
-
- switch (type) {
- case REPORT_TYPE_PINNING_VIOLATION:
- SendCertLoggerRequest(request);
- break;
- case REPORT_TYPE_EXTENDED_REPORTING:
- // TODO(estark): Encrypt the report if not sending over HTTPS
- DCHECK(upload_url_.SchemeIsSecure());
- SendCertLoggerRequest(request);
- break;
- default:
- NOTREACHED();
- }
-}
-
-void CertificateErrorReporter::OnResponseStarted(net::URLRequest* request) {
- const net::URLRequestStatus& status(request->status());
- if (!status.is_success()) {
- LOG(WARNING) << "Certificate upload failed"
- << " status:" << status.status()
- << " error:" << status.error();
- } else if (request->GetResponseCode() != 200) {
- LOG(WARNING) << "Certificate upload HTTP status: "
- << request->GetResponseCode();
- }
- RequestComplete(request);
-}
-
-void CertificateErrorReporter::OnReadCompleted(net::URLRequest* request,
- int bytes_read) {
+ CertLoggerRequest report;
+ BuildReport(hostname, ssl_info, &report);
+ SendReport(type, report);
}
-scoped_ptr<net::URLRequest> CertificateErrorReporter::CreateURLRequest(
- net::URLRequestContext* context) {
- scoped_ptr<net::URLRequest> request =
- context->CreateRequest(upload_url_, net::DEFAULT_PRIORITY, this);
- if (cookies_preference_ != SEND_COOKIES) {
- request->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
- net::LOAD_DO_NOT_SAVE_COOKIES);
- }
- return request.Pass();
+void CertificateErrorReporter::SendReport(ReportType type,
+ const CertLoggerRequest& report) {
+ if (type == REPORT_TYPE_EXTENDED_REPORTING) {
+ // TODO(estark): Encrypt the report if not sending over HTTPS
Ryan Sleevi 2015/04/16 01:44:10 FWIW, a tracking bug for this is handy, even if it
+ DCHECK(upload_url_.SchemeIsSecure());
}
-void CertificateErrorReporter::SendCertLoggerRequest(
- const CertLoggerRequest& request) {
- std::string serialized_request;
- request.SerializeToString(&serialized_request);
+std::string serialized_report;
+report.SerializeToString(&serialized_report);
scoped_ptr<net::URLRequest> url_request = CreateURLRequest(request_context_);
url_request->set_method("POST");
scoped_ptr<net::UploadElementReader> reader(
- net::UploadOwnedBytesElementReader::CreateWithString(serialized_request));
+ net::UploadOwnedBytesElementReader::CreateWithString(serialized_report));
url_request->set_upload(
net::ElementsUploadDataStream::CreateWithReader(reader.Pass(), 0));
@@ -107,6 +70,41 @@ void CertificateErrorReporter::SendCertLoggerRequest(
raw_url_request->Start();
}
+void CertificateErrorReporter::OnResponseStarted(net::URLRequest* request) {
+ const net::URLRequestStatus& status(request->status());
+ if (!status.is_success()) {
+ LOG(WARNING) << "Certificate upload failed"
+ << " status:" << status.status()
+ << " error:" << status.error();
+ } else if (request->GetResponseCode() != 200) {
+ LOG(WARNING) << "Certificate upload HTTP status: "
+ << request->GetResponseCode();
+ }
+ RequestComplete(request);
+}
+
+void CertificateErrorReporter::OnReadCompleted(net::URLRequest* request,
+ int bytes_read) {
+}
+
+void CertificateErrorReporter::BuildReport(const std::string& hostname,
+ const net::SSLInfo& ssl_info,
+ uint32 validation_result,
+ uint32 interstitial_reason,
+ ProceedDecision proceed_decision,
+ Overridable overridable,
+ CertLoggerRequest* out_request) {
+ BuildReport(hostname, ssl_info, out_request);
+ out_request->mutable_interstitial_info()->set_validation_result(
+ validation_result);
+ out_request->mutable_interstitial_info()->set_interstitial_reason(
+ interstitial_reason);
+ out_request->mutable_interstitial_info()->set_user_proceeded(
+ proceed_decision == USER_PROCEEDED);
+ out_request->mutable_interstitial_info()->set_overridable(overridable ==
+ OVERRIDABLE);
+}
+
void CertificateErrorReporter::BuildReport(const std::string& hostname,
const net::SSLInfo& ssl_info,
CertLoggerRequest* out_request) {
@@ -125,6 +123,21 @@ void CertificateErrorReporter::BuildReport(const std::string& hostname,
out_request->add_pin(ssl_info.pinning_failure_log);
}
+scoped_ptr<net::URLRequest> CertificateErrorReporter::CreateURLRequest(
+ net::URLRequestContext* context) {
+ scoped_ptr<net::URLRequest> request =
+ context->CreateRequest(upload_url_, net::DEFAULT_PRIORITY, this);
+ if (cookies_preference_ != SEND_COOKIES) {
+ request->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
+ net::LOAD_DO_NOT_SAVE_COOKIES);
+ }
+ return request.Pass();
+}
+
+void CertificateErrorReporter::SendCertLoggerRequest(
+ const CertLoggerRequest& request) {
+}
Ryan Sleevi 2015/04/16 01:44:10 Dead code? Broken?
+
void CertificateErrorReporter::RequestComplete(net::URLRequest* request) {
std::set<net::URLRequest*>::iterator i = inflight_requests_.find(request);
DCHECK(i != inflight_requests_.end());

Powered by Google App Engine
This is Rietveld 408576698