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

Side by Side Diff: chrome/browser/net/certificate_error_reporter.cc

Issue 935663004: Add checkbox for reporting invalid TLS/SSL cert chains (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix comment typo Created 5 years, 9 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/net/certificate_error_reporter.h" 5 #include "chrome/browser/net/certificate_error_reporter.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/weak_ptr.h"
10 #include "base/stl_util.h" 11 #include "base/stl_util.h"
11 #include "base/time/time.h" 12 #include "base/time/time.h"
12 #include "chrome/browser/net/cert_logger.pb.h" 13 #include "chrome/browser/net/cert_logger.pb.h"
13 #include "net/base/elements_upload_data_stream.h" 14 #include "net/base/elements_upload_data_stream.h"
14 #include "net/base/load_flags.h" 15 #include "net/base/load_flags.h"
15 #include "net/base/request_priority.h" 16 #include "net/base/request_priority.h"
16 #include "net/base/upload_bytes_element_reader.h" 17 #include "net/base/upload_bytes_element_reader.h"
17 #include "net/cert/x509_certificate.h" 18 #include "net/cert/x509_certificate.h"
18 #include "net/ssl/ssl_info.h" 19 #include "net/ssl/ssl_info.h"
19 #include "net/url_request/url_request_context.h" 20 #include "net/url_request/url_request_context.h"
20 21
21 namespace chrome_browser_net { 22 namespace chrome_browser_net {
22 23
24 // URL to upload invalid certificate chain reports
25 // TODO(estark): Fill this in with the real URL when live.
26 const char kExtendedReportingUploadUrl[] = "http://example.test";
27
23 CertificateErrorReporter::CertificateErrorReporter( 28 CertificateErrorReporter::CertificateErrorReporter(
24 net::URLRequestContext* request_context, 29 net::URLRequestContext* request_context,
25 const GURL& upload_url) 30 const GURL& upload_url)
26 : request_context_(request_context), upload_url_(upload_url) { 31 : request_context_(request_context),
32 upload_url_(upload_url),
33 weak_ptr_factory_(this) {
27 DCHECK(!upload_url.is_empty()); 34 DCHECK(!upload_url.is_empty());
28 } 35 }
29 36
30 CertificateErrorReporter::~CertificateErrorReporter() { 37 CertificateErrorReporter::~CertificateErrorReporter() {
31 STLDeleteElements(&inflight_requests_); 38 STLDeleteElements(&inflight_requests_);
32 } 39 }
33 40
34 void CertificateErrorReporter::SendReport(ReportType type, 41 void CertificateErrorReporter::SendReport(ReportType type,
35 const std::string& hostname, 42 const std::string& hostname,
36 const net::SSLInfo& ssl_info) { 43 const net::SSLInfo& ssl_info) {
(...skipping 28 matching lines...) Expand all
65 LOG(WARNING) << "Certificate upload HTTP status: " 72 LOG(WARNING) << "Certificate upload HTTP status: "
66 << request->GetResponseCode(); 73 << request->GetResponseCode();
67 } 74 }
68 RequestComplete(request); 75 RequestComplete(request);
69 } 76 }
70 77
71 void CertificateErrorReporter::OnReadCompleted(net::URLRequest* request, 78 void CertificateErrorReporter::OnReadCompleted(net::URLRequest* request,
72 int bytes_read) { 79 int bytes_read) {
73 } 80 }
74 81
82 base::WeakPtr<CertificateErrorReporter> CertificateErrorReporter::GetWeakPtr() {
83 return weak_ptr_factory_.GetWeakPtr();
84 }
85
75 scoped_ptr<net::URLRequest> CertificateErrorReporter::CreateURLRequest( 86 scoped_ptr<net::URLRequest> CertificateErrorReporter::CreateURLRequest(
76 net::URLRequestContext* context) { 87 net::URLRequestContext* context) {
77 scoped_ptr<net::URLRequest> request = 88 scoped_ptr<net::URLRequest> request =
78 context->CreateRequest(upload_url_, net::DEFAULT_PRIORITY, this, NULL); 89 context->CreateRequest(upload_url_, net::DEFAULT_PRIORITY, this, NULL);
79 request->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | 90 request->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
80 net::LOAD_DO_NOT_SAVE_COOKIES); 91 net::LOAD_DO_NOT_SAVE_COOKIES);
81 return request.Pass(); 92 return request.Pass();
82 } 93 }
83 94
84 void CertificateErrorReporter::SendCertLoggerRequest( 95 void CertificateErrorReporter::SendCertLoggerRequest(
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 } 134 }
124 135
125 void CertificateErrorReporter::RequestComplete(net::URLRequest* request) { 136 void CertificateErrorReporter::RequestComplete(net::URLRequest* request) {
126 std::set<net::URLRequest*>::iterator i = inflight_requests_.find(request); 137 std::set<net::URLRequest*>::iterator i = inflight_requests_.find(request);
127 DCHECK(i != inflight_requests_.end()); 138 DCHECK(i != inflight_requests_.end());
128 scoped_ptr<net::URLRequest> url_request(*i); 139 scoped_ptr<net::URLRequest> url_request(*i);
129 inflight_requests_.erase(i); 140 inflight_requests_.erase(i);
130 } 141 }
131 142
132 } // namespace chrome_browser_net 143 } // namespace chrome_browser_net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698