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 2339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2350 new CertificateReportingServiceCertReporter(cert_reporting_service)); | 2350 new CertificateReportingServiceCertReporter(cert_reporting_service)); |
2351 | 2351 |
2352 SSLErrorHandler::HandleSSLError(web_contents, cert_error, ssl_info, | 2352 SSLErrorHandler::HandleSSLError(web_contents, cert_error, ssl_info, |
2353 request_url, options_mask, | 2353 request_url, options_mask, |
2354 std::move(cert_reporter), callback); | 2354 std::move(cert_reporter), callback); |
2355 } | 2355 } |
2356 | 2356 |
2357 void ChromeContentBrowserClient::SelectClientCertificate( | 2357 void ChromeContentBrowserClient::SelectClientCertificate( |
2358 content::WebContents* web_contents, | 2358 content::WebContents* web_contents, |
2359 net::SSLCertRequestInfo* cert_request_info, | 2359 net::SSLCertRequestInfo* cert_request_info, |
2360 net::CertificateList client_certs, | 2360 net::ClientCertIdentityList client_certs, |
2361 std::unique_ptr<content::ClientCertificateDelegate> delegate) { | 2361 std::unique_ptr<content::ClientCertificateDelegate> delegate) { |
2362 prerender::PrerenderContents* prerender_contents = | 2362 prerender::PrerenderContents* prerender_contents = |
2363 prerender::PrerenderContents::FromWebContents(web_contents); | 2363 prerender::PrerenderContents::FromWebContents(web_contents); |
2364 if (prerender_contents) { | 2364 if (prerender_contents) { |
2365 prerender_contents->Destroy( | 2365 prerender_contents->Destroy( |
2366 prerender::FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED); | 2366 prerender::FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED); |
2367 return; | 2367 return; |
2368 } | 2368 } |
2369 | 2369 |
2370 GURL requesting_url("https://" + cert_request_info->host_and_port.ToString()); | 2370 GURL requesting_url("https://" + cert_request_info->host_and_port.ToString()); |
2371 DCHECK(requesting_url.is_valid()) | 2371 DCHECK(requesting_url.is_valid()) |
2372 << "Invalid URL string: https://" | 2372 << "Invalid URL string: https://" |
2373 << cert_request_info->host_and_port.ToString(); | 2373 << cert_request_info->host_and_port.ToString(); |
2374 | 2374 |
2375 Profile* profile = | 2375 Profile* profile = |
2376 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 2376 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
2377 std::unique_ptr<base::Value> filter = | 2377 std::unique_ptr<base::Value> filter = |
2378 HostContentSettingsMapFactory::GetForProfile(profile)->GetWebsiteSetting( | 2378 HostContentSettingsMapFactory::GetForProfile(profile)->GetWebsiteSetting( |
2379 requesting_url, requesting_url, | 2379 requesting_url, requesting_url, |
2380 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, std::string(), NULL); | 2380 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, std::string(), NULL); |
2381 | 2381 |
2382 if (filter.get()) { | 2382 if (filter.get()) { |
2383 // Try to automatically select a client certificate. | 2383 // Try to automatically select a client certificate. |
2384 if (filter->IsType(base::Value::Type::DICTIONARY)) { | 2384 if (filter->IsType(base::Value::Type::DICTIONARY)) { |
2385 base::DictionaryValue* filter_dict = | 2385 base::DictionaryValue* filter_dict = |
2386 static_cast<base::DictionaryValue*>(filter.get()); | 2386 static_cast<base::DictionaryValue*>(filter.get()); |
2387 | 2387 |
2388 for (size_t i = 0; i < client_certs.size(); ++i) { | 2388 for (size_t i = 0; i < client_certs.size(); ++i) { |
2389 if (CertMatchesFilter(*client_certs[i].get(), *filter_dict)) { | 2389 if (CertMatchesFilter(*client_certs[i]->certificate(), *filter_dict)) { |
2390 // Use the first certificate that is matched by the filter. | 2390 // Use the first certificate that is matched by the filter. |
2391 delegate->ContinueWithCertificate(client_certs[i].get()); | 2391 // The callback will own |client_certs[i]| and |delegate|, keeping |
| 2392 // them alive until after ContinueWithCertificate is called. |
| 2393 scoped_refptr<net::X509Certificate> cert = |
| 2394 client_certs[i]->certificate(); |
| 2395 net::ClientCertIdentity::SelfOwningAcquirePrivateKey( |
| 2396 std::move(client_certs[i]), |
| 2397 base::Bind( |
| 2398 &content::ClientCertificateDelegate::ContinueWithCertificate, |
| 2399 base::Passed(&delegate), std::move(cert))); |
2392 return; | 2400 return; |
2393 } | 2401 } |
2394 } | 2402 } |
2395 } else { | 2403 } else { |
2396 NOTREACHED(); | 2404 NOTREACHED(); |
2397 } | 2405 } |
2398 } | 2406 } |
2399 | 2407 |
2400 chrome::ShowSSLClientCertificateSelector(web_contents, cert_request_info, | 2408 chrome::ShowSSLClientCertificateSelector(web_contents, cert_request_info, |
2401 std::move(client_certs), | 2409 std::move(client_certs), |
(...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3580 RedirectNonUINonIOBrowserThreadsToTaskScheduler() { | 3588 RedirectNonUINonIOBrowserThreadsToTaskScheduler() { |
3581 return variations::GetVariationParamValue( | 3589 return variations::GetVariationParamValue( |
3582 "BrowserScheduler", "RedirectNonUINonIOBrowserThreads") == "true"; | 3590 "BrowserScheduler", "RedirectNonUINonIOBrowserThreads") == "true"; |
3583 } | 3591 } |
3584 | 3592 |
3585 // static | 3593 // static |
3586 void ChromeContentBrowserClient::SetDefaultQuotaSettingsForTesting( | 3594 void ChromeContentBrowserClient::SetDefaultQuotaSettingsForTesting( |
3587 const storage::QuotaSettings* settings) { | 3595 const storage::QuotaSettings* settings) { |
3588 g_default_quota_settings = settings; | 3596 g_default_quota_settings = settings; |
3589 } | 3597 } |
OLD | NEW |