Disable view source for Developer Tools.
[chromium-blink-merge.git] / net / cert / nss_cert_database_chromeos.cc
blob936287c2204fa75f5b350540d4363d910952760e
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "net/cert/nss_cert_database_chromeos.h"
7 #include <cert.h>
8 #include <pk11pub.h>
10 #include "net/base/crypto_module.h"
11 #include "net/cert/x509_certificate.h"
13 namespace net {
15 NSSCertDatabaseChromeOS::NSSCertDatabaseChromeOS(
16 crypto::ScopedPK11Slot public_slot,
17 crypto::ScopedPK11Slot private_slot)
18 : public_slot_(public_slot.Pass()),
19 private_slot_(private_slot.Pass()) {
20 profile_filter_.Init(GetPublicSlot(), GetPrivateSlot());
23 NSSCertDatabaseChromeOS::~NSSCertDatabaseChromeOS() {}
25 void NSSCertDatabaseChromeOS::ListCerts(CertificateList* certs) {
26 NSSCertDatabase::ListCerts(certs);
28 size_t pre_size = certs->size();
29 certs->erase(std::remove_if(
30 certs->begin(),
31 certs->end(),
32 NSSProfileFilterChromeOS::CertNotAllowedForProfilePredicate(
33 profile_filter_)),
34 certs->end());
35 DVLOG(1) << "filtered " << pre_size - certs->size() << " of " << pre_size
36 << " certs";
39 crypto::ScopedPK11Slot NSSCertDatabaseChromeOS::GetPublicSlot() const {
40 return crypto::ScopedPK11Slot(
41 public_slot_ ? PK11_ReferenceSlot(public_slot_.get()) : NULL);
44 crypto::ScopedPK11Slot NSSCertDatabaseChromeOS::GetPrivateSlot() const {
45 return crypto::ScopedPK11Slot(
46 private_slot_ ? PK11_ReferenceSlot(private_slot_.get()) : NULL);
49 void NSSCertDatabaseChromeOS::ListModules(CryptoModuleList* modules,
50 bool need_rw) const {
51 NSSCertDatabase::ListModules(modules, need_rw);
53 size_t pre_size = modules->size();
54 modules->erase(
55 std::remove_if(
56 modules->begin(),
57 modules->end(),
58 NSSProfileFilterChromeOS::ModuleNotAllowedForProfilePredicate(
59 profile_filter_)),
60 modules->end());
61 DVLOG(1) << "filtered " << pre_size - modules->size() << " of " << pre_size
62 << " modules";
65 } // namespace net