OLD | NEW |
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 #ifndef NET_CERT_NSS_CERT_DATABASE_H_ | 5 #ifndef NET_CERT_NSS_CERT_DATABASE_H_ |
6 #define NET_CERT_NSS_CERT_DATABASE_H_ | 6 #define NET_CERT_NSS_CERT_DATABASE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
15 #include "crypto/scoped_nss_types.h" | 15 #include "crypto/scoped_nss_types.h" |
16 #include "net/base/net_export.h" | 16 #include "net/base/net_export.h" |
17 #include "net/cert/cert_type.h" | 17 #include "net/cert/cert_type.h" |
18 #include "net/cert/x509_certificate.h" | 18 #include "net/cert/x509_certificate.h" |
19 | 19 |
20 namespace base { | 20 namespace base { |
21 template <typename T> struct DefaultLazyInstanceTraits; | 21 template <typename T> |
| 22 struct DefaultLazyInstanceTraits; |
22 class TaskRunner; | 23 class TaskRunner; |
23 } | 24 } |
24 template <class ObserverType> class ObserverListThreadSafe; | 25 template <class ObserverType> |
| 26 class ObserverListThreadSafe; |
25 | 27 |
26 namespace net { | 28 namespace net { |
27 | 29 |
28 class CryptoModule; | 30 class CryptoModule; |
29 typedef std::vector<scoped_refptr<CryptoModule> > CryptoModuleList; | 31 typedef std::vector<scoped_refptr<CryptoModule> > CryptoModuleList; |
30 | 32 |
31 // Provides functions to manipulate the NSS certificate stores. | 33 // Provides functions to manipulate the NSS certificate stores. |
32 class NET_EXPORT NSSCertDatabase { | 34 class NET_EXPORT NSSCertDatabase { |
33 public: | 35 public: |
34 | |
35 class NET_EXPORT Observer { | 36 class NET_EXPORT Observer { |
36 public: | 37 public: |
37 virtual ~Observer() {} | 38 virtual ~Observer() {} |
38 | 39 |
39 // Will be called when a new certificate is added. | 40 // Will be called when a new certificate is added. |
40 // Called with |cert| == NULL after importing a list of certificates | 41 // Called with |cert| == NULL after importing a list of certificates |
41 // in ImportFromPKCS12(). | 42 // in ImportFromPKCS12(). |
42 virtual void OnCertAdded(const X509Certificate* cert) {} | 43 virtual void OnCertAdded(const X509Certificate* cert) {} |
43 | 44 |
44 // Will be called when a certificate is removed. | 45 // Will be called when a certificate is removed. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 // For EMAIL_CERT, only TRUSTED_EMAIL makes sense, and specifies the cert is | 78 // For EMAIL_CERT, only TRUSTED_EMAIL makes sense, and specifies the cert is |
78 // trusted for email. | 79 // trusted for email. |
79 // DISTRUSTED_* specifies that the cert should not be trusted for the given | 80 // DISTRUSTED_* specifies that the cert should not be trusted for the given |
80 // usage, regardless of whether it would otherwise inherit trust from the | 81 // usage, regardless of whether it would otherwise inherit trust from the |
81 // issuer chain. | 82 // issuer chain. |
82 // Use TRUST_DEFAULT to inherit trust as normal. | 83 // Use TRUST_DEFAULT to inherit trust as normal. |
83 // NOTE: The actual constants are defined using an enum instead of static | 84 // NOTE: The actual constants are defined using an enum instead of static |
84 // consts due to compilation/linkage constraints with template functions. | 85 // consts due to compilation/linkage constraints with template functions. |
85 typedef uint32 TrustBits; | 86 typedef uint32 TrustBits; |
86 enum { | 87 enum { |
87 TRUST_DEFAULT = 0, | 88 TRUST_DEFAULT = 0, |
88 TRUSTED_SSL = 1 << 0, | 89 TRUSTED_SSL = 1 << 0, |
89 TRUSTED_EMAIL = 1 << 1, | 90 TRUSTED_EMAIL = 1 << 1, |
90 TRUSTED_OBJ_SIGN = 1 << 2, | 91 TRUSTED_OBJ_SIGN = 1 << 2, |
91 DISTRUSTED_SSL = 1 << 3, | 92 DISTRUSTED_SSL = 1 << 3, |
92 DISTRUSTED_EMAIL = 1 << 4, | 93 DISTRUSTED_EMAIL = 1 << 4, |
93 DISTRUSTED_OBJ_SIGN = 1 << 5, | 94 DISTRUSTED_OBJ_SIGN = 1 << 5, |
94 }; | 95 }; |
95 | 96 |
96 typedef base::Callback<void(scoped_ptr<CertificateList> certs)> | 97 typedef base::Callback<void(scoped_ptr<CertificateList> certs)> |
97 ListCertsCallback; | 98 ListCertsCallback; |
98 | 99 |
99 // DEPRECATED: See http://crbug.com/329735. | 100 // DEPRECATED: See http://crbug.com/329735. |
100 static NSSCertDatabase* GetInstance(); | 101 static NSSCertDatabase* GetInstance(); |
101 | 102 |
102 // Get a list of unique certificates in the certificate database (one | 103 // Get a list of unique certificates in the certificate database (one |
103 // instance of all certificates). | 104 // instance of all certificates). |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 scoped_refptr<base::TaskRunner> slow_task_runner_for_test_; | 250 scoped_refptr<base::TaskRunner> slow_task_runner_for_test_; |
250 | 251 |
251 const scoped_refptr<ObserverListThreadSafe<Observer> > observer_list_; | 252 const scoped_refptr<ObserverListThreadSafe<Observer> > observer_list_; |
252 | 253 |
253 DISALLOW_COPY_AND_ASSIGN(NSSCertDatabase); | 254 DISALLOW_COPY_AND_ASSIGN(NSSCertDatabase); |
254 }; | 255 }; |
255 | 256 |
256 } // namespace net | 257 } // namespace net |
257 | 258 |
258 #endif // NET_CERT_NSS_CERT_DATABASE_H_ | 259 #endif // NET_CERT_NSS_CERT_DATABASE_H_ |
OLD | NEW |