| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_CHROMEOS_CERTIFICATE_PROVIDER_CERTIFICATE_PROVIDER_SERVIC
E_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_CERTIFICATE_PROVIDER_CERTIFICATE_PROVIDER_SERVIC
E_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_CERTIFICATE_PROVIDER_CERTIFICATE_PROVIDER_SERVIC
E_H_ | 6 #define CHROME_BROWSER_CHROMEOS_CERTIFICATE_PROVIDER_CERTIFICATE_PROVIDER_SERVIC
E_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/callback_forward.h" | 15 #include "base/callback_forward.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 19 #include "base/threading/thread_checker.h" | 19 #include "base/threading/thread_checker.h" |
| 20 #include "chrome/browser/chromeos/certificate_provider/certificate_info.h" | 20 #include "chrome/browser/chromeos/certificate_provider/certificate_info.h" |
| 21 #include "chrome/browser/chromeos/certificate_provider/certificate_requests.h" | 21 #include "chrome/browser/chromeos/certificate_provider/certificate_requests.h" |
| 22 #include "chrome/browser/chromeos/certificate_provider/pin_dialog_manager.h" |
| 22 #include "chrome/browser/chromeos/certificate_provider/sign_requests.h" | 23 #include "chrome/browser/chromeos/certificate_provider/sign_requests.h" |
| 23 #include "chrome/browser/chromeos/certificate_provider/thread_safe_certificate_m
ap.h" | 24 #include "chrome/browser/chromeos/certificate_provider/thread_safe_certificate_m
ap.h" |
| 24 #include "components/keyed_service/core/keyed_service.h" | 25 #include "components/keyed_service/core/keyed_service.h" |
| 25 #include "net/cert/x509_certificate.h" | 26 #include "net/cert/x509_certificate.h" |
| 26 #include "net/ssl/ssl_private_key.h" | 27 #include "net/ssl/ssl_private_key.h" |
| 27 | 28 |
| 28 namespace chromeos { | 29 namespace chromeos { |
| 29 | 30 |
| 30 class CertificateProvider; | 31 class CertificateProvider; |
| 31 | 32 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 // call its |GetCertificates()|. The returned provider is valid even after the | 144 // call its |GetCertificates()|. The returned provider is valid even after the |
| 144 // destruction of this service. | 145 // destruction of this service. |
| 145 // The returned provider can be used on any thread. | 146 // The returned provider can be used on any thread. |
| 146 std::unique_ptr<CertificateProvider> CreateCertificateProvider(); | 147 std::unique_ptr<CertificateProvider> CreateCertificateProvider(); |
| 147 | 148 |
| 148 // Must be called if extension with id |extension_id| is unloaded and cannot | 149 // Must be called if extension with id |extension_id| is unloaded and cannot |
| 149 // serve certificates anymore. This should be called everytime the | 150 // serve certificates anymore. This should be called everytime the |
| 150 // corresponding notification of the ExtensionRegistry is triggered. | 151 // corresponding notification of the ExtensionRegistry is triggered. |
| 151 void OnExtensionUnloaded(const std::string& extension_id); | 152 void OnExtensionUnloaded(const std::string& extension_id); |
| 152 | 153 |
| 154 PinDialogManager* pin_dialog_manager() { return pin_dialog_manager_.get(); } |
| 155 |
| 153 private: | 156 private: |
| 154 class CertKeyProviderImpl; | 157 class CertKeyProviderImpl; |
| 155 class CertificateProviderImpl; | 158 class CertificateProviderImpl; |
| 156 class SSLPrivateKey; | 159 class SSLPrivateKey; |
| 157 | 160 |
| 158 // Requests the current list of certificates from every registered extension. | 161 // Requests the current list of certificates from every registered extension. |
| 159 // Once all extensions replied or a timeout was reached, the internal | 162 // Once all extensions replied or a timeout was reached, the internal |
| 160 // |extension_to_certificates_| is updated and |callback| is run with the | 163 // |extension_to_certificates_| is updated and |callback| is run with the |
| 161 // retrieved list of certificates. | 164 // retrieved list of certificates. |
| 162 void GetCertificatesFromExtensions( | 165 void GetCertificatesFromExtensions( |
| (...skipping 21 matching lines...) Expand all Loading... |
| 184 net::SSLPrivateKey::Hash hash, | 187 net::SSLPrivateKey::Hash hash, |
| 185 const std::string& digest, | 188 const std::string& digest, |
| 186 const net::SSLPrivateKey::SignCallback& callback); | 189 const net::SSLPrivateKey::SignCallback& callback); |
| 187 | 190 |
| 188 std::unique_ptr<Delegate> delegate_; | 191 std::unique_ptr<Delegate> delegate_; |
| 189 | 192 |
| 190 // An instance of net::ClientKeyStore::CertKeyProvider that is registered at | 193 // An instance of net::ClientKeyStore::CertKeyProvider that is registered at |
| 191 // the net::ClientKeyStore singleton. | 194 // the net::ClientKeyStore singleton. |
| 192 std::unique_ptr<CertKeyProviderImpl> cert_key_provider_; | 195 std::unique_ptr<CertKeyProviderImpl> cert_key_provider_; |
| 193 | 196 |
| 197 // The object to manage the dialog displayed when requestPin is called by the |
| 198 // extension. |
| 199 std::unique_ptr<PinDialogManager> pin_dialog_manager_; |
| 200 |
| 194 // State about all pending sign requests. | 201 // State about all pending sign requests. |
| 195 certificate_provider::SignRequests sign_requests_; | 202 certificate_provider::SignRequests sign_requests_; |
| 196 | 203 |
| 197 // Contains all pending certificate requests. | 204 // Contains all pending certificate requests. |
| 198 certificate_provider::CertificateRequests certificate_requests_; | 205 certificate_provider::CertificateRequests certificate_requests_; |
| 199 | 206 |
| 200 // Contains all certificates that the extensions returned during the lifetime | 207 // Contains all certificates that the extensions returned during the lifetime |
| 201 // of this service. Each certificate is associated with the extension that | 208 // of this service. Each certificate is associated with the extension that |
| 202 // reported the certificate in response to the most recent certificate | 209 // reported the certificate in response to the most recent certificate |
| 203 // request. If a certificate was reported previously but in the most recent | 210 // request. If a certificate was reported previously but in the most recent |
| 204 // responses, it is still cached but not loses it's association with any | 211 // responses, it is still cached but not loses it's association with any |
| 205 // extension. This ensures that a certificate can't magically appear as | 212 // extension. This ensures that a certificate can't magically appear as |
| 206 // platform certificate (e.g. in the client certificate selection dialog) | 213 // platform certificate (e.g. in the client certificate selection dialog) |
| 207 // after an extension doesn't report it anymore. | 214 // after an extension doesn't report it anymore. |
| 208 certificate_provider::ThreadSafeCertificateMap certificate_map_; | 215 certificate_provider::ThreadSafeCertificateMap certificate_map_; |
| 209 | 216 |
| 210 base::ThreadChecker thread_checker_; | 217 base::ThreadChecker thread_checker_; |
| 211 base::WeakPtrFactory<CertificateProviderService> weak_factory_; | 218 base::WeakPtrFactory<CertificateProviderService> weak_factory_; |
| 212 | 219 |
| 213 DISALLOW_COPY_AND_ASSIGN(CertificateProviderService); | 220 DISALLOW_COPY_AND_ASSIGN(CertificateProviderService); |
| 214 }; | 221 }; |
| 215 | 222 |
| 216 } // namespace chromeos | 223 } // namespace chromeos |
| 217 | 224 |
| 218 #endif // CHROME_BROWSER_CHROMEOS_CERTIFICATE_PROVIDER_CERTIFICATE_PROVIDER_SER
VICE_H_ | 225 #endif // CHROME_BROWSER_CHROMEOS_CERTIFICATE_PROVIDER_CERTIFICATE_PROVIDER_SER
VICE_H_ |
| OLD | NEW |