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" | |
mattm
2016/09/09 01:34:05
can you forward declare CertificateProvider and mo
Ivan Šandrk
2016/09/09 10:17:53
Done.
| |
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 net::NSSCertDatabase::TrustBits trust_bits); | 124 net::NSSCertDatabase::TrustBits trust_bits); |
123 | 125 |
124 // Delete the cert. Returns true on success. |cert| is still valid when this | 126 // Delete the cert. Returns true on success. |cert| is still valid when this |
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( |
133 bool is_user_db_available, | 135 net::NSSCertDatabase* nss_cert_database, |
134 bool is_tpm_available, | 136 bool is_user_db_available, |
135 Observer* observer); | 137 bool is_tpm_available, |
138 Observer* observer, | |
139 std::unique_ptr<chromeos::CertificateProvider> certificate_provider); | |
136 | 140 |
137 // Methods used during initialization, see the comment at the top of the .cc | 141 // Methods used during initialization, see the comment at the top of the .cc |
138 // file for details. | 142 // file for details. |
139 static void DidGetCertDBOnUIThread( | 143 static void DidGetCertDBOnUIThread( |
140 net::NSSCertDatabase* cert_db, | 144 net::NSSCertDatabase* cert_db, |
141 bool is_user_db_available, | 145 bool is_user_db_available, |
142 bool is_tpm_available, | 146 bool is_tpm_available, |
143 CertificateManagerModel::Observer* observer, | 147 CertificateManagerModel::Observer* observer, |
148 std::unique_ptr<chromeos::CertificateProvider> certificate_provider, | |
144 const CreationCallback& callback); | 149 const CreationCallback& callback); |
145 static void DidGetCertDBOnIOThread( | 150 static void DidGetCertDBOnIOThread( |
146 CertificateManagerModel::Observer* observer, | 151 CertificateManagerModel::Observer* observer, |
152 std::unique_ptr<chromeos::CertificateProvider> certificate_provider, | |
147 const CreationCallback& callback, | 153 const CreationCallback& callback, |
148 net::NSSCertDatabase* cert_db); | 154 net::NSSCertDatabase* cert_db); |
149 static void GetCertDBOnIOThread(content::ResourceContext* context, | 155 static void GetCertDBOnIOThread( |
150 CertificateManagerModel::Observer* observer, | 156 content::ResourceContext* context, |
151 const CreationCallback& callback); | 157 CertificateManagerModel::Observer* observer, |
158 std::unique_ptr<chromeos::CertificateProvider> certificate_provider, | |
159 const CreationCallback& callback); | |
152 | 160 |
153 // Callback used by Refresh() for when the cert slots have been unlocked. | 161 // Callback used by Refresh() for when the cert slots have been unlocked. |
154 // This method does the actual refreshing. | 162 // This method does the actual refreshing. |
155 void RefreshSlotsUnlocked(); | 163 void RefreshSlotsUnlocked(); |
156 | 164 |
165 // Callback used to refresh extension provided certificates. Refreshes UI. | |
166 void RefreshExtensionCertificates(const net::CertificateList& new_certs); | |
167 | |
157 net::NSSCertDatabase* cert_db_; | 168 net::NSSCertDatabase* cert_db_; |
158 net::CertificateList cert_list_; | 169 net::CertificateList cert_list_; |
170 net::CertificateList extension_cert_list_; | |
159 // Whether the certificate database has a public slot associated with the | 171 // Whether the certificate database has a public slot associated with the |
160 // profile. If not set, importing certificates is not allowed with this model. | 172 // profile. If not set, importing certificates is not allowed with this model. |
161 bool is_user_db_available_; | 173 bool is_user_db_available_; |
162 bool is_tpm_available_; | 174 bool is_tpm_available_; |
163 | 175 |
164 // The observer to notify when certificate list is refreshed. | 176 // The observer to notify when certificate list is refreshed. |
165 Observer* observer_; | 177 Observer* observer_; |
166 | 178 |
179 // Certificate provider used to fetch extension provided certificates. | |
180 std::unique_ptr<chromeos::CertificateProvider> certificate_provider_; | |
mattm
2016/09/09 01:34:04
I'd suggest %s/certificate_provider/extension_cert
Ivan Šandrk
2016/09/09 10:17:53
Good suggestion, I agree.
| |
181 | |
182 base::WeakPtrFactory<CertificateManagerModel> weak_ptr_factory_; | |
183 | |
167 DISALLOW_COPY_AND_ASSIGN(CertificateManagerModel); | 184 DISALLOW_COPY_AND_ASSIGN(CertificateManagerModel); |
168 }; | 185 }; |
169 | 186 |
170 #endif // CHROME_BROWSER_CERTIFICATE_MANAGER_MODEL_H_ | 187 #endif // CHROME_BROWSER_CERTIFICATE_MANAGER_MODEL_H_ |
OLD | NEW |