OLD | NEW |
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 2315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2326 new CertificateReportingServiceCertReporter(cert_reporting_service)); | 2326 new CertificateReportingServiceCertReporter(cert_reporting_service)); |
2327 | 2327 |
2328 SSLErrorHandler::HandleSSLError(web_contents, cert_error, ssl_info, | 2328 SSLErrorHandler::HandleSSLError(web_contents, cert_error, ssl_info, |
2329 request_url, options_mask, | 2329 request_url, options_mask, |
2330 std::move(cert_reporter), callback); | 2330 std::move(cert_reporter), callback); |
2331 } | 2331 } |
2332 | 2332 |
2333 void ChromeContentBrowserClient::SelectClientCertificate( | 2333 void ChromeContentBrowserClient::SelectClientCertificate( |
2334 content::WebContents* web_contents, | 2334 content::WebContents* web_contents, |
2335 net::SSLCertRequestInfo* cert_request_info, | 2335 net::SSLCertRequestInfo* cert_request_info, |
2336 net::CertificateList client_certs, | 2336 net::ClientCertIdentityList client_certs, |
2337 std::unique_ptr<content::ClientCertificateDelegate> delegate) { | 2337 std::unique_ptr<content::ClientCertificateDelegate> delegate) { |
2338 prerender::PrerenderContents* prerender_contents = | 2338 prerender::PrerenderContents* prerender_contents = |
2339 prerender::PrerenderContents::FromWebContents(web_contents); | 2339 prerender::PrerenderContents::FromWebContents(web_contents); |
2340 if (prerender_contents) { | 2340 if (prerender_contents) { |
2341 prerender_contents->Destroy( | 2341 prerender_contents->Destroy( |
2342 prerender::FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED); | 2342 prerender::FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED); |
2343 return; | 2343 return; |
2344 } | 2344 } |
2345 | 2345 |
2346 GURL requesting_url("https://" + cert_request_info->host_and_port.ToString()); | 2346 GURL requesting_url("https://" + cert_request_info->host_and_port.ToString()); |
2347 DCHECK(requesting_url.is_valid()) | 2347 DCHECK(requesting_url.is_valid()) |
2348 << "Invalid URL string: https://" | 2348 << "Invalid URL string: https://" |
2349 << cert_request_info->host_and_port.ToString(); | 2349 << cert_request_info->host_and_port.ToString(); |
2350 | 2350 |
2351 Profile* profile = | 2351 Profile* profile = |
2352 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 2352 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
2353 std::unique_ptr<base::Value> filter = | 2353 std::unique_ptr<base::Value> filter = |
2354 HostContentSettingsMapFactory::GetForProfile(profile)->GetWebsiteSetting( | 2354 HostContentSettingsMapFactory::GetForProfile(profile)->GetWebsiteSetting( |
2355 requesting_url, requesting_url, | 2355 requesting_url, requesting_url, |
2356 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, std::string(), NULL); | 2356 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, std::string(), NULL); |
2357 | 2357 |
2358 if (filter.get()) { | 2358 if (filter.get()) { |
2359 // Try to automatically select a client certificate. | 2359 // Try to automatically select a client certificate. |
2360 if (filter->IsType(base::Value::Type::DICTIONARY)) { | 2360 if (filter->IsType(base::Value::Type::DICTIONARY)) { |
2361 base::DictionaryValue* filter_dict = | 2361 base::DictionaryValue* filter_dict = |
2362 static_cast<base::DictionaryValue*>(filter.get()); | 2362 static_cast<base::DictionaryValue*>(filter.get()); |
2363 | 2363 |
2364 for (size_t i = 0; i < client_certs.size(); ++i) { | 2364 for (size_t i = 0; i < client_certs.size(); ++i) { |
2365 if (CertMatchesFilter(*client_certs[i].get(), *filter_dict)) { | 2365 if (CertMatchesFilter(*client_certs[i]->certificate(), *filter_dict)) { |
2366 // Use the first certificate that is matched by the filter. | 2366 // Use the first certificate that is matched by the filter. |
2367 delegate->ContinueWithCertificate(client_certs[i].get()); | 2367 // The callback will own |client_certs[i]| and |delegate|, keeping |
| 2368 // them alive until after ContinueWithCertificate is called. |
| 2369 scoped_refptr<net::X509Certificate> cert = |
| 2370 client_certs[i]->certificate(); |
| 2371 net::ClientCertIdentity::SelfOwningAcquirePrivateKey( |
| 2372 std::move(client_certs[i]), |
| 2373 base::Bind( |
| 2374 &content::ClientCertificateDelegate::ContinueWithCertificate, |
| 2375 base::Passed(&delegate), std::move(cert))); |
2368 return; | 2376 return; |
2369 } | 2377 } |
2370 } | 2378 } |
2371 } else { | 2379 } else { |
2372 NOTREACHED(); | 2380 NOTREACHED(); |
2373 } | 2381 } |
2374 } | 2382 } |
2375 | 2383 |
2376 chrome::ShowSSLClientCertificateSelector(web_contents, cert_request_info, | 2384 chrome::ShowSSLClientCertificateSelector(web_contents, cert_request_info, |
2377 std::move(client_certs), | 2385 std::move(client_certs), |
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3504 RedirectNonUINonIOBrowserThreadsToTaskScheduler() { | 3512 RedirectNonUINonIOBrowserThreadsToTaskScheduler() { |
3505 return variations::GetVariationParamValue( | 3513 return variations::GetVariationParamValue( |
3506 "BrowserScheduler", "RedirectNonUINonIOBrowserThreads") == "true"; | 3514 "BrowserScheduler", "RedirectNonUINonIOBrowserThreads") == "true"; |
3507 } | 3515 } |
3508 | 3516 |
3509 // static | 3517 // static |
3510 void ChromeContentBrowserClient::SetDefaultQuotaSettingsForTesting( | 3518 void ChromeContentBrowserClient::SetDefaultQuotaSettingsForTesting( |
3511 const storage::QuotaSettings* settings) { | 3519 const storage::QuotaSettings* settings) { |
3512 g_default_quota_settings = settings; | 3520 g_default_quota_settings = settings; |
3513 } | 3521 } |
OLD | NEW |