| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_BASE_CERT_DATABASE_H_ | 5 #ifndef NET_BASE_CERT_DATABASE_H_ |
| 6 #define NET_BASE_CERT_DATABASE_H_ | 6 #define NET_BASE_CERT_DATABASE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/string16.h" | 14 #include "base/string16.h" |
| 15 #include "net/base/cert_type.h" | 15 #include "net/base/cert_type.h" |
| 16 #include "net/base/net_api.h" | 16 #include "net/base/net_export.h" |
| 17 | 17 |
| 18 namespace net { | 18 namespace net { |
| 19 | 19 |
| 20 class CryptoModule; | 20 class CryptoModule; |
| 21 typedef std::vector<scoped_refptr<CryptoModule> > CryptoModuleList; | 21 typedef std::vector<scoped_refptr<CryptoModule> > CryptoModuleList; |
| 22 class X509Certificate; | 22 class X509Certificate; |
| 23 typedef std::vector<scoped_refptr<X509Certificate> > CertificateList; | 23 typedef std::vector<scoped_refptr<X509Certificate> > CertificateList; |
| 24 | 24 |
| 25 | 25 |
| 26 // This class provides functions to manipulate the local | 26 // This class provides functions to manipulate the local |
| 27 // certificate store. | 27 // certificate store. |
| 28 | 28 |
| 29 // TODO(gauravsh): This class could be augmented with methods | 29 // TODO(gauravsh): This class could be augmented with methods |
| 30 // for all operations that manipulate the underlying system | 30 // for all operations that manipulate the underlying system |
| 31 // certificate store. | 31 // certificate store. |
| 32 | 32 |
| 33 class NET_API CertDatabase { | 33 class NET_EXPORT CertDatabase { |
| 34 public: | 34 public: |
| 35 | 35 |
| 36 // A CertDatabase::Observer will be notified on certificate database changes. | 36 // A CertDatabase::Observer will be notified on certificate database changes. |
| 37 // The change could be either a new user certificate is added or trust on | 37 // The change could be either a new user certificate is added or trust on |
| 38 // a certificate is changed. Observers can register themselves | 38 // a certificate is changed. Observers can register themselves |
| 39 // via CertDatabase::AddObserver, and can un-register with | 39 // via CertDatabase::AddObserver, and can un-register with |
| 40 // CertDatabase::RemoveObserver. | 40 // CertDatabase::RemoveObserver. |
| 41 class NET_API Observer { | 41 class NET_EXPORT Observer { |
| 42 public: | 42 public: |
| 43 virtual ~Observer() {} | 43 virtual ~Observer() {} |
| 44 | 44 |
| 45 // Will be called when a new user certificate is added. | 45 // Will be called when a new user certificate is added. |
| 46 // Note that |cert| could be NULL when called. | 46 // Note that |cert| could be NULL when called. |
| 47 virtual void OnUserCertAdded(const X509Certificate* cert) {} | 47 virtual void OnUserCertAdded(const X509Certificate* cert) {} |
| 48 | 48 |
| 49 // Will be called when a certificate's trust is changed. | 49 // Will be called when a certificate's trust is changed. |
| 50 // Note that |cert| could be NULL when called. | 50 // Note that |cert| could be NULL when called. |
| 51 virtual void OnCertTrustChanged(const X509Certificate* cert) {} | 51 virtual void OnCertTrustChanged(const X509Certificate* cert) {} |
| 52 | 52 |
| 53 protected: | 53 protected: |
| 54 Observer() {} | 54 Observer() {} |
| 55 | 55 |
| 56 private: | 56 private: |
| 57 DISALLOW_COPY_AND_ASSIGN(Observer); | 57 DISALLOW_COPY_AND_ASSIGN(Observer); |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 // Stores per-certificate error codes for import failures. | 60 // Stores per-certificate error codes for import failures. |
| 61 struct NET_API ImportCertFailure { | 61 struct NET_EXPORT ImportCertFailure { |
| 62 public: | 62 public: |
| 63 ImportCertFailure(X509Certificate* cert, int err); | 63 ImportCertFailure(X509Certificate* cert, int err); |
| 64 ~ImportCertFailure(); | 64 ~ImportCertFailure(); |
| 65 | 65 |
| 66 scoped_refptr<X509Certificate> certificate; | 66 scoped_refptr<X509Certificate> certificate; |
| 67 int net_error; | 67 int net_error; |
| 68 }; | 68 }; |
| 69 typedef std::vector<ImportCertFailure> ImportCertFailureList; | 69 typedef std::vector<ImportCertFailure> ImportCertFailureList; |
| 70 | 70 |
| 71 // Constants that define which usages a certificate is trusted for. | 71 // Constants that define which usages a certificate is trusted for. |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 // Broadcasts notifications to all registered observers. | 187 // Broadcasts notifications to all registered observers. |
| 188 static void NotifyObserversOfUserCertAdded(const X509Certificate* cert); | 188 static void NotifyObserversOfUserCertAdded(const X509Certificate* cert); |
| 189 static void NotifyObserversOfCertTrustChanged(const X509Certificate* cert); | 189 static void NotifyObserversOfCertTrustChanged(const X509Certificate* cert); |
| 190 | 190 |
| 191 DISALLOW_COPY_AND_ASSIGN(CertDatabase); | 191 DISALLOW_COPY_AND_ASSIGN(CertDatabase); |
| 192 }; | 192 }; |
| 193 | 193 |
| 194 } // namespace net | 194 } // namespace net |
| 195 | 195 |
| 196 #endif // NET_BASE_CERT_DATABASE_H_ | 196 #endif // NET_BASE_CERT_DATABASE_H_ |
| OLD | NEW |