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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 #include "content/public/common/service_registry.h" | 151 #include "content/public/common/service_registry.h" |
152 #include "content/public/common/url_utils.h" | 152 #include "content/public/common/url_utils.h" |
153 #include "content/public/common/web_preferences.h" | 153 #include "content/public/common/web_preferences.h" |
154 #include "device/devices_app/usb/public/interfaces/device_manager.mojom.h" | 154 #include "device/devices_app/usb/public/interfaces/device_manager.mojom.h" |
155 #include "gin/v8_initializer.h" | 155 #include "gin/v8_initializer.h" |
156 #include "mojo/shell/public/cpp/application_delegate.h" | 156 #include "mojo/shell/public/cpp/application_delegate.h" |
157 #include "net/base/mime_util.h" | 157 #include "net/base/mime_util.h" |
158 #include "net/cookies/canonical_cookie.h" | 158 #include "net/cookies/canonical_cookie.h" |
159 #include "net/cookies/cookie_options.h" | 159 #include "net/cookies/cookie_options.h" |
160 #include "net/ssl/ssl_cert_request_info.h" | 160 #include "net/ssl/ssl_cert_request_info.h" |
| 161 #include "net/ssl/ssl_platform_key.h" |
161 #include "ppapi/host/ppapi_host.h" | 162 #include "ppapi/host/ppapi_host.h" |
162 #include "storage/browser/fileapi/external_mount_points.h" | 163 #include "storage/browser/fileapi/external_mount_points.h" |
163 #include "ui/base/l10n/l10n_util.h" | 164 #include "ui/base/l10n/l10n_util.h" |
164 #include "ui/base/resource/resource_bundle.h" | 165 #include "ui/base/resource/resource_bundle.h" |
165 #include "ui/resources/grit/ui_resources.h" | 166 #include "ui/resources/grit/ui_resources.h" |
166 | 167 |
167 #if defined(OS_WIN) | 168 #if defined(OS_WIN) |
168 #include "base/win/windows_version.h" | 169 #include "base/win/windows_version.h" |
169 #include "chrome/browser/chrome_browser_main_win.h" | 170 #include "chrome/browser/chrome_browser_main_win.h" |
170 #include "sandbox/win/src/sandbox_policy.h" | 171 #include "sandbox/win/src/sandbox_policy.h" |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 | 462 |
462 // Reverse URL handler for Web UI. Maps "chrome://chrome/foo/" to | 463 // Reverse URL handler for Web UI. Maps "chrome://chrome/foo/" to |
463 // "chrome://foo/". | 464 // "chrome://foo/". |
464 bool HandleWebUIReverse(GURL* url, content::BrowserContext* browser_context) { | 465 bool HandleWebUIReverse(GURL* url, content::BrowserContext* browser_context) { |
465 if (!url->is_valid() || !url->SchemeIs(content::kChromeUIScheme)) | 466 if (!url->is_valid() || !url->SchemeIs(content::kChromeUIScheme)) |
466 return false; | 467 return false; |
467 | 468 |
468 return RemoveUberHost(url); | 469 return RemoveUberHost(url); |
469 } | 470 } |
470 | 471 |
| 472 #if !defined(OS_ANDROID) |
471 bool CertMatchesFilter(const net::X509Certificate& cert, | 473 bool CertMatchesFilter(const net::X509Certificate& cert, |
472 const base::DictionaryValue& filter) { | 474 const base::DictionaryValue& filter) { |
473 // TODO(markusheintz): This is the minimal required filter implementation. | 475 // TODO(markusheintz): This is the minimal required filter implementation. |
474 // Implement a better matcher. | 476 // Implement a better matcher. |
475 | 477 |
476 // An empty filter matches any client certificate since no requirements are | 478 // An empty filter matches any client certificate since no requirements are |
477 // specified at all. | 479 // specified at all. |
478 if (filter.empty()) | 480 if (filter.empty()) |
479 return true; | 481 return true; |
480 | 482 |
481 std::string common_name; | 483 std::string common_name; |
482 if (filter.GetString("ISSUER.CN", &common_name) && | 484 if (filter.GetString("ISSUER.CN", &common_name) && |
483 (cert.issuer().common_name == common_name)) { | 485 (cert.issuer().common_name == common_name)) { |
484 return true; | 486 return true; |
485 } | 487 } |
486 return false; | 488 return false; |
487 } | 489 } |
| 490 #endif |
488 | 491 |
489 #if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) | 492 #if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) |
490 breakpad::CrashHandlerHostLinux* CreateCrashHandlerHost( | 493 breakpad::CrashHandlerHostLinux* CreateCrashHandlerHost( |
491 const std::string& process_type) { | 494 const std::string& process_type) { |
492 base::FilePath dumps_path; | 495 base::FilePath dumps_path; |
493 PathService::Get(chrome::DIR_CRASH_DUMPS, &dumps_path); | 496 PathService::Get(chrome::DIR_CRASH_DUMPS, &dumps_path); |
494 { | 497 { |
495 ANNOTATE_SCOPED_MEMORY_LEAK; | 498 ANNOTATE_SCOPED_MEMORY_LEAK; |
496 bool upload = (getenv(env_vars::kHeadless) == NULL); | 499 bool upload = (getenv(env_vars::kHeadless) == NULL); |
497 breakpad::CrashHandlerHostLinux* crash_handler = | 500 breakpad::CrashHandlerHostLinux* crash_handler = |
(...skipping 1547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2045 net::SSLCertRequestInfo* cert_request_info, | 2048 net::SSLCertRequestInfo* cert_request_info, |
2046 scoped_ptr<content::ClientCertificateDelegate> delegate) { | 2049 scoped_ptr<content::ClientCertificateDelegate> delegate) { |
2047 prerender::PrerenderContents* prerender_contents = | 2050 prerender::PrerenderContents* prerender_contents = |
2048 prerender::PrerenderContents::FromWebContents(web_contents); | 2051 prerender::PrerenderContents::FromWebContents(web_contents); |
2049 if (prerender_contents) { | 2052 if (prerender_contents) { |
2050 prerender_contents->Destroy( | 2053 prerender_contents->Destroy( |
2051 prerender::FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED); | 2054 prerender::FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED); |
2052 return; | 2055 return; |
2053 } | 2056 } |
2054 | 2057 |
| 2058 // Android can't support CONENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE since |
| 2059 // the platform doesn't provide a list of matching certificates. |
| 2060 #if !defined(OS_ANDROID) |
2055 GURL requesting_url("https://" + cert_request_info->host_and_port.ToString()); | 2061 GURL requesting_url("https://" + cert_request_info->host_and_port.ToString()); |
2056 DCHECK(requesting_url.is_valid()) | 2062 DCHECK(requesting_url.is_valid()) |
2057 << "Invalid URL string: https://" | 2063 << "Invalid URL string: https://" |
2058 << cert_request_info->host_and_port.ToString(); | 2064 << cert_request_info->host_and_port.ToString(); |
2059 | 2065 |
2060 Profile* profile = | 2066 Profile* profile = |
2061 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 2067 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
2062 scoped_ptr<base::Value> filter = | 2068 scoped_ptr<base::Value> filter = |
2063 HostContentSettingsMapFactory::GetForProfile(profile)->GetWebsiteSetting( | 2069 HostContentSettingsMapFactory::GetForProfile(profile)->GetWebsiteSetting( |
2064 requesting_url, | 2070 requesting_url, |
2065 requesting_url, | 2071 requesting_url, |
2066 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, | 2072 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, |
2067 std::string(), | 2073 std::string(), |
2068 NULL); | 2074 NULL); |
2069 | 2075 |
2070 if (filter.get()) { | 2076 if (filter.get()) { |
2071 // Try to automatically select a client certificate. | 2077 // Try to automatically select a client certificate. |
2072 if (filter->IsType(base::Value::TYPE_DICTIONARY)) { | 2078 if (filter->IsType(base::Value::TYPE_DICTIONARY)) { |
2073 base::DictionaryValue* filter_dict = | 2079 base::DictionaryValue* filter_dict = |
2074 static_cast<base::DictionaryValue*>(filter.get()); | 2080 static_cast<base::DictionaryValue*>(filter.get()); |
2075 | 2081 |
2076 const std::vector<scoped_refptr<net::X509Certificate> >& | 2082 const std::vector<scoped_refptr<net::X509Certificate> >& |
2077 all_client_certs = cert_request_info->client_certs; | 2083 all_client_certs = cert_request_info->client_certs; |
2078 for (size_t i = 0; i < all_client_certs.size(); ++i) { | 2084 for (size_t i = 0; i < all_client_certs.size(); ++i) { |
2079 if (CertMatchesFilter(*all_client_certs[i].get(), *filter_dict)) { | 2085 if (CertMatchesFilter(*all_client_certs[i].get(), *filter_dict)) { |
2080 // Use the first certificate that is matched by the filter. | 2086 // Use the first certificate that is matched by the filter. |
2081 delegate->ContinueWithCertificate(all_client_certs[i].get()); | 2087 // The following is not supported on Android since the client_certs |
| 2088 // list |
| 2089 // won't be populated. |
| 2090 delegate->ContinueWithCertificate( |
| 2091 all_client_certs[i].get(), |
| 2092 net::FetchClientCertPrivateKey(all_client_certs[i].get()).get()); |
2082 return; | 2093 return; |
2083 } | 2094 } |
2084 } | 2095 } |
2085 } else { | 2096 } else { |
2086 NOTREACHED(); | 2097 NOTREACHED(); |
2087 } | 2098 } |
2088 } | 2099 } |
| 2100 #endif |
2089 | 2101 |
2090 chrome::ShowSSLClientCertificateSelector(web_contents, cert_request_info, | 2102 chrome::ShowSSLClientCertificateSelector(web_contents, cert_request_info, |
2091 std::move(delegate)); | 2103 std::move(delegate)); |
2092 } | 2104 } |
2093 | 2105 |
2094 void ChromeContentBrowserClient::AddCertificate( | 2106 void ChromeContentBrowserClient::AddCertificate( |
2095 net::CertificateMimeType cert_type, | 2107 net::CertificateMimeType cert_type, |
2096 const void* cert_data, | 2108 const void* cert_data, |
2097 size_t cert_size, | 2109 size_t cert_size, |
2098 int render_process_id, | 2110 int render_process_id, |
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2824 if (channel <= kMaxDisableEncryptionChannel) { | 2836 if (channel <= kMaxDisableEncryptionChannel) { |
2825 static const char* const kWebRtcDevSwitchNames[] = { | 2837 static const char* const kWebRtcDevSwitchNames[] = { |
2826 switches::kDisableWebRtcEncryption, | 2838 switches::kDisableWebRtcEncryption, |
2827 }; | 2839 }; |
2828 to_command_line->CopySwitchesFrom(from_command_line, | 2840 to_command_line->CopySwitchesFrom(from_command_line, |
2829 kWebRtcDevSwitchNames, | 2841 kWebRtcDevSwitchNames, |
2830 arraysize(kWebRtcDevSwitchNames)); | 2842 arraysize(kWebRtcDevSwitchNames)); |
2831 } | 2843 } |
2832 } | 2844 } |
2833 #endif // defined(ENABLE_WEBRTC) | 2845 #endif // defined(ENABLE_WEBRTC) |
OLD | NEW |