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