| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "content/renderer/media/rtc_certificate.h" | 5 #include "content/renderer/media/rtc_certificate.h" |
| 6 | 6 |
| 7 #include <vector> |
| 8 |
| 7 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/strings/string_util.h" |
| 11 #include "third_party/webrtc/base/sslidentity.h" |
| 8 #include "url/gurl.h" | 12 #include "url/gurl.h" |
| 9 | 13 |
| 10 namespace content { | 14 namespace content { |
| 11 | 15 |
| 12 RTCCertificate::RTCCertificate( | 16 RTCCertificate::RTCCertificate( |
| 13 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) | 17 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) |
| 14 : certificate_(certificate) { | 18 : certificate_(certificate) { |
| 15 DCHECK(certificate_); | 19 DCHECK(certificate_); |
| 16 } | 20 } |
| 17 | 21 |
| 18 RTCCertificate::~RTCCertificate() { | 22 RTCCertificate::~RTCCertificate() { |
| 19 } | 23 } |
| 20 | 24 |
| 21 std::unique_ptr<blink::WebRTCCertificate> RTCCertificate::ShallowCopy() const { | 25 std::unique_ptr<blink::WebRTCCertificate> RTCCertificate::ShallowCopy() const { |
| 22 return base::WrapUnique(new RTCCertificate(certificate_)); | 26 return base::WrapUnique(new RTCCertificate(certificate_)); |
| 23 } | 27 } |
| 24 | 28 |
| 25 uint64_t RTCCertificate::Expires() const { | 29 uint64_t RTCCertificate::Expires() const { |
| 26 return certificate_->Expires(); | 30 return certificate_->Expires(); |
| 27 } | 31 } |
| 28 | 32 |
| 33 blink::WebVector<blink::WebRTCDtlsFingerprint> RTCCertificate::GetFingerprints() |
| 34 const { |
| 35 std::vector<blink::WebRTCDtlsFingerprint> fingerprints; |
| 36 std::unique_ptr<rtc::SSLCertificateStats> first_certificate_stats = |
| 37 certificate_->identity()->certificate().GetStats(); |
| 38 for (rtc::SSLCertificateStats* certificate_stats = |
| 39 first_certificate_stats.get(); |
| 40 certificate_stats; certificate_stats = certificate_stats->issuer.get()) { |
| 41 fingerprints.push_back(blink::WebRTCDtlsFingerprint( |
| 42 blink::WebString::FromUTF8(certificate_stats->fingerprint_algorithm), |
| 43 blink::WebString::FromUTF8( |
| 44 base::ToLowerASCII(certificate_stats->fingerprint)))); |
| 45 } |
| 46 return blink::WebVector<blink::WebRTCDtlsFingerprint>(fingerprints); |
| 47 } |
| 48 |
| 29 blink::WebRTCCertificatePEM RTCCertificate::ToPEM() const { | 49 blink::WebRTCCertificatePEM RTCCertificate::ToPEM() const { |
| 30 rtc::RTCCertificatePEM pem = certificate_->ToPEM(); | 50 rtc::RTCCertificatePEM pem = certificate_->ToPEM(); |
| 31 return blink::WebRTCCertificatePEM( | 51 return blink::WebRTCCertificatePEM( |
| 32 blink::WebString::FromUTF8(pem.private_key()), | 52 blink::WebString::FromUTF8(pem.private_key()), |
| 33 blink::WebString::FromUTF8(pem.certificate())); | 53 blink::WebString::FromUTF8(pem.certificate())); |
| 34 } | 54 } |
| 35 | 55 |
| 36 bool RTCCertificate::Equals(const blink::WebRTCCertificate& other) const { | 56 bool RTCCertificate::Equals(const blink::WebRTCCertificate& other) const { |
| 37 return *certificate_ == | 57 return *certificate_ == |
| 38 *static_cast<const RTCCertificate&>(other).certificate_; | 58 *static_cast<const RTCCertificate&>(other).certificate_; |
| 39 } | 59 } |
| 40 | 60 |
| 41 const rtc::scoped_refptr<rtc::RTCCertificate>& | 61 const rtc::scoped_refptr<rtc::RTCCertificate>& |
| 42 RTCCertificate::rtcCertificate() const { | 62 RTCCertificate::rtcCertificate() const { |
| 43 return certificate_; | 63 return certificate_; |
| 44 } | 64 } |
| 45 | 65 |
| 46 } // namespace content | 66 } // namespace content |
| OLD | NEW |