| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 #include "content/public/common/service_registry.h" | 142 #include "content/public/common/service_registry.h" |
| 143 #include "content/public/common/url_utils.h" | 143 #include "content/public/common/url_utils.h" |
| 144 #include "content/public/common/web_preferences.h" | 144 #include "content/public/common/web_preferences.h" |
| 145 #include "device/devices_app/usb/device_manager_impl.h" | 145 #include "device/devices_app/usb/device_manager_impl.h" |
| 146 #include "gin/v8_initializer.h" | 146 #include "gin/v8_initializer.h" |
| 147 #include "mojo/application/public/cpp/application_delegate.h" | 147 #include "mojo/application/public/cpp/application_delegate.h" |
| 148 #include "net/base/mime_util.h" | 148 #include "net/base/mime_util.h" |
| 149 #include "net/cookies/canonical_cookie.h" | 149 #include "net/cookies/canonical_cookie.h" |
| 150 #include "net/cookies/cookie_options.h" | 150 #include "net/cookies/cookie_options.h" |
| 151 #include "net/ssl/ssl_cert_request_info.h" | 151 #include "net/ssl/ssl_cert_request_info.h" |
| 152 #include "net/ssl/ssl_platform_key.h" |
| 152 #include "ppapi/host/ppapi_host.h" | 153 #include "ppapi/host/ppapi_host.h" |
| 153 #include "storage/browser/fileapi/external_mount_points.h" | 154 #include "storage/browser/fileapi/external_mount_points.h" |
| 154 #include "ui/base/l10n/l10n_util.h" | 155 #include "ui/base/l10n/l10n_util.h" |
| 155 #include "ui/base/resource/resource_bundle.h" | 156 #include "ui/base/resource/resource_bundle.h" |
| 156 #include "ui/resources/grit/ui_resources.h" | 157 #include "ui/resources/grit/ui_resources.h" |
| 157 | 158 |
| 158 #if defined(OS_WIN) | 159 #if defined(OS_WIN) |
| 159 #include "base/win/windows_version.h" | 160 #include "base/win/windows_version.h" |
| 160 #include "chrome/browser/chrome_browser_main_win.h" | 161 #include "chrome/browser/chrome_browser_main_win.h" |
| 161 #include "sandbox/win/src/sandbox_policy.h" | 162 #include "sandbox/win/src/sandbox_policy.h" |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 | 435 |
| 435 // Reverse URL handler for Web UI. Maps "chrome://chrome/foo/" to | 436 // Reverse URL handler for Web UI. Maps "chrome://chrome/foo/" to |
| 436 // "chrome://foo/". | 437 // "chrome://foo/". |
| 437 bool HandleWebUIReverse(GURL* url, content::BrowserContext* browser_context) { | 438 bool HandleWebUIReverse(GURL* url, content::BrowserContext* browser_context) { |
| 438 if (!url->is_valid() || !url->SchemeIs(content::kChromeUIScheme)) | 439 if (!url->is_valid() || !url->SchemeIs(content::kChromeUIScheme)) |
| 439 return false; | 440 return false; |
| 440 | 441 |
| 441 return RemoveUberHost(url); | 442 return RemoveUberHost(url); |
| 442 } | 443 } |
| 443 | 444 |
| 445 #if !defined(OS_ANDROID) |
| 444 bool CertMatchesFilter(const net::X509Certificate& cert, | 446 bool CertMatchesFilter(const net::X509Certificate& cert, |
| 445 const base::DictionaryValue& filter) { | 447 const base::DictionaryValue& filter) { |
| 446 // TODO(markusheintz): This is the minimal required filter implementation. | 448 // TODO(markusheintz): This is the minimal required filter implementation. |
| 447 // Implement a better matcher. | 449 // Implement a better matcher. |
| 448 | 450 |
| 449 // An empty filter matches any client certificate since no requirements are | 451 // An empty filter matches any client certificate since no requirements are |
| 450 // specified at all. | 452 // specified at all. |
| 451 if (filter.empty()) | 453 if (filter.empty()) |
| 452 return true; | 454 return true; |
| 453 | 455 |
| 454 std::string common_name; | 456 std::string common_name; |
| 455 if (filter.GetString("ISSUER.CN", &common_name) && | 457 if (filter.GetString("ISSUER.CN", &common_name) && |
| 456 (cert.issuer().common_name == common_name)) { | 458 (cert.issuer().common_name == common_name)) { |
| 457 return true; | 459 return true; |
| 458 } | 460 } |
| 459 return false; | 461 return false; |
| 460 } | 462 } |
| 463 #endif |
| 461 | 464 |
| 462 #if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) | 465 #if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) |
| 463 breakpad::CrashHandlerHostLinux* CreateCrashHandlerHost( | 466 breakpad::CrashHandlerHostLinux* CreateCrashHandlerHost( |
| 464 const std::string& process_type) { | 467 const std::string& process_type) { |
| 465 base::FilePath dumps_path; | 468 base::FilePath dumps_path; |
| 466 PathService::Get(chrome::DIR_CRASH_DUMPS, &dumps_path); | 469 PathService::Get(chrome::DIR_CRASH_DUMPS, &dumps_path); |
| 467 { | 470 { |
| 468 ANNOTATE_SCOPED_MEMORY_LEAK; | 471 ANNOTATE_SCOPED_MEMORY_LEAK; |
| 469 bool upload = (getenv(env_vars::kHeadless) == NULL); | 472 bool upload = (getenv(env_vars::kHeadless) == NULL); |
| 470 breakpad::CrashHandlerHostLinux* crash_handler = | 473 breakpad::CrashHandlerHostLinux* crash_handler = |
| (...skipping 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1970 net::SSLCertRequestInfo* cert_request_info, | 1973 net::SSLCertRequestInfo* cert_request_info, |
| 1971 scoped_ptr<content::ClientCertificateDelegate> delegate) { | 1974 scoped_ptr<content::ClientCertificateDelegate> delegate) { |
| 1972 prerender::PrerenderContents* prerender_contents = | 1975 prerender::PrerenderContents* prerender_contents = |
| 1973 prerender::PrerenderContents::FromWebContents(web_contents); | 1976 prerender::PrerenderContents::FromWebContents(web_contents); |
| 1974 if (prerender_contents) { | 1977 if (prerender_contents) { |
| 1975 prerender_contents->Destroy( | 1978 prerender_contents->Destroy( |
| 1976 prerender::FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED); | 1979 prerender::FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED); |
| 1977 return; | 1980 return; |
| 1978 } | 1981 } |
| 1979 | 1982 |
| 1983 // Android can't support CONENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE since |
| 1984 // the platform doesn't provide a list of matching certificates. |
| 1985 #if !defined(OS_ANDROID) |
| 1980 GURL requesting_url("https://" + cert_request_info->host_and_port.ToString()); | 1986 GURL requesting_url("https://" + cert_request_info->host_and_port.ToString()); |
| 1981 DCHECK(requesting_url.is_valid()) | 1987 DCHECK(requesting_url.is_valid()) |
| 1982 << "Invalid URL string: https://" | 1988 << "Invalid URL string: https://" |
| 1983 << cert_request_info->host_and_port.ToString(); | 1989 << cert_request_info->host_and_port.ToString(); |
| 1984 | 1990 |
| 1985 Profile* profile = | 1991 Profile* profile = |
| 1986 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 1992 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 1987 scoped_ptr<base::Value> filter = | 1993 scoped_ptr<base::Value> filter = |
| 1988 HostContentSettingsMapFactory::GetForProfile(profile)->GetWebsiteSetting( | 1994 HostContentSettingsMapFactory::GetForProfile(profile)->GetWebsiteSetting( |
| 1989 requesting_url, | 1995 requesting_url, |
| 1990 requesting_url, | 1996 requesting_url, |
| 1991 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, | 1997 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, |
| 1992 std::string(), | 1998 std::string(), |
| 1993 NULL); | 1999 NULL); |
| 1994 | 2000 |
| 1995 if (filter.get()) { | 2001 if (filter.get()) { |
| 1996 // Try to automatically select a client certificate. | 2002 // Try to automatically select a client certificate. |
| 1997 if (filter->IsType(base::Value::TYPE_DICTIONARY)) { | 2003 if (filter->IsType(base::Value::TYPE_DICTIONARY)) { |
| 1998 base::DictionaryValue* filter_dict = | 2004 base::DictionaryValue* filter_dict = |
| 1999 static_cast<base::DictionaryValue*>(filter.get()); | 2005 static_cast<base::DictionaryValue*>(filter.get()); |
| 2000 | 2006 |
| 2001 const std::vector<scoped_refptr<net::X509Certificate> >& | 2007 const std::vector<scoped_refptr<net::X509Certificate> >& |
| 2002 all_client_certs = cert_request_info->client_certs; | 2008 all_client_certs = cert_request_info->client_certs; |
| 2003 for (size_t i = 0; i < all_client_certs.size(); ++i) { | 2009 for (size_t i = 0; i < all_client_certs.size(); ++i) { |
| 2004 if (CertMatchesFilter(*all_client_certs[i].get(), *filter_dict)) { | 2010 if (CertMatchesFilter(*all_client_certs[i].get(), *filter_dict)) { |
| 2005 // Use the first certificate that is matched by the filter. | 2011 // Use the first certificate that is matched by the filter. |
| 2006 delegate->ContinueWithCertificate(all_client_certs[i].get()); | 2012 // The following is not supported on Android since the client_certs |
| 2013 // list |
| 2014 // won't be populated. |
| 2015 delegate->ContinueWithCertificate( |
| 2016 all_client_certs[i].get(), |
| 2017 net::FetchClientCertPrivateKey(all_client_certs[i].get()).get()); |
| 2007 return; | 2018 return; |
| 2008 } | 2019 } |
| 2009 } | 2020 } |
| 2010 } else { | 2021 } else { |
| 2011 NOTREACHED(); | 2022 NOTREACHED(); |
| 2012 } | 2023 } |
| 2013 } | 2024 } |
| 2025 #endif |
| 2014 | 2026 |
| 2015 chrome::ShowSSLClientCertificateSelector(web_contents, cert_request_info, | 2027 chrome::ShowSSLClientCertificateSelector(web_contents, cert_request_info, |
| 2016 delegate.Pass()); | 2028 delegate.Pass()); |
| 2017 } | 2029 } |
| 2018 | 2030 |
| 2019 void ChromeContentBrowserClient::AddCertificate( | 2031 void ChromeContentBrowserClient::AddCertificate( |
| 2020 net::CertificateMimeType cert_type, | 2032 net::CertificateMimeType cert_type, |
| 2021 const void* cert_data, | 2033 const void* cert_data, |
| 2022 size_t cert_size, | 2034 size_t cert_size, |
| 2023 int render_process_id, | 2035 int render_process_id, |
| (...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2714 if (channel <= kMaxDisableEncryptionChannel) { | 2726 if (channel <= kMaxDisableEncryptionChannel) { |
| 2715 static const char* const kWebRtcDevSwitchNames[] = { | 2727 static const char* const kWebRtcDevSwitchNames[] = { |
| 2716 switches::kDisableWebRtcEncryption, | 2728 switches::kDisableWebRtcEncryption, |
| 2717 }; | 2729 }; |
| 2718 to_command_line->CopySwitchesFrom(from_command_line, | 2730 to_command_line->CopySwitchesFrom(from_command_line, |
| 2719 kWebRtcDevSwitchNames, | 2731 kWebRtcDevSwitchNames, |
| 2720 arraysize(kWebRtcDevSwitchNames)); | 2732 arraysize(kWebRtcDevSwitchNames)); |
| 2721 } | 2733 } |
| 2722 } | 2734 } |
| 2723 #endif // defined(ENABLE_WEBRTC) | 2735 #endif // defined(ENABLE_WEBRTC) |
| OLD | NEW |