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

Side by Side Diff: chrome/browser/ssl/chrome_fraudulent_certificate_reporter.cc

Issue 1117173004: Split cert reporter class into report building/serializing and sending (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: document parse/serialize return value Created 5 years, 7 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 (c) 2012 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/chrome_fraudulent_certificate_reporter.h" 5 #include "chrome/browser/ssl/chrome_fraudulent_certificate_reporter.h"
6 6
7 #include "base/profiler/scoped_tracker.h" 7 #include "base/profiler/scoped_tracker.h"
8 #include "chrome/browser/net/certificate_error_reporter.h" 8 #include "chrome/browser/net/certificate_error_reporter.h"
9 #include "chrome/browser/ssl/certificate_error_report.h"
9 #include "net/ssl/ssl_info.h" 10 #include "net/ssl/ssl_info.h"
10 #include "net/url_request/url_request_context.h" 11 #include "net/url_request/url_request_context.h"
11 #include "url/gurl.h" 12 #include "url/gurl.h"
12 13
13 namespace { 14 namespace {
14 15
15 // TODO(palmer): Switch to HTTPS when the error handling delegate is more 16 // TODO(palmer): Switch to HTTPS when the error handling delegate is more
16 // sophisticated. Ultimately we plan to attempt the report on many transports. 17 // sophisticated. Ultimately we plan to attempt the report on many transports.
17 const char kFraudulentCertificateUploadEndpoint[] = 18 const char kFraudulentCertificateUploadEndpoint[] =
18 "http://clients3.google.com/log_cert_error"; 19 "http://clients3.google.com/log_cert_error";
19 20
20 } // namespace 21 } // namespace
21 22
22 namespace chrome_browser_net { 23 namespace chrome_browser_ssl {
23 24
24 ChromeFraudulentCertificateReporter::ChromeFraudulentCertificateReporter( 25 ChromeFraudulentCertificateReporter::ChromeFraudulentCertificateReporter(
25 net::URLRequestContext* request_context) 26 net::URLRequestContext* request_context)
26 : certificate_reporter_(new CertificateErrorReporter( 27 : certificate_reporter_(new chrome_browser_net::CertificateErrorReporter(
27 request_context, 28 request_context,
28 GURL(kFraudulentCertificateUploadEndpoint), 29 GURL(kFraudulentCertificateUploadEndpoint),
29 CertificateErrorReporter::DO_NOT_SEND_COOKIES)) { 30 chrome_browser_net::CertificateErrorReporter::DO_NOT_SEND_COOKIES)) {
30 } 31 }
31 32
32 ChromeFraudulentCertificateReporter::ChromeFraudulentCertificateReporter( 33 ChromeFraudulentCertificateReporter::ChromeFraudulentCertificateReporter(
33 scoped_ptr<CertificateErrorReporter> certificate_reporter) 34 scoped_ptr<chrome_browser_net::CertificateErrorReporter>
35 certificate_reporter)
34 : certificate_reporter_(certificate_reporter.Pass()) { 36 : certificate_reporter_(certificate_reporter.Pass()) {
35 } 37 }
36 38
37 ChromeFraudulentCertificateReporter::~ChromeFraudulentCertificateReporter() { 39 ChromeFraudulentCertificateReporter::~ChromeFraudulentCertificateReporter() {
38 } 40 }
39 41
40 void ChromeFraudulentCertificateReporter::SendReport( 42 void ChromeFraudulentCertificateReporter::SendReport(
41 const std::string& hostname, 43 const std::string& hostname,
42 const net::SSLInfo& ssl_info) { 44 const net::SSLInfo& ssl_info) {
43 // Do silent/automatic reporting ONLY for Google properties. For other 45 // Do silent/automatic reporting ONLY for Google properties. For other
44 // domains (when that is supported), Chrome will ask for user permission. 46 // domains (when that is supported), Chrome will ask for user permission.
45 if (!net::TransportSecurityState::IsGooglePinnedProperty(hostname)) 47 if (!net::TransportSecurityState::IsGooglePinnedProperty(hostname))
46 return; 48 return;
47 49
48 certificate_reporter_->SendReport( 50 CertificateErrorReport report(hostname, ssl_info);
49 CertificateErrorReporter::REPORT_TYPE_PINNING_VIOLATION, hostname, 51 std::string serialized_report;
50 ssl_info); 52 if (report.Serialize(&serialized_report)) {
53 certificate_reporter_->SendReport(
54 chrome_browser_net::CertificateErrorReporter::
55 REPORT_TYPE_PINNING_VIOLATION,
56 serialized_report);
57 } else {
58 LOG(ERROR) << "Failed to serialize pinning violation report.";
59 }
Ryan Sleevi 2015/05/13 01:02:12 In general, we prefer error handling first if (!r
estark 2015/05/13 01:44:49 Done.
51 } 60 }
52 61
53 } // namespace chrome_browser_net 62 } // namespace chrome_browser_ssl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698