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

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

Issue 859213006: Cancel client auth requests when not promptable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@client-auth-cancel-1
Patch Set: fix test Created 5 years, 9 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 <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 #include "components/signin/core/common/profile_management_switches.h" 106 #include "components/signin/core/common/profile_management_switches.h"
107 #include "components/translate/core/common/translate_switches.h" 107 #include "components/translate/core/common/translate_switches.h"
108 #include "components/url_fixer/url_fixer.h" 108 #include "components/url_fixer/url_fixer.h"
109 #include "content/public/browser/browser_child_process_host.h" 109 #include "content/public/browser/browser_child_process_host.h"
110 #include "content/public/browser/browser_main_parts.h" 110 #include "content/public/browser/browser_main_parts.h"
111 #include "content/public/browser/browser_ppapi_host.h" 111 #include "content/public/browser/browser_ppapi_host.h"
112 #include "content/public/browser/browser_thread.h" 112 #include "content/public/browser/browser_thread.h"
113 #include "content/public/browser/browser_url_handler.h" 113 #include "content/public/browser/browser_url_handler.h"
114 #include "content/public/browser/child_process_data.h" 114 #include "content/public/browser/child_process_data.h"
115 #include "content/public/browser/child_process_security_policy.h" 115 #include "content/public/browser/child_process_security_policy.h"
116 #include "content/public/browser/client_certificate_delegate.h"
116 #include "content/public/browser/permission_type.h" 117 #include "content/public/browser/permission_type.h"
117 #include "content/public/browser/render_frame_host.h" 118 #include "content/public/browser/render_frame_host.h"
118 #include "content/public/browser/render_process_host.h" 119 #include "content/public/browser/render_process_host.h"
119 #include "content/public/browser/render_view_host.h" 120 #include "content/public/browser/render_view_host.h"
120 #include "content/public/browser/resource_context.h" 121 #include "content/public/browser/resource_context.h"
121 #include "content/public/browser/site_instance.h" 122 #include "content/public/browser/site_instance.h"
122 #include "content/public/browser/web_contents.h" 123 #include "content/public/browser/web_contents.h"
123 #include "content/public/common/child_process_host.h" 124 #include "content/public/common/child_process_host.h"
124 #include "content/public/common/content_descriptors.h" 125 #include "content/public/common/content_descriptors.h"
125 #include "content/public/common/url_utils.h" 126 #include "content/public/common/url_utils.h"
(...skipping 1709 matching lines...) Expand 10 before | Expand all | Expand 10 after
1835 if (strict_enforcement) 1836 if (strict_enforcement)
1836 options_mask |= SSLBlockingPage::STRICT_ENFORCEMENT; 1837 options_mask |= SSLBlockingPage::STRICT_ENFORCEMENT;
1837 if (expired_previous_decision) 1838 if (expired_previous_decision)
1838 options_mask |= SSLBlockingPage::EXPIRED_BUT_PREVIOUSLY_ALLOWED; 1839 options_mask |= SSLBlockingPage::EXPIRED_BUT_PREVIOUSLY_ALLOWED;
1839 1840
1840 SSLErrorHandler::HandleSSLError( 1841 SSLErrorHandler::HandleSSLError(
1841 tab, cert_error, ssl_info, request_url, options_mask, callback); 1842 tab, cert_error, ssl_info, request_url, options_mask, callback);
1842 } 1843 }
1843 1844
1844 void ChromeContentBrowserClient::SelectClientCertificate( 1845 void ChromeContentBrowserClient::SelectClientCertificate(
1845 int render_process_id, 1846 content::WebContents* web_contents,
1846 int render_frame_id,
1847 net::SSLCertRequestInfo* cert_request_info, 1847 net::SSLCertRequestInfo* cert_request_info,
1848 const base::Callback<void(net::X509Certificate*)>& callback) { 1848 scoped_ptr<content::ClientCertificateDelegate> delegate) {
1849 content::RenderFrameHost* rfh = content::RenderFrameHost::FromID(
1850 render_process_id, render_frame_id);
1851 WebContents* tab = WebContents::FromRenderFrameHost(rfh);
1852 if (!tab) {
1853 // TODO(davidben): This makes the request hang, but returning no certificate
1854 // also breaks. It should abort the request. See https://crbug.com/417092
1855 return;
1856 }
1857
1858 prerender::PrerenderContents* prerender_contents = 1849 prerender::PrerenderContents* prerender_contents =
1859 prerender::PrerenderContents::FromWebContents(tab); 1850 prerender::PrerenderContents::FromWebContents(web_contents);
1860 if (prerender_contents) { 1851 if (prerender_contents) {
1861 prerender_contents->Destroy( 1852 prerender_contents->Destroy(
1862 prerender::FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED); 1853 prerender::FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED);
1863 return; 1854 return;
1864 } 1855 }
1865 1856
1866 GURL requesting_url("https://" + cert_request_info->host_and_port.ToString()); 1857 GURL requesting_url("https://" + cert_request_info->host_and_port.ToString());
1867 DCHECK(requesting_url.is_valid()) 1858 DCHECK(requesting_url.is_valid())
1868 << "Invalid URL string: https://" 1859 << "Invalid URL string: https://"
1869 << cert_request_info->host_and_port.ToString(); 1860 << cert_request_info->host_and_port.ToString();
1870 1861
1871 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); 1862 Profile* profile =
1863 Profile::FromBrowserContext(web_contents->GetBrowserContext());
1872 scoped_ptr<base::Value> filter = 1864 scoped_ptr<base::Value> filter =
1873 profile->GetHostContentSettingsMap()->GetWebsiteSetting( 1865 profile->GetHostContentSettingsMap()->GetWebsiteSetting(
1874 requesting_url, 1866 requesting_url,
1875 requesting_url, 1867 requesting_url,
1876 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, 1868 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE,
1877 std::string(), 1869 std::string(),
1878 NULL); 1870 NULL);
1879 1871
1880 if (filter.get()) { 1872 if (filter.get()) {
1881 // Try to automatically select a client certificate. 1873 // Try to automatically select a client certificate.
1882 if (filter->IsType(base::Value::TYPE_DICTIONARY)) { 1874 if (filter->IsType(base::Value::TYPE_DICTIONARY)) {
1883 base::DictionaryValue* filter_dict = 1875 base::DictionaryValue* filter_dict =
1884 static_cast<base::DictionaryValue*>(filter.get()); 1876 static_cast<base::DictionaryValue*>(filter.get());
1885 1877
1886 const std::vector<scoped_refptr<net::X509Certificate> >& 1878 const std::vector<scoped_refptr<net::X509Certificate> >&
1887 all_client_certs = cert_request_info->client_certs; 1879 all_client_certs = cert_request_info->client_certs;
1888 for (size_t i = 0; i < all_client_certs.size(); ++i) { 1880 for (size_t i = 0; i < all_client_certs.size(); ++i) {
1889 if (CertMatchesFilter(*all_client_certs[i].get(), *filter_dict)) { 1881 if (CertMatchesFilter(*all_client_certs[i].get(), *filter_dict)) {
1890 // Use the first certificate that is matched by the filter. 1882 // Use the first certificate that is matched by the filter.
1891 callback.Run(all_client_certs[i].get()); 1883 delegate->ContinueWithCertificate(all_client_certs[i].get());
1892 return; 1884 return;
1893 } 1885 }
1894 } 1886 }
1895 } else { 1887 } else {
1896 NOTREACHED(); 1888 NOTREACHED();
1897 } 1889 }
1898 } 1890 }
1899 1891
1900 chrome::ShowSSLClientCertificateSelector(tab, cert_request_info, callback); 1892 chrome::ShowSSLClientCertificateSelector(web_contents, cert_request_info,
1893 delegate.Pass());
1901 } 1894 }
1902 1895
1903 void ChromeContentBrowserClient::AddCertificate( 1896 void ChromeContentBrowserClient::AddCertificate(
1904 net::CertificateMimeType cert_type, 1897 net::CertificateMimeType cert_type,
1905 const void* cert_data, 1898 const void* cert_data,
1906 size_t cert_size, 1899 size_t cert_size,
1907 int render_process_id, 1900 int render_process_id,
1908 int render_frame_id) { 1901 int render_frame_id) {
1909 chrome::SSLAddCertificate(cert_type, cert_data, cert_size, 1902 chrome::SSLAddCertificate(cert_type, cert_data, cert_size,
1910 render_process_id, render_frame_id); 1903 render_process_id, render_frame_id);
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
2634 switches::kDisableWebRtcEncryption, 2627 switches::kDisableWebRtcEncryption,
2635 }; 2628 };
2636 to_command_line->CopySwitchesFrom(from_command_line, 2629 to_command_line->CopySwitchesFrom(from_command_line,
2637 kWebRtcDevSwitchNames, 2630 kWebRtcDevSwitchNames,
2638 arraysize(kWebRtcDevSwitchNames)); 2631 arraysize(kWebRtcDevSwitchNames));
2639 } 2632 }
2640 } 2633 }
2641 #endif // defined(ENABLE_WEBRTC) 2634 #endif // defined(ENABLE_WEBRTC)
2642 2635
2643 } // namespace chrome 2636 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698