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

Side by Side Diff: chrome/browser/extensions/api/certificate_provider/certificate_provider_api.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 years, 8 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
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 #include "chrome/browser/extensions/api/certificate_provider/certificate_provide r_api.h" 5 #include "chrome/browser/extensions/api/certificate_provider/certificate_provide r_api.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory>
10 #include <vector> 11 #include <vector>
11 12
12 #include "base/logging.h" 13 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "chrome/browser/chromeos/certificate_provider/certificate_provider_serv ice.h" 14 #include "chrome/browser/chromeos/certificate_provider/certificate_provider_serv ice.h"
15 #include "chrome/browser/chromeos/certificate_provider/certificate_provider_serv ice_factory.h" 15 #include "chrome/browser/chromeos/certificate_provider/certificate_provider_serv ice_factory.h"
16 #include "chrome/common/extensions/api/certificate_provider.h" 16 #include "chrome/common/extensions/api/certificate_provider.h"
17 #include "chrome/common/extensions/api/certificate_provider_internal.h" 17 #include "chrome/common/extensions/api/certificate_provider_internal.h"
18 #include "content/public/common/console_message_level.h" 18 #include "content/public/common/console_message_level.h"
19 #include "net/cert/x509_certificate.h" 19 #include "net/cert/x509_certificate.h"
20 #include "net/ssl/ssl_private_key.h" 20 #include "net/ssl/ssl_private_key.h"
21 21
22 namespace extensions { 22 namespace extensions {
23 23
24 namespace api_cp = api::certificate_provider; 24 namespace api_cp = api::certificate_provider;
25 namespace api_cpi = api::certificate_provider_internal; 25 namespace api_cpi = api::certificate_provider_internal;
26 26
27 namespace { 27 namespace {
28 28
29 const char kErrorInvalidX509Cert[] = 29 const char kErrorInvalidX509Cert[] =
30 "Certificate is not a valid X.509 certificate."; 30 "Certificate is not a valid X.509 certificate.";
31 const char kErrorECDSANotSupported[] = "Key type ECDSA not supported."; 31 const char kErrorECDSANotSupported[] = "Key type ECDSA not supported.";
32 const char kErrorUnknownKeyType[] = "Key type unknown."; 32 const char kErrorUnknownKeyType[] = "Key type unknown.";
33 const char kErrorAborted[] = "Request was aborted."; 33 const char kErrorAborted[] = "Request was aborted.";
34 const char kErrorTimeout[] = "Request timed out, reply rejected."; 34 const char kErrorTimeout[] = "Request timed out, reply rejected.";
35 35
36 } // namespace 36 } // namespace
37 37
38 CertificateProviderInternalReportCertificatesFunction:: 38 CertificateProviderInternalReportCertificatesFunction::
39 ~CertificateProviderInternalReportCertificatesFunction() {} 39 ~CertificateProviderInternalReportCertificatesFunction() {}
40 40
41 ExtensionFunction::ResponseAction 41 ExtensionFunction::ResponseAction
42 CertificateProviderInternalReportCertificatesFunction::Run() { 42 CertificateProviderInternalReportCertificatesFunction::Run() {
43 scoped_ptr<api_cpi::ReportCertificates::Params> params( 43 std::unique_ptr<api_cpi::ReportCertificates::Params> params(
44 api_cpi::ReportCertificates::Params::Create(*args_)); 44 api_cpi::ReportCertificates::Params::Create(*args_));
45 EXTENSION_FUNCTION_VALIDATE(params); 45 EXTENSION_FUNCTION_VALIDATE(params);
46 46
47 chromeos::CertificateProviderService* const service = 47 chromeos::CertificateProviderService* const service =
48 chromeos::CertificateProviderServiceFactory::GetForBrowserContext( 48 chromeos::CertificateProviderServiceFactory::GetForBrowserContext(
49 browser_context()); 49 browser_context());
50 DCHECK(service); 50 DCHECK(service);
51 51
52 if (!params->certificates) { 52 if (!params->certificates) {
53 // In the public API, the certificates parameter is mandatory. We only run 53 // In the public API, the certificates parameter is mandatory. We only run
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 } 146 }
147 } 147 }
148 return true; 148 return true;
149 } 149 }
150 150
151 CertificateProviderInternalReportSignatureFunction:: 151 CertificateProviderInternalReportSignatureFunction::
152 ~CertificateProviderInternalReportSignatureFunction() {} 152 ~CertificateProviderInternalReportSignatureFunction() {}
153 153
154 ExtensionFunction::ResponseAction 154 ExtensionFunction::ResponseAction
155 CertificateProviderInternalReportSignatureFunction::Run() { 155 CertificateProviderInternalReportSignatureFunction::Run() {
156 scoped_ptr<api_cpi::ReportSignature::Params> params( 156 std::unique_ptr<api_cpi::ReportSignature::Params> params(
157 api_cpi::ReportSignature::Params::Create(*args_)); 157 api_cpi::ReportSignature::Params::Create(*args_));
158 EXTENSION_FUNCTION_VALIDATE(params); 158 EXTENSION_FUNCTION_VALIDATE(params);
159 159
160 chromeos::CertificateProviderService* const service = 160 chromeos::CertificateProviderService* const service =
161 chromeos::CertificateProviderServiceFactory::GetForBrowserContext( 161 chromeos::CertificateProviderServiceFactory::GetForBrowserContext(
162 browser_context()); 162 browser_context());
163 DCHECK(service); 163 DCHECK(service);
164 164
165 std::vector<uint8_t> signature; 165 std::vector<uint8_t> signature;
166 // If an error occurred, |signature| will not be set. 166 // If an error occurred, |signature| will not be set.
167 if (params->signature) 167 if (params->signature)
168 signature.assign(params->signature->begin(), params->signature->end()); 168 signature.assign(params->signature->begin(), params->signature->end());
169 169
170 service->ReplyToSignRequest(extension_id(), params->request_id, signature); 170 service->ReplyToSignRequest(extension_id(), params->request_id, signature);
171 return RespondNow(NoArguments()); 171 return RespondNow(NoArguments());
172 } 172 }
173 173
174 } // namespace extensions 174 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698