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

Side by Side Diff: chrome/browser/extensions/api/platform_keys/platform_keys_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: 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/platform_keys/platform_keys_api.h" 5 #include "chrome/browser/extensions/api/platform_keys/platform_keys_api.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 } 117 }
118 118
119 } // namespace platform_keys 119 } // namespace platform_keys
120 120
121 PlatformKeysInternalGetPublicKeyFunction:: 121 PlatformKeysInternalGetPublicKeyFunction::
122 ~PlatformKeysInternalGetPublicKeyFunction() { 122 ~PlatformKeysInternalGetPublicKeyFunction() {
123 } 123 }
124 124
125 ExtensionFunction::ResponseAction 125 ExtensionFunction::ResponseAction
126 PlatformKeysInternalGetPublicKeyFunction::Run() { 126 PlatformKeysInternalGetPublicKeyFunction::Run() {
127 scoped_ptr<api_pki::GetPublicKey::Params> params( 127 std::unique_ptr<api_pki::GetPublicKey::Params> params(
128 api_pki::GetPublicKey::Params::Create(*args_)); 128 api_pki::GetPublicKey::Params::Create(*args_));
129 EXTENSION_FUNCTION_VALIDATE(params); 129 EXTENSION_FUNCTION_VALIDATE(params);
130 130
131 const std::vector<char>& cert_der = params->certificate; 131 const std::vector<char>& cert_der = params->certificate;
132 if (cert_der.empty()) 132 if (cert_der.empty())
133 return RespondNow(Error(platform_keys::kErrorInvalidX509Cert)); 133 return RespondNow(Error(platform_keys::kErrorInvalidX509Cert));
134 scoped_refptr<net::X509Certificate> cert_x509 = 134 scoped_refptr<net::X509Certificate> cert_x509 =
135 net::X509Certificate::CreateFromBytes(cert_der.data(), cert_der.size()); 135 net::X509Certificate::CreateFromBytes(cert_der.data(), cert_der.size());
136 if (!cert_x509) 136 if (!cert_x509)
137 return RespondNow(Error(platform_keys::kErrorInvalidX509Cert)); 137 return RespondNow(Error(platform_keys::kErrorInvalidX509Cert));
(...skipping 23 matching lines...) Expand all
161 key_info.public_key_spki_der.end()), 161 key_info.public_key_spki_der.end()),
162 algorithm))); 162 algorithm)));
163 } 163 }
164 164
165 PlatformKeysInternalSelectClientCertificatesFunction:: 165 PlatformKeysInternalSelectClientCertificatesFunction::
166 ~PlatformKeysInternalSelectClientCertificatesFunction() { 166 ~PlatformKeysInternalSelectClientCertificatesFunction() {
167 } 167 }
168 168
169 ExtensionFunction::ResponseAction 169 ExtensionFunction::ResponseAction
170 PlatformKeysInternalSelectClientCertificatesFunction::Run() { 170 PlatformKeysInternalSelectClientCertificatesFunction::Run() {
171 scoped_ptr<api_pki::SelectClientCertificates::Params> params( 171 std::unique_ptr<api_pki::SelectClientCertificates::Params> params(
172 api_pki::SelectClientCertificates::Params::Create(*args_)); 172 api_pki::SelectClientCertificates::Params::Create(*args_));
173 EXTENSION_FUNCTION_VALIDATE(params); 173 EXTENSION_FUNCTION_VALIDATE(params);
174 174
175 chromeos::PlatformKeysService* service = 175 chromeos::PlatformKeysService* service =
176 chromeos::PlatformKeysServiceFactory::GetForBrowserContext( 176 chromeos::PlatformKeysServiceFactory::GetForBrowserContext(
177 browser_context()); 177 browser_context());
178 DCHECK(service); 178 DCHECK(service);
179 179
180 chromeos::platform_keys::ClientCertificateRequest request; 180 chromeos::platform_keys::ClientCertificateRequest request;
181 for (const std::vector<char>& cert_authority : 181 for (const std::vector<char>& cert_authority :
(...skipping 10 matching lines...) Expand all
192 break; 192 break;
193 case api_pk::CLIENT_CERTIFICATE_TYPE_RSASIGN: 193 case api_pk::CLIENT_CERTIFICATE_TYPE_RSASIGN:
194 request.certificate_key_types.push_back( 194 request.certificate_key_types.push_back(
195 net::X509Certificate::kPublicKeyTypeRSA); 195 net::X509Certificate::kPublicKeyTypeRSA);
196 break; 196 break;
197 case api_pk::CLIENT_CERTIFICATE_TYPE_NONE: 197 case api_pk::CLIENT_CERTIFICATE_TYPE_NONE:
198 NOTREACHED(); 198 NOTREACHED();
199 } 199 }
200 } 200 }
201 201
202 scoped_ptr<net::CertificateList> client_certs; 202 std::unique_ptr<net::CertificateList> client_certs;
203 if (params->details.client_certs) { 203 if (params->details.client_certs) {
204 client_certs.reset(new net::CertificateList); 204 client_certs.reset(new net::CertificateList);
205 for (const std::vector<char>& client_cert_der : 205 for (const std::vector<char>& client_cert_der :
206 *params->details.client_certs) { 206 *params->details.client_certs) {
207 if (client_cert_der.empty()) 207 if (client_cert_der.empty())
208 return RespondNow(Error(platform_keys::kErrorInvalidX509Cert)); 208 return RespondNow(Error(platform_keys::kErrorInvalidX509Cert));
209 scoped_refptr<net::X509Certificate> client_cert_x509 = 209 scoped_refptr<net::X509Certificate> client_cert_x509 =
210 net::X509Certificate::CreateFromBytes(client_cert_der.data(), 210 net::X509Certificate::CreateFromBytes(client_cert_der.data(),
211 client_cert_der.size()); 211 client_cert_der.size());
212 if (!client_cert_x509) 212 if (!client_cert_x509)
(...skipping 19 matching lines...) Expand all
232 request, std::move(client_certs), params->details.interactive, 232 request, std::move(client_certs), params->details.interactive,
233 extension_id(), 233 extension_id(),
234 base::Bind(&PlatformKeysInternalSelectClientCertificatesFunction:: 234 base::Bind(&PlatformKeysInternalSelectClientCertificatesFunction::
235 OnSelectedCertificates, 235 OnSelectedCertificates,
236 this), 236 this),
237 web_contents); 237 web_contents);
238 return RespondLater(); 238 return RespondLater();
239 } 239 }
240 240
241 void PlatformKeysInternalSelectClientCertificatesFunction:: 241 void PlatformKeysInternalSelectClientCertificatesFunction::
242 OnSelectedCertificates(scoped_ptr<net::CertificateList> matches, 242 OnSelectedCertificates(std::unique_ptr<net::CertificateList> matches,
243 const std::string& error_message) { 243 const std::string& error_message) {
244 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 244 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
245 245
246 if (!error_message.empty()) { 246 if (!error_message.empty()) {
247 Respond(Error(error_message)); 247 Respond(Error(error_message));
248 return; 248 return;
249 } 249 }
250 DCHECK(matches); 250 DCHECK(matches);
251 std::vector<api_pk::Match> result_matches; 251 std::vector<api_pk::Match> result_matches;
252 for (const scoped_refptr<net::X509Certificate>& match : *matches) { 252 for (const scoped_refptr<net::X509Certificate>& match : *matches) {
(...skipping 22 matching lines...) Expand all
275 result_matches.push_back(std::move(result_match)); 275 result_matches.push_back(std::move(result_match));
276 } 276 }
277 Respond(ArgumentList( 277 Respond(ArgumentList(
278 api_pki::SelectClientCertificates::Results::Create(result_matches))); 278 api_pki::SelectClientCertificates::Results::Create(result_matches)));
279 } 279 }
280 280
281 PlatformKeysInternalSignFunction::~PlatformKeysInternalSignFunction() { 281 PlatformKeysInternalSignFunction::~PlatformKeysInternalSignFunction() {
282 } 282 }
283 283
284 ExtensionFunction::ResponseAction PlatformKeysInternalSignFunction::Run() { 284 ExtensionFunction::ResponseAction PlatformKeysInternalSignFunction::Run() {
285 scoped_ptr<api_pki::Sign::Params> params( 285 std::unique_ptr<api_pki::Sign::Params> params(
286 api_pki::Sign::Params::Create(*args_)); 286 api_pki::Sign::Params::Create(*args_));
287 EXTENSION_FUNCTION_VALIDATE(params); 287 EXTENSION_FUNCTION_VALIDATE(params);
288 std::string platform_keys_token_id; 288 std::string platform_keys_token_id;
289 if (!params->token_id.empty() && 289 if (!params->token_id.empty() &&
290 !platform_keys::ValidateToken(params->token_id, 290 !platform_keys::ValidateToken(params->token_id,
291 &platform_keys_token_id)) { 291 &platform_keys_token_id)) {
292 return RespondNow(Error(platform_keys::kErrorInvalidToken)); 292 return RespondNow(Error(platform_keys::kErrorInvalidToken));
293 } 293 }
294 294
295 chromeos::PlatformKeysService* service = 295 chromeos::PlatformKeysService* service =
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 } 341 }
342 342
343 PlatformKeysVerifyTLSServerCertificateFunction:: 343 PlatformKeysVerifyTLSServerCertificateFunction::
344 ~PlatformKeysVerifyTLSServerCertificateFunction() { 344 ~PlatformKeysVerifyTLSServerCertificateFunction() {
345 } 345 }
346 346
347 ExtensionFunction::ResponseAction 347 ExtensionFunction::ResponseAction
348 PlatformKeysVerifyTLSServerCertificateFunction::Run() { 348 PlatformKeysVerifyTLSServerCertificateFunction::Run() {
349 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 349 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
350 350
351 scoped_ptr<api_pk::VerifyTLSServerCertificate::Params> params( 351 std::unique_ptr<api_pk::VerifyTLSServerCertificate::Params> params(
352 api_pk::VerifyTLSServerCertificate::Params::Create(*args_)); 352 api_pk::VerifyTLSServerCertificate::Params::Create(*args_));
353 EXTENSION_FUNCTION_VALIDATE(params.get()); 353 EXTENSION_FUNCTION_VALIDATE(params.get());
354 354
355 VerifyTrustAPI::GetFactoryInstance() 355 VerifyTrustAPI::GetFactoryInstance()
356 ->Get(browser_context()) 356 ->Get(browser_context())
357 ->Verify(std::move(params), extension_id(), 357 ->Verify(std::move(params), extension_id(),
358 base::Bind(&PlatformKeysVerifyTLSServerCertificateFunction:: 358 base::Bind(&PlatformKeysVerifyTLSServerCertificateFunction::
359 FinishedVerification, 359 FinishedVerification,
360 this)); 360 this));
361 361
(...skipping 22 matching lines...) Expand all
384 result.debug_errors.push_back(kCertStatusErrors[i].name); 384 result.debug_errors.push_back(kCertStatusErrors[i].name);
385 } 385 }
386 } 386 }
387 } 387 }
388 388
389 Respond(ArgumentList( 389 Respond(ArgumentList(
390 api_pk::VerifyTLSServerCertificate::Results::Create(result))); 390 api_pk::VerifyTLSServerCertificate::Results::Create(result)));
391 } 391 }
392 392
393 } // namespace extensions 393 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698