| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ssl/chrome_expect_ct_reporter.h" | 5 #include "chrome/browser/ssl/chrome_expect_ct_reporter.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 t.UTCExplode(&exploded); | 26 t.UTCExplode(&exploded); |
| 27 return base::StringPrintf( | 27 return base::StringPrintf( |
| 28 "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", exploded.year, exploded.month, | 28 "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", exploded.year, exploded.month, |
| 29 exploded.day_of_month, exploded.hour, exploded.minute, exploded.second, | 29 exploded.day_of_month, exploded.hour, exploded.minute, exploded.second, |
| 30 exploded.millisecond); | 30 exploded.millisecond); |
| 31 } | 31 } |
| 32 | 32 |
| 33 std::unique_ptr<base::ListValue> GetPEMEncodedChainAsList( | 33 std::unique_ptr<base::ListValue> GetPEMEncodedChainAsList( |
| 34 const net::X509Certificate* cert_chain) { | 34 const net::X509Certificate* cert_chain) { |
| 35 if (!cert_chain) | 35 if (!cert_chain) |
| 36 return base::WrapUnique(new base::ListValue()); | 36 return base::MakeUnique<base::ListValue>(); |
| 37 | 37 |
| 38 std::unique_ptr<base::ListValue> result(new base::ListValue()); | 38 std::unique_ptr<base::ListValue> result(new base::ListValue()); |
| 39 std::vector<std::string> pem_encoded_chain; | 39 std::vector<std::string> pem_encoded_chain; |
| 40 cert_chain->GetPEMEncodedChain(&pem_encoded_chain); | 40 cert_chain->GetPEMEncodedChain(&pem_encoded_chain); |
| 41 for (const std::string& cert : pem_encoded_chain) | 41 for (const std::string& cert : pem_encoded_chain) |
| 42 result->Append(base::WrapUnique(new base::StringValue(cert))); | 42 result->Append(base::MakeUnique<base::StringValue>(cert)); |
| 43 | 43 |
| 44 return result; | 44 return result; |
| 45 } | 45 } |
| 46 | 46 |
| 47 std::string SCTOriginToString( | 47 std::string SCTOriginToString( |
| 48 net::ct::SignedCertificateTimestamp::Origin origin) { | 48 net::ct::SignedCertificateTimestamp::Origin origin) { |
| 49 switch (origin) { | 49 switch (origin) { |
| 50 case net::ct::SignedCertificateTimestamp::SCT_EMBEDDED: | 50 case net::ct::SignedCertificateTimestamp::SCT_EMBEDDED: |
| 51 return "embedded"; | 51 return "embedded"; |
| 52 case net::ct::SignedCertificateTimestamp::SCT_FROM_TLS_EXTENSION: | 52 case net::ct::SignedCertificateTimestamp::SCT_FROM_TLS_EXTENSION: |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 std::string serialized_report; | 172 std::string serialized_report; |
| 173 if (!base::JSONWriter::Write(report, &serialized_report)) { | 173 if (!base::JSONWriter::Write(report, &serialized_report)) { |
| 174 LOG(ERROR) << "Failed to serialize Expect CT report"; | 174 LOG(ERROR) << "Failed to serialize Expect CT report"; |
| 175 return; | 175 return; |
| 176 } | 176 } |
| 177 | 177 |
| 178 UMA_HISTOGRAM_BOOLEAN("SSL.ExpectCTReportSendingAttempt", true); | 178 UMA_HISTOGRAM_BOOLEAN("SSL.ExpectCTReportSendingAttempt", true); |
| 179 | 179 |
| 180 report_sender_->Send(report_uri, serialized_report); | 180 report_sender_->Send(report_uri, serialized_report); |
| 181 } | 181 } |
| OLD | NEW |