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

Side by Side Diff: net/cert/nss_cert_database.cc

Issue 214863002: Extension API enterprise.platformKeys. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Enabled restriction to extensions force-installed by policy. Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/cert/nss_cert_database.h" 5 #include "net/cert/nss_cert_database.h"
6 6
7 #include <cert.h> 7 #include <cert.h>
8 #include <certdb.h> 8 #include <certdb.h>
9 #include <keyhi.h> 9 #include <keyhi.h>
10 #include <pk11pub.h> 10 #include <pk11pub.h>
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 NSSCertDatabase::~NSSCertDatabase() {} 75 NSSCertDatabase::~NSSCertDatabase() {}
76 76
77 void NSSCertDatabase::ListCertsSync(CertificateList* certs) { 77 void NSSCertDatabase::ListCertsSync(CertificateList* certs) {
78 ListCertsImpl(certs); 78 ListCertsImpl(certs);
79 } 79 }
80 80
81 void NSSCertDatabase::ListCerts( 81 void NSSCertDatabase::ListCerts(
82 const base::Callback<void(scoped_ptr<CertificateList> certs)>& callback) { 82 const base::Callback<void(scoped_ptr<CertificateList> certs)>& callback) {
83 scoped_ptr<CertificateList> certs(new CertificateList()); 83 scoped_ptr<CertificateList> certs(new CertificateList());
84 84
85 // base::Pased will NULL out |certs|, so cache the underlying pointer here. 85 // base::Passed will NULL out |certs|, so cache the underlying pointer here.
86 CertificateList* raw_certs = certs.get(); 86 CertificateList* raw_certs = certs.get();
87 GetSlowTaskRunner()->PostTaskAndReply( 87 GetSlowTaskRunner()->PostTaskAndReply(
88 FROM_HERE, 88 FROM_HERE,
89 base::Bind(&NSSCertDatabase::ListCertsImpl, 89 base::Bind(&NSSCertDatabase::ListCertsImpl,
90 base::Unretained(raw_certs)), 90 base::Unretained(raw_certs)),
91 base::Bind(callback, base::Passed(&certs))); 91 base::Bind(callback, base::Passed(&certs)));
92 } 92 }
93 93
94 void NSSCertDatabase::ListCertsInSlot(const ListCertsCallback& callback,
95 PK11SlotInfo* slot) {
96 DCHECK(slot);
97 scoped_ptr<CertificateList> certs(new CertificateList());
98
99 // base::Passed will NULL out |certs|, so cache the underlying pointer here.
100 CertificateList* raw_certs = certs.get();
101 GetSlowTaskRunner()->PostTaskAndReply(
102 FROM_HERE,
103 base::Bind(&NSSCertDatabase::ListCertsInSlotImpl,
104 base::Passed(crypto::ScopedPK11Slot(PK11_ReferenceSlot(slot))),
105 base::Unretained(raw_certs)),
106 base::Bind(callback, base::Passed(&certs)));
107 }
108
94 crypto::ScopedPK11Slot NSSCertDatabase::GetPublicSlot() const { 109 crypto::ScopedPK11Slot NSSCertDatabase::GetPublicSlot() const {
95 return crypto::ScopedPK11Slot(crypto::GetPublicNSSKeySlot()); 110 return crypto::ScopedPK11Slot(crypto::GetPublicNSSKeySlot());
96 } 111 }
97 112
98 crypto::ScopedPK11Slot NSSCertDatabase::GetPrivateSlot() const { 113 crypto::ScopedPK11Slot NSSCertDatabase::GetPrivateSlot() const {
99 return crypto::ScopedPK11Slot(crypto::GetPrivateNSSKeySlot()); 114 return crypto::ScopedPK11Slot(crypto::GetPrivateNSSKeySlot());
100 } 115 }
101 116
102 CryptoModule* NSSCertDatabase::GetPublicModule() const { 117 CryptoModule* NSSCertDatabase::GetPublicModule() const {
103 crypto::ScopedPK11Slot slot(GetPublicSlot()); 118 crypto::ScopedPK11Slot slot(GetPublicSlot());
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 void NSSCertDatabase::RemoveObserver(Observer* observer) { 370 void NSSCertDatabase::RemoveObserver(Observer* observer) {
356 observer_list_->RemoveObserver(observer); 371 observer_list_->RemoveObserver(observer);
357 } 372 }
358 373
359 void NSSCertDatabase::SetSlowTaskRunnerForTest( 374 void NSSCertDatabase::SetSlowTaskRunnerForTest(
360 const scoped_refptr<base::TaskRunner>& task_runner) { 375 const scoped_refptr<base::TaskRunner>& task_runner) {
361 slow_task_runner_for_test_ = task_runner; 376 slow_task_runner_for_test_ = task_runner;
362 } 377 }
363 378
364 // static 379 // static
380 void NSSCertDatabase::ListCertsInSlotImpl(crypto::ScopedPK11Slot slot,
381 CertificateList* certs) {
mattm 2014/05/16 20:27:12 certs->clear();
pneubeck (no reviews) 2014/05/19 19:17:19 Merged with other ListCertsImpl. Done.
382 DCHECK(slot);
383 CERTCertList* cert_list = PK11_ListCertsInSlot(slot.get());
384 CERTCertListNode* node;
385 for (node = CERT_LIST_HEAD(cert_list); !CERT_LIST_END(node, cert_list);
386 node = CERT_LIST_NEXT(node)) {
387 certs->push_back(X509Certificate::CreateFromHandle(
388 node->cert, X509Certificate::OSCertHandles()));
389 }
390 CERT_DestroyCertList(cert_list);
391 }
392
393 // static
365 void NSSCertDatabase::ListCertsImpl(CertificateList* certs) { 394 void NSSCertDatabase::ListCertsImpl(CertificateList* certs) {
366 certs->clear(); 395 certs->clear();
367 396
368 CERTCertList* cert_list = PK11_ListCerts(PK11CertListUnique, NULL); 397 CERTCertList* cert_list = PK11_ListCerts(PK11CertListUnique, NULL);
369 CERTCertListNode* node; 398 CERTCertListNode* node;
370 for (node = CERT_LIST_HEAD(cert_list); 399 for (node = CERT_LIST_HEAD(cert_list);
371 !CERT_LIST_END(node, cert_list); 400 !CERT_LIST_END(node, cert_list);
372 node = CERT_LIST_NEXT(node)) { 401 node = CERT_LIST_NEXT(node)) {
373 certs->push_back(X509Certificate::CreateFromHandle( 402 certs->push_back(X509Certificate::CreateFromHandle(
374 node->cert, X509Certificate::OSCertHandles())); 403 node->cert, X509Certificate::OSCertHandles()));
(...skipping 16 matching lines...) Expand all
391 observer_list_->Notify(&Observer::OnCertRemoved, make_scoped_refptr(cert)); 420 observer_list_->Notify(&Observer::OnCertRemoved, make_scoped_refptr(cert));
392 } 421 }
393 422
394 void NSSCertDatabase::NotifyObserversOfCACertChanged( 423 void NSSCertDatabase::NotifyObserversOfCACertChanged(
395 const X509Certificate* cert) { 424 const X509Certificate* cert) {
396 observer_list_->Notify( 425 observer_list_->Notify(
397 &Observer::OnCACertChanged, make_scoped_refptr(cert)); 426 &Observer::OnCACertChanged, make_scoped_refptr(cert));
398 } 427 }
399 428
400 } // namespace net 429 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698