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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 #include "components/signin/core/common/profile_management_switches.h" | 109 #include "components/signin/core/common/profile_management_switches.h" |
110 #include "components/translate/core/common/translate_switches.h" | 110 #include "components/translate/core/common/translate_switches.h" |
111 #include "components/url_fixer/url_fixer.h" | 111 #include "components/url_fixer/url_fixer.h" |
112 #include "content/public/browser/browser_child_process_host.h" | 112 #include "content/public/browser/browser_child_process_host.h" |
113 #include "content/public/browser/browser_main_parts.h" | 113 #include "content/public/browser/browser_main_parts.h" |
114 #include "content/public/browser/browser_ppapi_host.h" | 114 #include "content/public/browser/browser_ppapi_host.h" |
115 #include "content/public/browser/browser_thread.h" | 115 #include "content/public/browser/browser_thread.h" |
116 #include "content/public/browser/browser_url_handler.h" | 116 #include "content/public/browser/browser_url_handler.h" |
117 #include "content/public/browser/child_process_data.h" | 117 #include "content/public/browser/child_process_data.h" |
118 #include "content/public/browser/child_process_security_policy.h" | 118 #include "content/public/browser/child_process_security_policy.h" |
| 119 #include "content/public/browser/client_certificate_delegate.h" |
119 #include "content/public/browser/permission_type.h" | 120 #include "content/public/browser/permission_type.h" |
120 #include "content/public/browser/render_frame_host.h" | 121 #include "content/public/browser/render_frame_host.h" |
121 #include "content/public/browser/render_process_host.h" | 122 #include "content/public/browser/render_process_host.h" |
122 #include "content/public/browser/render_view_host.h" | 123 #include "content/public/browser/render_view_host.h" |
123 #include "content/public/browser/resource_context.h" | 124 #include "content/public/browser/resource_context.h" |
124 #include "content/public/browser/site_instance.h" | 125 #include "content/public/browser/site_instance.h" |
125 #include "content/public/browser/web_contents.h" | 126 #include "content/public/browser/web_contents.h" |
126 #include "content/public/common/child_process_host.h" | 127 #include "content/public/common/child_process_host.h" |
127 #include "content/public/common/content_descriptors.h" | 128 #include "content/public/common/content_descriptors.h" |
128 #include "content/public/common/url_utils.h" | 129 #include "content/public/common/url_utils.h" |
(...skipping 1716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1845 if (strict_enforcement) | 1846 if (strict_enforcement) |
1846 options_mask |= SSLBlockingPage::STRICT_ENFORCEMENT; | 1847 options_mask |= SSLBlockingPage::STRICT_ENFORCEMENT; |
1847 if (expired_previous_decision) | 1848 if (expired_previous_decision) |
1848 options_mask |= SSLBlockingPage::EXPIRED_BUT_PREVIOUSLY_ALLOWED; | 1849 options_mask |= SSLBlockingPage::EXPIRED_BUT_PREVIOUSLY_ALLOWED; |
1849 | 1850 |
1850 SSLErrorHandler::HandleSSLError( | 1851 SSLErrorHandler::HandleSSLError( |
1851 tab, cert_error, ssl_info, request_url, options_mask, callback); | 1852 tab, cert_error, ssl_info, request_url, options_mask, callback); |
1852 } | 1853 } |
1853 | 1854 |
1854 void ChromeContentBrowserClient::SelectClientCertificate( | 1855 void ChromeContentBrowserClient::SelectClientCertificate( |
1855 int render_process_id, | 1856 content::WebContents* web_contents, |
1856 int render_frame_id, | |
1857 net::SSLCertRequestInfo* cert_request_info, | 1857 net::SSLCertRequestInfo* cert_request_info, |
1858 const base::Callback<void(net::X509Certificate*)>& callback) { | 1858 scoped_ptr<content::ClientCertificateDelegate> delegate) { |
1859 content::RenderFrameHost* rfh = content::RenderFrameHost::FromID( | |
1860 render_process_id, render_frame_id); | |
1861 WebContents* tab = WebContents::FromRenderFrameHost(rfh); | |
1862 if (!tab) { | |
1863 // TODO(davidben): This makes the request hang, but returning no certificate | |
1864 // also breaks. It should abort the request. See https://crbug.com/417092 | |
1865 return; | |
1866 } | |
1867 | |
1868 prerender::PrerenderContents* prerender_contents = | 1859 prerender::PrerenderContents* prerender_contents = |
1869 prerender::PrerenderContents::FromWebContents(tab); | 1860 prerender::PrerenderContents::FromWebContents(web_contents); |
1870 if (prerender_contents) { | 1861 if (prerender_contents) { |
1871 prerender_contents->Destroy( | 1862 prerender_contents->Destroy( |
1872 prerender::FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED); | 1863 prerender::FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED); |
1873 return; | 1864 return; |
1874 } | 1865 } |
1875 | 1866 |
1876 GURL requesting_url("https://" + cert_request_info->host_and_port.ToString()); | 1867 GURL requesting_url("https://" + cert_request_info->host_and_port.ToString()); |
1877 DCHECK(requesting_url.is_valid()) | 1868 DCHECK(requesting_url.is_valid()) |
1878 << "Invalid URL string: https://" | 1869 << "Invalid URL string: https://" |
1879 << cert_request_info->host_and_port.ToString(); | 1870 << cert_request_info->host_and_port.ToString(); |
1880 | 1871 |
1881 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); | 1872 Profile* profile = |
| 1873 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
1882 scoped_ptr<base::Value> filter = | 1874 scoped_ptr<base::Value> filter = |
1883 profile->GetHostContentSettingsMap()->GetWebsiteSetting( | 1875 profile->GetHostContentSettingsMap()->GetWebsiteSetting( |
1884 requesting_url, | 1876 requesting_url, |
1885 requesting_url, | 1877 requesting_url, |
1886 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, | 1878 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, |
1887 std::string(), | 1879 std::string(), |
1888 NULL); | 1880 NULL); |
1889 | 1881 |
1890 if (filter.get()) { | 1882 if (filter.get()) { |
1891 // Try to automatically select a client certificate. | 1883 // Try to automatically select a client certificate. |
1892 if (filter->IsType(base::Value::TYPE_DICTIONARY)) { | 1884 if (filter->IsType(base::Value::TYPE_DICTIONARY)) { |
1893 base::DictionaryValue* filter_dict = | 1885 base::DictionaryValue* filter_dict = |
1894 static_cast<base::DictionaryValue*>(filter.get()); | 1886 static_cast<base::DictionaryValue*>(filter.get()); |
1895 | 1887 |
1896 const std::vector<scoped_refptr<net::X509Certificate> >& | 1888 const std::vector<scoped_refptr<net::X509Certificate> >& |
1897 all_client_certs = cert_request_info->client_certs; | 1889 all_client_certs = cert_request_info->client_certs; |
1898 for (size_t i = 0; i < all_client_certs.size(); ++i) { | 1890 for (size_t i = 0; i < all_client_certs.size(); ++i) { |
1899 if (CertMatchesFilter(*all_client_certs[i].get(), *filter_dict)) { | 1891 if (CertMatchesFilter(*all_client_certs[i].get(), *filter_dict)) { |
1900 // Use the first certificate that is matched by the filter. | 1892 // Use the first certificate that is matched by the filter. |
1901 callback.Run(all_client_certs[i].get()); | 1893 delegate->ContinueWithCertificate(all_client_certs[i].get()); |
1902 return; | 1894 return; |
1903 } | 1895 } |
1904 } | 1896 } |
1905 } else { | 1897 } else { |
1906 NOTREACHED(); | 1898 NOTREACHED(); |
1907 } | 1899 } |
1908 } | 1900 } |
1909 | 1901 |
1910 chrome::ShowSSLClientCertificateSelector(tab, cert_request_info, callback); | 1902 chrome::ShowSSLClientCertificateSelector(web_contents, cert_request_info, |
| 1903 delegate.Pass()); |
1911 } | 1904 } |
1912 | 1905 |
1913 void ChromeContentBrowserClient::AddCertificate( | 1906 void ChromeContentBrowserClient::AddCertificate( |
1914 net::CertificateMimeType cert_type, | 1907 net::CertificateMimeType cert_type, |
1915 const void* cert_data, | 1908 const void* cert_data, |
1916 size_t cert_size, | 1909 size_t cert_size, |
1917 int render_process_id, | 1910 int render_process_id, |
1918 int render_frame_id) { | 1911 int render_frame_id) { |
1919 chrome::SSLAddCertificate(cert_type, cert_data, cert_size, | 1912 chrome::SSLAddCertificate(cert_type, cert_data, cert_size, |
1920 render_process_id, render_frame_id); | 1913 render_process_id, render_frame_id); |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2641 switches::kDisableWebRtcEncryption, | 2634 switches::kDisableWebRtcEncryption, |
2642 }; | 2635 }; |
2643 to_command_line->CopySwitchesFrom(from_command_line, | 2636 to_command_line->CopySwitchesFrom(from_command_line, |
2644 kWebRtcDevSwitchNames, | 2637 kWebRtcDevSwitchNames, |
2645 arraysize(kWebRtcDevSwitchNames)); | 2638 arraysize(kWebRtcDevSwitchNames)); |
2646 } | 2639 } |
2647 } | 2640 } |
2648 #endif // defined(ENABLE_WEBRTC) | 2641 #endif // defined(ENABLE_WEBRTC) |
2649 | 2642 |
2650 } // namespace chrome | 2643 } // namespace chrome |
OLD | NEW |