| Index: chrome/browser/chromeos/certificate_provider/certificate_provider_service.cc
|
| diff --git a/chrome/browser/chromeos/certificate_provider/certificate_provider_service.cc b/chrome/browser/chromeos/certificate_provider/certificate_provider_service.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..cea4a1d15d7981de2152a630a57aa12013b57190
|
| --- /dev/null
|
| +++ b/chrome/browser/chromeos/certificate_provider/certificate_provider_service.cc
|
| @@ -0,0 +1,80 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/chromeos/certificate_provider/certificate_provider_service.h"
|
| +
|
| +#include "base/location.h"
|
| +#include "base/logging.h"
|
| +#include "base/bind.h"
|
| +#include "base/task_runner.h"
|
| +#include "net/cert/x509_certificate.h"
|
| +#include "net/ssl/ssl_platform_key.h"
|
| +
|
| +namespace chromeos {
|
| +
|
| +CertificateProviderService::IOPart* g_cps_iopart = nullptr;
|
| +
|
| +class CertificateProviderService::IOPart {
|
| + public:
|
| + IOPart() {
|
| + g_cps_iopart = this;
|
| + net::fetch_private_key_func = &IOPart::FetchPrivateKey;
|
| + }
|
| +
|
| + ~IOPart() {
|
| + net::fetch_private_key_func = nullptr;
|
| + }
|
| +
|
| + static scoped_ptr<net::SSLPrivateKey> FetchPrivateKey(
|
| + net::X509Certificate* certificate) {
|
| + CHECK(g_cps_iopart);
|
| + return g_cps_iopart->FetchPrivateKeyInternal(certificate);
|
| + }
|
| +
|
| + scoped_ptr<net::SSLPrivateKey> FetchPrivateKeyInternal(
|
| + net::X509Certificate* certificate) {
|
| + return nullptr;
|
| + }
|
| +
|
| + void SetCertificatesProvidedByExtension(
|
| + const std::string& extension_id,
|
| + const CertificateInfos& certificate_infos) {
|
| + LOG(ERROR) << "IO: set certificates for extension " << extension_id;
|
| + extension_to_certificates[extension_id] = certificate_infos;
|
| + }
|
| +
|
| + private:
|
| + std::map<std::string, CertificateInfos> extension_to_certificates;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(IOPart);
|
| +};
|
| +
|
| +
|
| +CertificateProviderService::CertificateInfo::CertificateInfo() {
|
| +}
|
| +
|
| +CertificateProviderService::CertificateInfo::~CertificateInfo() {
|
| +}
|
| +
|
| +CertificateProviderService::CertificateProviderService(
|
| + scoped_refptr<base::SequencedTaskRunner> task_runner)
|
| + : io_part_(new IOPart()), task_runner_(task_runner) {}
|
| +
|
| +CertificateProviderService::~CertificateProviderService() {
|
| + task_runner_->DeleteSoon(FROM_HERE, io_part_);
|
| + io_part_ = nullptr;
|
| +}
|
| +
|
| +void CertificateProviderService::SetCertificatesProvidedByExtension(
|
| + const std::string& extension_id,
|
| + const CertificateInfos& certificate_infos) {
|
| + LOG(ERROR) << "set certificates for extension " << extension_id;
|
| +
|
| + task_runner_->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&IOPart::SetCertificatesProvidedByExtension,
|
| + base::Unretained(io_part_), extension_id, certificate_infos));
|
| +}
|
| +
|
| +} // namespace chromeos
|
|
|