Chromium Code Reviews| 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_CERT_DATABASE_H_ | 5 #ifndef NET_CERT_CERT_DATABASE_H_ |
| 6 #define NET_CERT_CERT_DATABASE_H_ | 6 #define NET_CERT_CERT_DATABASE_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 | 36 |
| 37 // Will be called when a new certificate is added. | 37 // Will be called when a new certificate is added. |
| 38 virtual void OnCertAdded(const X509Certificate* cert) {} | 38 virtual void OnCertAdded(const X509Certificate* cert) {} |
| 39 | 39 |
| 40 // Will be called when a certificate is removed. | 40 // Will be called when a certificate is removed. |
| 41 virtual void OnCertRemoved(const X509Certificate* cert) {} | 41 virtual void OnCertRemoved(const X509Certificate* cert) {} |
| 42 | 42 |
| 43 // Will be called when a certificate's trust is changed. | 43 // Will be called when a certificate's trust is changed. |
| 44 virtual void OnCertTrustChanged(const X509Certificate* cert) {} | 44 virtual void OnCertTrustChanged(const X509Certificate* cert) {} |
| 45 | 45 |
| 46 // Will be called when the database changed in a unspecified manner. This is | |
| 47 // needed because some platforms (for example Android) delegate the | |
| 48 // certificate database to the system and do not get precise notifications | |
| 49 // of changes. | |
| 50 virtual void OnDatabaseChanged() {} | |
|
Ryan Sleevi
2013/10/16 17:40:52
I would like to avoid adding a new method, especia
qsr
2013/10/17 09:17:54
Not sure to understand the comment, as the observe
| |
| 51 | |
| 46 protected: | 52 protected: |
| 47 Observer() {} | 53 Observer() {} |
| 48 | 54 |
| 49 private: | 55 private: |
| 50 DISALLOW_COPY_AND_ASSIGN(Observer); | 56 DISALLOW_COPY_AND_ASSIGN(Observer); |
| 51 }; | 57 }; |
| 52 | 58 |
| 53 // Returns the CertDatabase singleton. | 59 // Returns the CertDatabase singleton. |
| 54 static CertDatabase* GetInstance(); | 60 static CertDatabase* GetInstance(); |
| 55 | 61 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 71 // on the same thread on which AddObserver() was called. | 77 // on the same thread on which AddObserver() was called. |
| 72 void RemoveObserver(Observer* observer); | 78 void RemoveObserver(Observer* observer); |
| 73 | 79 |
| 74 #if defined(OS_MACOSX) && !defined(OS_IOS) | 80 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 75 // Configures the current message loop to observe and forward events from | 81 // Configures the current message loop to observe and forward events from |
| 76 // Keychain services. The MessageLoop must have an associated CFRunLoop, | 82 // Keychain services. The MessageLoop must have an associated CFRunLoop, |
| 77 // which means that this must be called from a MessageLoop of TYPE_UI. | 83 // which means that this must be called from a MessageLoop of TYPE_UI. |
| 78 void SetMessageLoopForKeychainEvents(); | 84 void SetMessageLoopForKeychainEvents(); |
| 79 #endif | 85 #endif |
| 80 | 86 |
| 87 #if defined(OS_ANDROID) | |
| 88 // On android, the system database is used. When the system notifies the | |
| 89 // application that the certificates changed, the observers must be notified. | |
| 90 void NotifyObserversOfDatabaseChanged(); | |
| 91 #endif | |
| 92 | |
| 81 private: | 93 private: |
| 82 friend struct DefaultSingletonTraits<CertDatabase>; | 94 friend struct DefaultSingletonTraits<CertDatabase>; |
| 83 | 95 |
| 84 CertDatabase(); | 96 CertDatabase(); |
| 85 ~CertDatabase(); | 97 ~CertDatabase(); |
| 86 | 98 |
| 87 // Broadcasts notifications to all registered observers. | 99 // Broadcasts notifications to all registered observers. |
| 88 void NotifyObserversOfCertAdded(const X509Certificate* cert); | 100 void NotifyObserversOfCertAdded(const X509Certificate* cert); |
| 89 void NotifyObserversOfCertRemoved(const X509Certificate* cert); | 101 void NotifyObserversOfCertRemoved(const X509Certificate* cert); |
| 90 void NotifyObserversOfCertTrustChanged(const X509Certificate* cert); | 102 void NotifyObserversOfCertTrustChanged(const X509Certificate* cert); |
| 91 | 103 |
| 92 const scoped_refptr<ObserverListThreadSafe<Observer> > observer_list_; | 104 const scoped_refptr<ObserverListThreadSafe<Observer> > observer_list_; |
| 93 | 105 |
| 94 #if defined(USE_NSS) || (defined(OS_MACOSX) && !defined(OS_IOS)) | 106 #if defined(USE_NSS) || (defined(OS_MACOSX) && !defined(OS_IOS)) |
| 95 class Notifier; | 107 class Notifier; |
| 96 friend class Notifier; | 108 friend class Notifier; |
| 97 scoped_ptr<Notifier> notifier_; | 109 scoped_ptr<Notifier> notifier_; |
| 98 #endif | 110 #endif |
| 99 | 111 |
| 100 DISALLOW_COPY_AND_ASSIGN(CertDatabase); | 112 DISALLOW_COPY_AND_ASSIGN(CertDatabase); |
| 101 }; | 113 }; |
| 102 | 114 |
| 103 } // namespace net | 115 } // namespace net |
| 104 | 116 |
| 105 #endif // NET_CERT_CERT_DATABASE_H_ | 117 #endif // NET_CERT_CERT_DATABASE_H_ |
| OLD | NEW |