| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 CHROMEOS_CERT_LOADER_H_ | 5 #ifndef CHROMEOS_CERT_LOADER_H_ |
| 6 #define CHROMEOS_CERT_LOADER_H_ | 6 #define CHROMEOS_CERT_LOADER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 60 |
| 61 // Returns true if the global instance has been initialized. | 61 // Returns true if the global instance has been initialized. |
| 62 static bool IsInitialized(); | 62 static bool IsInitialized(); |
| 63 | 63 |
| 64 static std::string GetPkcs11IdForCert(const net::X509Certificate& cert); | 64 static std::string GetPkcs11IdForCert(const net::X509Certificate& cert); |
| 65 | 65 |
| 66 // Starts the CertLoader with the NSS cert database. | 66 // Starts the CertLoader with the NSS cert database. |
| 67 // The CertLoader will _not_ take the ownership of the database. | 67 // The CertLoader will _not_ take the ownership of the database. |
| 68 void StartWithNSSDB(net::NSSCertDatabase* database); | 68 void StartWithNSSDB(net::NSSCertDatabase* database); |
| 69 | 69 |
| 70 // Sets the task runner that any slow calls will be made from, e.g. calls | |
| 71 // to the NSS database. If not set, uses base::WorkerPool. | |
| 72 void SetSlowTaskRunnerForTest( | |
| 73 const scoped_refptr<base::TaskRunner>& task_runner); | |
| 74 | |
| 75 void AddObserver(CertLoader::Observer* observer); | 70 void AddObserver(CertLoader::Observer* observer); |
| 76 void RemoveObserver(CertLoader::Observer* observer); | 71 void RemoveObserver(CertLoader::Observer* observer); |
| 77 | 72 |
| 78 int TPMTokenSlotID() const; | 73 int TPMTokenSlotID() const; |
| 79 bool IsHardwareBacked() const; | 74 bool IsHardwareBacked() const; |
| 80 | 75 |
| 81 // Whether the certificate is hardware backed. Returns false if the CertLoader | 76 // Whether the certificate is hardware backed. Returns false if the CertLoader |
| 82 // was not yet started (both |CertificatesLoading()| and | 77 // was not yet started (both |CertificatesLoading()| and |
| 83 // |certificates_loaded()| are false). | 78 // |certificates_loaded()| are false). |
| 84 bool IsCertificateHardwareBacked(const net::X509Certificate* cert) const; | 79 bool IsCertificateHardwareBacked(const net::X509Certificate* cert) const; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 97 | 92 |
| 98 private: | 93 private: |
| 99 CertLoader(); | 94 CertLoader(); |
| 100 virtual ~CertLoader(); | 95 virtual ~CertLoader(); |
| 101 | 96 |
| 102 // Trigger a certificate load. If a certificate loading task is already in | 97 // Trigger a certificate load. If a certificate loading task is already in |
| 103 // progress, will start a reload once the current task is finished. | 98 // progress, will start a reload once the current task is finished. |
| 104 void LoadCertificates(); | 99 void LoadCertificates(); |
| 105 | 100 |
| 106 // Called if a certificate load task is finished. | 101 // Called if a certificate load task is finished. |
| 107 void UpdateCertificates(net::CertificateList* cert_list); | 102 void UpdateCertificates(scoped_ptr<net::CertificateList> cert_list); |
| 108 | 103 |
| 109 void NotifyCertificatesLoaded(bool initial_load); | 104 void NotifyCertificatesLoaded(bool initial_load); |
| 110 | 105 |
| 111 // net::CertDatabase::Observer | 106 // net::CertDatabase::Observer |
| 112 virtual void OnCACertChanged(const net::X509Certificate* cert) OVERRIDE; | 107 virtual void OnCACertChanged(const net::X509Certificate* cert) OVERRIDE; |
| 113 virtual void OnCertAdded(const net::X509Certificate* cert) OVERRIDE; | 108 virtual void OnCertAdded(const net::X509Certificate* cert) OVERRIDE; |
| 114 virtual void OnCertRemoved(const net::X509Certificate* cert) OVERRIDE; | 109 virtual void OnCertRemoved(const net::X509Certificate* cert) OVERRIDE; |
| 115 | 110 |
| 116 ObserverList<Observer> observers_; | 111 ObserverList<Observer> observers_; |
| 117 | 112 |
| 118 // Flags describing current CertLoader state. | 113 // Flags describing current CertLoader state. |
| 119 bool certificates_loaded_; | 114 bool certificates_loaded_; |
| 120 bool certificates_update_required_; | 115 bool certificates_update_required_; |
| 121 bool certificates_update_running_; | 116 bool certificates_update_running_; |
| 122 | 117 |
| 123 // The user-specific NSS certificate database from which the certificates | 118 // The user-specific NSS certificate database from which the certificates |
| 124 // should be loaded. | 119 // should be loaded. |
| 125 net::NSSCertDatabase* database_; | 120 net::NSSCertDatabase* database_; |
| 126 | 121 |
| 127 // Set during tests if |IsHardwareBacked()| should always return true. | 122 // Set during tests if |IsHardwareBacked()| should always return true. |
| 128 bool force_hardware_backed_for_test_; | 123 bool force_hardware_backed_for_test_; |
| 129 | 124 |
| 130 // Cached Certificates loaded from the database. | 125 // Cached Certificates loaded from the database. |
| 131 net::CertificateList cert_list_; | 126 net::CertificateList cert_list_; |
| 132 | 127 |
| 133 base::ThreadChecker thread_checker_; | 128 base::ThreadChecker thread_checker_; |
| 134 | 129 |
| 135 // TaskRunner that, if set, replaces base::WorkerPool. Should only be set in | |
| 136 // tests. | |
| 137 scoped_refptr<base::TaskRunner> slow_task_runner_for_test_; | |
| 138 | |
| 139 base::WeakPtrFactory<CertLoader> weak_factory_; | 130 base::WeakPtrFactory<CertLoader> weak_factory_; |
| 140 | 131 |
| 141 DISALLOW_COPY_AND_ASSIGN(CertLoader); | 132 DISALLOW_COPY_AND_ASSIGN(CertLoader); |
| 142 }; | 133 }; |
| 143 | 134 |
| 144 } // namespace chromeos | 135 } // namespace chromeos |
| 145 | 136 |
| 146 #endif // CHROMEOS_CERT_LOADER_H_ | 137 #endif // CHROMEOS_CERT_LOADER_H_ |
| OLD | NEW |