Chromium Code Reviews| 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 <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 Loading... | |
| 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 1712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1838 if (strict_enforcement) | 1839 if (strict_enforcement) |
| 1839 options_mask |= SSLBlockingPage::STRICT_ENFORCEMENT; | 1840 options_mask |= SSLBlockingPage::STRICT_ENFORCEMENT; |
| 1840 if (expired_previous_decision) | 1841 if (expired_previous_decision) |
| 1841 options_mask |= SSLBlockingPage::EXPIRED_BUT_PREVIOUSLY_ALLOWED; | 1842 options_mask |= SSLBlockingPage::EXPIRED_BUT_PREVIOUSLY_ALLOWED; |
| 1842 | 1843 |
| 1843 SSLErrorHandler::HandleSSLError( | 1844 SSLErrorHandler::HandleSSLError( |
| 1844 tab, cert_error, ssl_info, request_url, options_mask, callback); | 1845 tab, cert_error, ssl_info, request_url, options_mask, callback); |
| 1845 } | 1846 } |
| 1846 | 1847 |
| 1847 void ChromeContentBrowserClient::SelectClientCertificate( | 1848 void ChromeContentBrowserClient::SelectClientCertificate( |
| 1848 int render_process_id, | 1849 content::WebContents* web_contents, |
| 1849 int render_frame_id, | |
| 1850 net::SSLCertRequestInfo* cert_request_info, | 1850 net::SSLCertRequestInfo* cert_request_info, |
| 1851 const base::Callback<void(net::X509Certificate*)>& callback) { | 1851 scoped_ptr<content::ClientCertificateDelegate> delegate) { |
| 1852 content::RenderFrameHost* rfh = content::RenderFrameHost::FromID( | 1852 prerender::PrerenderContents* prerender_contents = |
| 1853 render_process_id, render_frame_id); | 1853 prerender::PrerenderContents::FromWebContents(web_contents); |
| 1854 WebContents* tab = WebContents::FromRenderFrameHost(rfh); | 1854 if (prerender_contents) { |
| 1855 if (!tab) { | 1855 prerender_contents->Destroy( |
| 1856 // TODO(davidben): This makes the request hang, but returning no certificate | 1856 prerender::FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED); |
| 1857 // also breaks. It should abort the request. See https://crbug.com/417092 | 1857 delegate->CancelCertificateSelection(); |
|
sky
2015/02/20 21:32:29
Since the delegate is going to be deleted in the r
davidben
2015/02/24 22:38:40
Switched the delegate to trigger cancel in the des
| |
| 1858 return; | 1858 return; |
| 1859 } | 1859 } |
| 1860 | 1860 |
| 1861 prerender::PrerenderContents* prerender_contents = | |
| 1862 prerender::PrerenderContents::FromWebContents(tab); | |
| 1863 if (prerender_contents) { | |
| 1864 prerender_contents->Destroy( | |
| 1865 prerender::FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED); | |
| 1866 return; | |
| 1867 } | |
| 1868 | |
| 1869 GURL requesting_url("https://" + cert_request_info->host_and_port.ToString()); | 1861 GURL requesting_url("https://" + cert_request_info->host_and_port.ToString()); |
| 1870 DCHECK(requesting_url.is_valid()) | 1862 DCHECK(requesting_url.is_valid()) |
| 1871 << "Invalid URL string: https://" | 1863 << "Invalid URL string: https://" |
| 1872 << cert_request_info->host_and_port.ToString(); | 1864 << cert_request_info->host_and_port.ToString(); |
| 1873 | 1865 |
| 1874 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); | 1866 Profile* profile = |
| 1867 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | |
| 1875 scoped_ptr<base::Value> filter = | 1868 scoped_ptr<base::Value> filter = |
| 1876 profile->GetHostContentSettingsMap()->GetWebsiteSetting( | 1869 profile->GetHostContentSettingsMap()->GetWebsiteSetting( |
| 1877 requesting_url, | 1870 requesting_url, |
| 1878 requesting_url, | 1871 requesting_url, |
| 1879 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, | 1872 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, |
| 1880 std::string(), | 1873 std::string(), |
| 1881 NULL); | 1874 NULL); |
| 1882 | 1875 |
| 1883 if (filter.get()) { | 1876 if (filter.get()) { |
| 1884 // Try to automatically select a client certificate. | 1877 // Try to automatically select a client certificate. |
| 1885 if (filter->IsType(base::Value::TYPE_DICTIONARY)) { | 1878 if (filter->IsType(base::Value::TYPE_DICTIONARY)) { |
| 1886 base::DictionaryValue* filter_dict = | 1879 base::DictionaryValue* filter_dict = |
| 1887 static_cast<base::DictionaryValue*>(filter.get()); | 1880 static_cast<base::DictionaryValue*>(filter.get()); |
| 1888 | 1881 |
| 1889 const std::vector<scoped_refptr<net::X509Certificate> >& | 1882 const std::vector<scoped_refptr<net::X509Certificate> >& |
| 1890 all_client_certs = cert_request_info->client_certs; | 1883 all_client_certs = cert_request_info->client_certs; |
| 1891 for (size_t i = 0; i < all_client_certs.size(); ++i) { | 1884 for (size_t i = 0; i < all_client_certs.size(); ++i) { |
| 1892 if (CertMatchesFilter(*all_client_certs[i].get(), *filter_dict)) { | 1885 if (CertMatchesFilter(*all_client_certs[i].get(), *filter_dict)) { |
| 1893 // Use the first certificate that is matched by the filter. | 1886 // Use the first certificate that is matched by the filter. |
| 1894 callback.Run(all_client_certs[i].get()); | 1887 delegate->ContinueWithCertificate(all_client_certs[i].get()); |
| 1895 return; | 1888 return; |
| 1896 } | 1889 } |
| 1897 } | 1890 } |
| 1898 } else { | 1891 } else { |
| 1899 NOTREACHED(); | 1892 NOTREACHED(); |
| 1900 } | 1893 } |
| 1901 } | 1894 } |
| 1902 | 1895 |
| 1903 chrome::ShowSSLClientCertificateSelector(tab, cert_request_info, callback); | 1896 chrome::ShowSSLClientCertificateSelector(web_contents, cert_request_info, |
| 1897 delegate.Pass()); | |
| 1904 } | 1898 } |
| 1905 | 1899 |
| 1906 void ChromeContentBrowserClient::AddCertificate( | 1900 void ChromeContentBrowserClient::AddCertificate( |
| 1907 net::CertificateMimeType cert_type, | 1901 net::CertificateMimeType cert_type, |
| 1908 const void* cert_data, | 1902 const void* cert_data, |
| 1909 size_t cert_size, | 1903 size_t cert_size, |
| 1910 int render_process_id, | 1904 int render_process_id, |
| 1911 int render_frame_id) { | 1905 int render_frame_id) { |
| 1912 chrome::SSLAddCertificate(cert_type, cert_data, cert_size, | 1906 chrome::SSLAddCertificate(cert_type, cert_data, cert_size, |
| 1913 render_process_id, render_frame_id); | 1907 render_process_id, render_frame_id); |
| (...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2637 switches::kDisableWebRtcEncryption, | 2631 switches::kDisableWebRtcEncryption, |
| 2638 }; | 2632 }; |
| 2639 to_command_line->CopySwitchesFrom(from_command_line, | 2633 to_command_line->CopySwitchesFrom(from_command_line, |
| 2640 kWebRtcDevSwitchNames, | 2634 kWebRtcDevSwitchNames, |
| 2641 arraysize(kWebRtcDevSwitchNames)); | 2635 arraysize(kWebRtcDevSwitchNames)); |
| 2642 } | 2636 } |
| 2643 } | 2637 } |
| 2644 #endif // defined(ENABLE_WEBRTC) | 2638 #endif // defined(ENABLE_WEBRTC) |
| 2645 | 2639 |
| 2646 } // namespace chrome | 2640 } // namespace chrome |
| OLD | NEW |