OLD | NEW |
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/chromeos/certificate_provider/thread_safe_certificate_m
ap.h" | 5 #include "chrome/browser/chromeos/certificate_provider/thread_safe_certificate_m
ap.h" |
6 | 6 |
| 7 #include "base/memory/ptr_util.h" |
7 #include "net/base/hash_value.h" | 8 #include "net/base/hash_value.h" |
8 #include "net/cert/x509_certificate.h" | 9 #include "net/cert/x509_certificate.h" |
9 | 10 |
10 namespace chromeos { | 11 namespace chromeos { |
11 namespace certificate_provider { | 12 namespace certificate_provider { |
12 namespace { | 13 namespace { |
13 | 14 |
14 void BuildFingerprintsMap( | 15 void BuildFingerprintsMap( |
15 const std::map<std::string, certificate_provider::CertificateInfoList>& | 16 const std::map<std::string, certificate_provider::CertificateInfoList>& |
16 extension_to_certificates, | 17 extension_to_certificates, |
17 ThreadSafeCertificateMap::FingerprintToCertAndExtensionMap* | 18 ThreadSafeCertificateMap::FingerprintToCertAndExtensionMap* |
18 fingerprint_to_cert) { | 19 fingerprint_to_cert) { |
19 for (const auto& entry : extension_to_certificates) { | 20 for (const auto& entry : extension_to_certificates) { |
20 const std::string& extension_id = entry.first; | 21 const std::string& extension_id = entry.first; |
21 for (const CertificateInfo& cert_info : entry.second) { | 22 for (const CertificateInfo& cert_info : entry.second) { |
22 const net::SHA256HashValue fingerprint = | 23 const net::SHA256HashValue fingerprint = |
23 net::X509Certificate::CalculateFingerprint256( | 24 net::X509Certificate::CalculateFingerprint256( |
24 cert_info.certificate->os_cert_handle()); | 25 cert_info.certificate->os_cert_handle()); |
25 fingerprint_to_cert->insert(std::make_pair( | 26 fingerprint_to_cert->insert(std::make_pair( |
26 fingerprint, make_scoped_ptr(new ThreadSafeCertificateMap::MapValue( | 27 fingerprint, base::WrapUnique(new ThreadSafeCertificateMap::MapValue( |
27 cert_info, extension_id)))); | 28 cert_info, extension_id)))); |
28 } | 29 } |
29 } | 30 } |
30 } | 31 } |
31 | 32 |
32 } // namespace | 33 } // namespace |
33 | 34 |
34 ThreadSafeCertificateMap::MapValue::MapValue(const CertificateInfo& cert_info, | 35 ThreadSafeCertificateMap::MapValue::MapValue(const CertificateInfo& cert_info, |
35 const std::string& extension_id) | 36 const std::string& extension_id) |
36 : cert_info(cert_info), extension_id(extension_id) {} | 37 : cert_info(cert_info), extension_id(extension_id) {} |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 MapValue* const value = entry.second.get(); | 89 MapValue* const value = entry.second.get(); |
89 // Only remove the association of the fingerprint to the extension, but keep | 90 // Only remove the association of the fingerprint to the extension, but keep |
90 // the fingerprint. | 91 // the fingerprint. |
91 if (value && value->extension_id == extension_id) | 92 if (value && value->extension_id == extension_id) |
92 fingerprint_to_cert_and_extension_[entry.first] = nullptr; | 93 fingerprint_to_cert_and_extension_[entry.first] = nullptr; |
93 } | 94 } |
94 } | 95 } |
95 | 96 |
96 } // namespace certificate_provider | 97 } // namespace certificate_provider |
97 } // namespace chromeos | 98 } // namespace chromeos |
OLD | NEW |