Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(200)

Side by Side Diff: chrome/browser/chromeos/certificate_provider/certificate_provider_service.cc

Issue 1232553003: Add new certificateProvider extension API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/certificate_provider/certificate_provider_serv ice.h"
6
7 #include "base/location.h"
8 #include "base/logging.h"
9 #include "base/bind.h"
10 #include "base/task_runner.h"
11 #include "net/cert/x509_certificate.h"
12 #include "net/ssl/ssl_platform_key.h"
13
14 namespace chromeos {
15
16 CertificateProviderService::IOPart* g_cps_iopart = nullptr;
17
18 class CertificateProviderService::IOPart {
19 public:
20 IOPart() {
21 g_cps_iopart = this;
22 net::fetch_private_key_func = &IOPart::FetchPrivateKey;
23 }
24
25 ~IOPart() {
26 net::fetch_private_key_func = nullptr;
27 }
28
29 static scoped_ptr<net::SSLPrivateKey> FetchPrivateKey(
30 net::X509Certificate* certificate) {
31 CHECK(g_cps_iopart);
32 return g_cps_iopart->FetchPrivateKeyInternal(certificate);
33 }
34
35 scoped_ptr<net::SSLPrivateKey> FetchPrivateKeyInternal(
36 net::X509Certificate* certificate) {
37 return nullptr;
38 }
39
40 void SetCertificatesProvidedByExtension(
41 const std::string& extension_id,
42 const CertificateInfos& certificate_infos) {
43 LOG(ERROR) << "IO: set certificates for extension " << extension_id;
44 extension_to_certificates[extension_id] = certificate_infos;
45 }
46
47 private:
48 std::map<std::string, CertificateInfos> extension_to_certificates;
49
50 DISALLOW_COPY_AND_ASSIGN(IOPart);
51 };
52
53
54 CertificateProviderService::CertificateInfo::CertificateInfo() {
55 }
56
57 CertificateProviderService::CertificateInfo::~CertificateInfo() {
58 }
59
60 CertificateProviderService::CertificateProviderService(
61 scoped_refptr<base::SequencedTaskRunner> task_runner)
62 : io_part_(new IOPart()), task_runner_(task_runner) {}
63
64 CertificateProviderService::~CertificateProviderService() {
65 task_runner_->DeleteSoon(FROM_HERE, io_part_);
66 io_part_ = nullptr;
67 }
68
69 void CertificateProviderService::SetCertificatesProvidedByExtension(
70 const std::string& extension_id,
71 const CertificateInfos& certificate_infos) {
72 LOG(ERROR) << "set certificates for extension " << extension_id;
73
74 task_runner_->PostTask(
75 FROM_HERE,
76 base::Bind(&IOPart::SetCertificatesProvidedByExtension,
77 base::Unretained(io_part_), extension_id, certificate_infos));
78 }
79
80 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698