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

Side by Side Diff: chrome/browser/chrome_content_browser_client.cc

Issue 2898573002: Refactor client cert private key handling. (Closed)
Patch Set: removed no longer needed forward declaration Created 3 years, 6 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chrome_content_browser_client.h" 5 #include "chrome/browser/chrome_content_browser_client.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 2257 matching lines...) Expand 10 before | Expand all | Expand 10 after
2268 new CertificateReportingServiceCertReporter(cert_reporting_service)); 2268 new CertificateReportingServiceCertReporter(cert_reporting_service));
2269 2269
2270 SSLErrorHandler::HandleSSLError(web_contents, cert_error, ssl_info, 2270 SSLErrorHandler::HandleSSLError(web_contents, cert_error, ssl_info,
2271 request_url, options_mask, 2271 request_url, options_mask,
2272 std::move(cert_reporter), callback); 2272 std::move(cert_reporter), callback);
2273 } 2273 }
2274 2274
2275 void ChromeContentBrowserClient::SelectClientCertificate( 2275 void ChromeContentBrowserClient::SelectClientCertificate(
2276 content::WebContents* web_contents, 2276 content::WebContents* web_contents,
2277 net::SSLCertRequestInfo* cert_request_info, 2277 net::SSLCertRequestInfo* cert_request_info,
2278 net::CertificateList client_certs, 2278 net::ClientCertIdentityList client_certs,
2279 std::unique_ptr<content::ClientCertificateDelegate> delegate) { 2279 std::unique_ptr<content::ClientCertificateDelegate> delegate) {
2280 prerender::PrerenderContents* prerender_contents = 2280 prerender::PrerenderContents* prerender_contents =
2281 prerender::PrerenderContents::FromWebContents(web_contents); 2281 prerender::PrerenderContents::FromWebContents(web_contents);
2282 if (prerender_contents) { 2282 if (prerender_contents) {
2283 prerender_contents->Destroy( 2283 prerender_contents->Destroy(
2284 prerender::FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED); 2284 prerender::FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED);
2285 return; 2285 return;
2286 } 2286 }
2287 2287
2288 GURL requesting_url("https://" + cert_request_info->host_and_port.ToString()); 2288 GURL requesting_url("https://" + cert_request_info->host_and_port.ToString());
2289 DCHECK(requesting_url.is_valid()) 2289 DCHECK(requesting_url.is_valid())
2290 << "Invalid URL string: https://" 2290 << "Invalid URL string: https://"
2291 << cert_request_info->host_and_port.ToString(); 2291 << cert_request_info->host_and_port.ToString();
2292 2292
2293 Profile* profile = 2293 Profile* profile =
2294 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 2294 Profile::FromBrowserContext(web_contents->GetBrowserContext());
2295 std::unique_ptr<base::Value> filter = 2295 std::unique_ptr<base::Value> filter =
2296 HostContentSettingsMapFactory::GetForProfile(profile)->GetWebsiteSetting( 2296 HostContentSettingsMapFactory::GetForProfile(profile)->GetWebsiteSetting(
2297 requesting_url, requesting_url, 2297 requesting_url, requesting_url,
2298 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, std::string(), NULL); 2298 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, std::string(), NULL);
2299 2299
2300 if (filter.get()) { 2300 if (filter.get()) {
2301 // Try to automatically select a client certificate. 2301 // Try to automatically select a client certificate.
2302 if (filter->IsType(base::Value::Type::DICTIONARY)) { 2302 if (filter->IsType(base::Value::Type::DICTIONARY)) {
2303 base::DictionaryValue* filter_dict = 2303 base::DictionaryValue* filter_dict =
2304 static_cast<base::DictionaryValue*>(filter.get()); 2304 static_cast<base::DictionaryValue*>(filter.get());
2305 2305
2306 for (size_t i = 0; i < client_certs.size(); ++i) { 2306 for (size_t i = 0; i < client_certs.size(); ++i) {
2307 if (CertMatchesFilter(*client_certs[i].get(), *filter_dict)) { 2307 if (CertMatchesFilter(*client_certs[i]->certificate(), *filter_dict)) {
2308 // Use the first certificate that is matched by the filter. 2308 // Use the first certificate that is matched by the filter.
2309 delegate->ContinueWithCertificate(client_certs[i].get()); 2309 // The callback will own |client_certs[i]| and |delegate|, keeping
2310 // them alive until after ContinueWithCertificate is called.
2311 scoped_refptr<net::X509Certificate> cert =
2312 client_certs[i]->certificate();
2313 net::ClientCertIdentity::SelfOwningAcquirePrivateKey(
2314 std::move(client_certs[i]),
2315 base::Bind(
2316 &content::ClientCertificateDelegate::ContinueWithCertificate,
2317 base::Passed(&delegate), std::move(cert)));
2310 return; 2318 return;
2311 } 2319 }
2312 } 2320 }
2313 } else { 2321 } else {
2314 NOTREACHED(); 2322 NOTREACHED();
2315 } 2323 }
2316 } 2324 }
2317 2325
2318 chrome::ShowSSLClientCertificateSelector(web_contents, cert_request_info, 2326 chrome::ShowSSLClientCertificateSelector(web_contents, cert_request_info,
2319 std::move(client_certs), 2327 std::move(client_certs),
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after
3436 3444
3437 base::FilePath ChromeContentBrowserClient::GetLoggingFileName() { 3445 base::FilePath ChromeContentBrowserClient::GetLoggingFileName() {
3438 return logging::GetLogFileName(); 3446 return logging::GetLogFileName();
3439 } 3447 }
3440 3448
3441 // static 3449 // static
3442 void ChromeContentBrowserClient::SetDefaultQuotaSettingsForTesting( 3450 void ChromeContentBrowserClient::SetDefaultQuotaSettingsForTesting(
3443 const storage::QuotaSettings* settings) { 3451 const storage::QuotaSettings* settings) {
3444 g_default_quota_settings = settings; 3452 g_default_quota_settings = settings;
3445 } 3453 }
OLDNEW
« no previous file with comments | « chrome/browser/chrome_content_browser_client.h ('k') | chrome/browser/chromeos/net/client_cert_store_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698