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

Side by Side Diff: chrome/browser/extensions/api/platform_keys/platform_keys_api.cc

Issue 1141253003: chrome.platformKeys: Add filtering by certificate types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 chromeos::PlatformKeysServiceFactory::GetForBrowserContext( 161 chromeos::PlatformKeysServiceFactory::GetForBrowserContext(
162 browser_context()); 162 browser_context());
163 DCHECK(service); 163 DCHECK(service);
164 164
165 chromeos::platform_keys::ClientCertificateRequest request; 165 chromeos::platform_keys::ClientCertificateRequest request;
166 for (const std::vector<char>& cert_authority : 166 for (const std::vector<char>& cert_authority :
167 params->details.request.certificate_authorities) { 167 params->details.request.certificate_authorities) {
168 request.certificate_authorities.push_back( 168 request.certificate_authorities.push_back(
169 std::string(cert_authority.begin(), cert_authority.end())); 169 std::string(cert_authority.begin(), cert_authority.end()));
170 } 170 }
171 for (const api_pk::ClientCertificateType& cert_type :
172 params->details.request.certificate_types) {
173 switch (cert_type) {
174 case api_pk::CLIENT_CERTIFICATE_TYPE_ECDSASIGN:
175 request.certificate_key_types.push_back(
176 net::X509Certificate::kPublicKeyTypeECDSA);
177 break;
178 case api_pk::CLIENT_CERTIFICATE_TYPE_RSASIGN:
179 request.certificate_key_types.push_back(
180 net::X509Certificate::kPublicKeyTypeRSA);
181 break;
182 case api_pk::CLIENT_CERTIFICATE_TYPE_NONE:
183 NOTREACHED();
184 }
185 }
171 content::WebContents* web_contents = nullptr; 186 content::WebContents* web_contents = nullptr;
172 if (params->details.interactive) { 187 if (params->details.interactive) {
173 web_contents = GetSenderWebContents(); 188 web_contents = GetSenderWebContents();
174 189
175 // Ensure that this function is called in a context that allows opening 190 // Ensure that this function is called in a context that allows opening
176 // dialogs. 191 // dialogs.
177 if (!web_contents || 192 if (!web_contents ||
178 !web_modal::PopupManager::FromWebContents(web_contents)) { 193 !web_modal::PopupManager::FromWebContents(web_contents)) {
179 return RespondNow(Error(kErrorInteractiveCallFromBackground)); 194 return RespondNow(Error(kErrorInteractiveCallFromBackground));
180 } 195 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 const std::string& error_message) { 298 const std::string& error_message) {
284 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 299 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
285 if (error_message.empty()) 300 if (error_message.empty())
286 Respond(ArgumentList(api_pki::Sign::Results::Create( 301 Respond(ArgumentList(api_pki::Sign::Results::Create(
287 std::vector<char>(signature.begin(), signature.end())))); 302 std::vector<char>(signature.begin(), signature.end()))));
288 else 303 else
289 Respond(Error(error_message)); 304 Respond(Error(error_message));
290 } 305 }
291 306
292 } // namespace extensions 307 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698