| 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 CHROME_BROWSER_CERTIFICATE_MANAGER_MODEL_H_ | 5 #ifndef CHROME_BROWSER_CERTIFICATE_MANAGER_MODEL_H_ |
| 6 #define CHROME_BROWSER_CERTIFICATE_MANAGER_MODEL_H_ | 6 #define CHROME_BROWSER_CERTIFICATE_MANAGER_MODEL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/weak_ptr.h" |
| 15 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
| 17 #include "chrome/browser/chromeos/certificate_provider/certificate_provider.h" |
| 16 #include "net/cert/nss_cert_database.h" | 18 #include "net/cert/nss_cert_database.h" |
| 17 | 19 |
| 18 namespace content { | 20 namespace content { |
| 19 class BrowserContext; | 21 class BrowserContext; |
| 20 class ResourceContext; | 22 class ResourceContext; |
| 21 } // namespace content | 23 } // namespace content |
| 22 | 24 |
| 23 // CertificateManagerModel provides the data to be displayed in the certificate | 25 // CertificateManagerModel provides the data to be displayed in the certificate |
| 24 // manager dialog, and processes changes from the view. | 26 // manager dialog, and processes changes from the view. |
| 25 class CertificateManagerModel { | 27 class CertificateManagerModel { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 // function returns. | 127 // function returns. |
| 126 bool Delete(net::X509Certificate* cert); | 128 bool Delete(net::X509Certificate* cert); |
| 127 | 129 |
| 128 // IsHardwareBacked returns true if |cert| is hardware backed. | 130 // IsHardwareBacked returns true if |cert| is hardware backed. |
| 129 bool IsHardwareBacked(const net::X509Certificate* cert) const; | 131 bool IsHardwareBacked(const net::X509Certificate* cert) const; |
| 130 | 132 |
| 131 private: | 133 private: |
| 132 CertificateManagerModel(net::NSSCertDatabase* nss_cert_database, | 134 CertificateManagerModel(net::NSSCertDatabase* nss_cert_database, |
| 133 bool is_user_db_available, | 135 bool is_user_db_available, |
| 134 bool is_tpm_available, | 136 bool is_tpm_available, |
| 135 Observer* observer); | 137 Observer* observer, |
| 138 content::BrowserContext* browser_context); |
| 136 | 139 |
| 137 // Methods used during initialization, see the comment at the top of the .cc | 140 // Methods used during initialization, see the comment at the top of the .cc |
| 138 // file for details. | 141 // file for details. |
| 139 static void DidGetCertDBOnUIThread( | 142 static void DidGetCertDBOnUIThread( |
| 140 net::NSSCertDatabase* cert_db, | 143 net::NSSCertDatabase* cert_db, |
| 141 bool is_user_db_available, | 144 bool is_user_db_available, |
| 142 bool is_tpm_available, | 145 bool is_tpm_available, |
| 143 CertificateManagerModel::Observer* observer, | 146 CertificateManagerModel::Observer* observer, |
| 147 content::BrowserContext* browser_context, |
| 144 const CreationCallback& callback); | 148 const CreationCallback& callback); |
| 145 static void DidGetCertDBOnIOThread( | 149 static void DidGetCertDBOnIOThread( |
| 146 CertificateManagerModel::Observer* observer, | 150 CertificateManagerModel::Observer* observer, |
| 151 content::BrowserContext* browser_context, |
| 147 const CreationCallback& callback, | 152 const CreationCallback& callback, |
| 148 net::NSSCertDatabase* cert_db); | 153 net::NSSCertDatabase* cert_db); |
| 149 static void GetCertDBOnIOThread(content::ResourceContext* context, | 154 static void GetCertDBOnIOThread(content::ResourceContext* context, |
| 150 CertificateManagerModel::Observer* observer, | 155 CertificateManagerModel::Observer* observer, |
| 156 content::BrowserContext* browser_context, |
| 151 const CreationCallback& callback); | 157 const CreationCallback& callback); |
| 152 | 158 |
| 153 // Callback used by Refresh() for when the cert slots have been unlocked. | 159 // Callback used by Refresh() for when the cert slots have been unlocked. |
| 154 // This method does the actual refreshing. | 160 // This method does the actual refreshing. |
| 155 void RefreshSlotsUnlocked(); | 161 void RefreshSlotsUnlocked(); |
| 156 | 162 |
| 163 // Callback used to refresh extension provided certificates. Refreshes UI. |
| 164 void RefreshExtensionCertificates(const net::CertificateList& new_certs); |
| 165 |
| 157 net::NSSCertDatabase* cert_db_; | 166 net::NSSCertDatabase* cert_db_; |
| 158 net::CertificateList cert_list_; | 167 net::CertificateList cert_list_; |
| 168 net::CertificateList extension_cert_list_; |
| 159 // Whether the certificate database has a public slot associated with the | 169 // Whether the certificate database has a public slot associated with the |
| 160 // profile. If not set, importing certificates is not allowed with this model. | 170 // profile. If not set, importing certificates is not allowed with this model. |
| 161 bool is_user_db_available_; | 171 bool is_user_db_available_; |
| 162 bool is_tpm_available_; | 172 bool is_tpm_available_; |
| 163 | 173 |
| 164 // The observer to notify when certificate list is refreshed. | 174 // The observer to notify when certificate list is refreshed. |
| 165 Observer* observer_; | 175 Observer* observer_; |
| 166 | 176 |
| 177 // Certificate provider used to fetch extension provided certificates. |
| 178 std::unique_ptr<chromeos::CertificateProvider> certificate_provider_; |
| 179 |
| 180 base::WeakPtrFactory<CertificateManagerModel> weak_ptr_factory_; |
| 181 |
| 167 DISALLOW_COPY_AND_ASSIGN(CertificateManagerModel); | 182 DISALLOW_COPY_AND_ASSIGN(CertificateManagerModel); |
| 168 }; | 183 }; |
| 169 | 184 |
| 170 #endif // CHROME_BROWSER_CERTIFICATE_MANAGER_MODEL_H_ | 185 #endif // CHROME_BROWSER_CERTIFICATE_MANAGER_MODEL_H_ |
| OLD | NEW |