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" |
16 #include "net/cert/nss_cert_database.h" | 17 #include "net/cert/nss_cert_database.h" |
17 | 18 |
| 19 namespace chromeos { |
| 20 class CertificateProvider; |
| 21 } // namespace chromeos |
| 22 |
18 namespace content { | 23 namespace content { |
19 class BrowserContext; | 24 class BrowserContext; |
20 class ResourceContext; | 25 class ResourceContext; |
21 } // namespace content | 26 } // namespace content |
22 | 27 |
23 // CertificateManagerModel provides the data to be displayed in the certificate | 28 // CertificateManagerModel provides the data to be displayed in the certificate |
24 // manager dialog, and processes changes from the view. | 29 // manager dialog, and processes changes from the view. |
25 class CertificateManagerModel { | 30 class CertificateManagerModel { |
26 public: | 31 public: |
27 // Map from the subject organization name to the list of certs from that | 32 // Map from the subject organization name to the list of certs from that |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 net::NSSCertDatabase::TrustBits trust_bits); | 127 net::NSSCertDatabase::TrustBits trust_bits); |
123 | 128 |
124 // Delete the cert. Returns true on success. |cert| is still valid when this | 129 // Delete the cert. Returns true on success. |cert| is still valid when this |
125 // function returns. | 130 // function returns. |
126 bool Delete(net::X509Certificate* cert); | 131 bool Delete(net::X509Certificate* cert); |
127 | 132 |
128 // IsHardwareBacked returns true if |cert| is hardware backed. | 133 // IsHardwareBacked returns true if |cert| is hardware backed. |
129 bool IsHardwareBacked(const net::X509Certificate* cert) const; | 134 bool IsHardwareBacked(const net::X509Certificate* cert) const; |
130 | 135 |
131 private: | 136 private: |
132 CertificateManagerModel(net::NSSCertDatabase* nss_cert_database, | 137 CertificateManagerModel( |
133 bool is_user_db_available, | 138 net::NSSCertDatabase* nss_cert_database, |
134 bool is_tpm_available, | 139 bool is_user_db_available, |
135 Observer* observer); | 140 bool is_tpm_available, |
| 141 Observer* observer, |
| 142 std::unique_ptr<chromeos::CertificateProvider> |
| 143 extension_certificate_provider); |
136 | 144 |
137 // Methods used during initialization, see the comment at the top of the .cc | 145 // Methods used during initialization, see the comment at the top of the .cc |
138 // file for details. | 146 // file for details. |
139 static void DidGetCertDBOnUIThread( | 147 static void DidGetCertDBOnUIThread( |
140 net::NSSCertDatabase* cert_db, | 148 net::NSSCertDatabase* cert_db, |
141 bool is_user_db_available, | 149 bool is_user_db_available, |
142 bool is_tpm_available, | 150 bool is_tpm_available, |
143 CertificateManagerModel::Observer* observer, | 151 CertificateManagerModel::Observer* observer, |
| 152 std::unique_ptr<chromeos::CertificateProvider> |
| 153 extension_certificate_provider, |
144 const CreationCallback& callback); | 154 const CreationCallback& callback); |
145 static void DidGetCertDBOnIOThread( | 155 static void DidGetCertDBOnIOThread( |
146 CertificateManagerModel::Observer* observer, | 156 CertificateManagerModel::Observer* observer, |
| 157 std::unique_ptr<chromeos::CertificateProvider> |
| 158 extension_certificate_provider, |
147 const CreationCallback& callback, | 159 const CreationCallback& callback, |
148 net::NSSCertDatabase* cert_db); | 160 net::NSSCertDatabase* cert_db); |
149 static void GetCertDBOnIOThread(content::ResourceContext* context, | 161 static void GetCertDBOnIOThread( |
150 CertificateManagerModel::Observer* observer, | 162 content::ResourceContext* context, |
151 const CreationCallback& callback); | 163 CertificateManagerModel::Observer* observer, |
| 164 std::unique_ptr<chromeos::CertificateProvider> |
| 165 extension_certificate_provider, |
| 166 const CreationCallback& callback); |
152 | 167 |
153 // Callback used by Refresh() for when the cert slots have been unlocked. | 168 // Callback used by Refresh() for when the cert slots have been unlocked. |
154 // This method does the actual refreshing. | 169 // This method does the actual refreshing. |
155 void RefreshSlotsUnlocked(); | 170 void RefreshSlotsUnlocked(); |
156 | 171 |
| 172 // Callback used to refresh extension provided certificates. Refreshes UI. |
| 173 void RefreshExtensionCertificates(const net::CertificateList& new_certs); |
| 174 |
157 net::NSSCertDatabase* cert_db_; | 175 net::NSSCertDatabase* cert_db_; |
158 net::CertificateList cert_list_; | 176 net::CertificateList cert_list_; |
| 177 net::CertificateList extension_cert_list_; |
159 // Whether the certificate database has a public slot associated with the | 178 // Whether the certificate database has a public slot associated with the |
160 // profile. If not set, importing certificates is not allowed with this model. | 179 // profile. If not set, importing certificates is not allowed with this model. |
161 bool is_user_db_available_; | 180 bool is_user_db_available_; |
162 bool is_tpm_available_; | 181 bool is_tpm_available_; |
163 | 182 |
164 // The observer to notify when certificate list is refreshed. | 183 // The observer to notify when certificate list is refreshed. |
165 Observer* observer_; | 184 Observer* observer_; |
166 | 185 |
| 186 // Certificate provider used to fetch extension provided certificates. |
| 187 std::unique_ptr<chromeos::CertificateProvider> |
| 188 extension_certificate_provider_; |
| 189 |
| 190 base::WeakPtrFactory<CertificateManagerModel> weak_ptr_factory_; |
| 191 |
167 DISALLOW_COPY_AND_ASSIGN(CertificateManagerModel); | 192 DISALLOW_COPY_AND_ASSIGN(CertificateManagerModel); |
168 }; | 193 }; |
169 | 194 |
170 #endif // CHROME_BROWSER_CERTIFICATE_MANAGER_MODEL_H_ | 195 #endif // CHROME_BROWSER_CERTIFICATE_MANAGER_MODEL_H_ |
OLD | NEW |