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