OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "chrome/app/breakpad_mac.h" | 12 #include "chrome/app/breakpad_mac.h" |
13 #include "chrome/browser/browser_about_handler.h" | 13 #include "chrome/browser/browser_about_handler.h" |
14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/browsing_data_remover.h" | 15 #include "chrome/browser/browsing_data_remover.h" |
16 #include "chrome/browser/character_encoding.h" | 16 #include "chrome/browser/character_encoding.h" |
17 #include "chrome/browser/chrome_benchmarking_message_filter.h" | 17 #include "chrome/browser/chrome_benchmarking_message_filter.h" |
18 #include "chrome/browser/chrome_plugin_message_filter.h" | 18 #include "chrome/browser/chrome_plugin_message_filter.h" |
19 #include "chrome/browser/chrome_quota_permission_context.h" | 19 #include "chrome/browser/chrome_quota_permission_context.h" |
20 #include "chrome/browser/content_settings/content_settings_utils.h" | 20 #include "chrome/browser/content_settings/content_settings_utils.h" |
21 #include "chrome/browser/content_settings/cookie_settings.h" | 21 #include "chrome/browser/content_settings/cookie_settings.h" |
22 #include "chrome/browser/content_settings/host_content_settings_map.h" | |
22 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 23 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
23 #include "chrome/browser/download/download_util.h" | 24 #include "chrome/browser/download/download_util.h" |
24 #include "chrome/browser/extensions/extension_info_map.h" | 25 #include "chrome/browser/extensions/extension_info_map.h" |
25 #include "chrome/browser/extensions/extension_message_handler.h" | 26 #include "chrome/browser/extensions/extension_message_handler.h" |
26 #include "chrome/browser/extensions/extension_service.h" | 27 #include "chrome/browser/extensions/extension_service.h" |
27 #include "chrome/browser/extensions/extension_web_ui.h" | 28 #include "chrome/browser/extensions/extension_web_ui.h" |
28 #include "chrome/browser/extensions/extension_webrequest_api.h" | 29 #include "chrome/browser/extensions/extension_webrequest_api.h" |
29 #include "chrome/browser/geolocation/chrome_access_token_store.h" | 30 #include "chrome/browser/geolocation/chrome_access_token_store.h" |
30 #include "chrome/browser/google/google_util.h" | 31 #include "chrome/browser/google/google_util.h" |
31 #include "chrome/browser/net/chrome_net_log.h" | 32 #include "chrome/browser/net/chrome_net_log.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 for (std::set<std::string>::iterator iter = extension_ids.begin(); | 202 for (std::set<std::string>::iterator iter = extension_ids.begin(); |
202 iter != extension_ids.end(); ++iter) { | 203 iter != extension_ids.end(); ++iter) { |
203 const Extension* extension = service->GetExtensionById(*iter, false); | 204 const Extension* extension = service->GetExtensionById(*iter, false); |
204 if (extension && extension->is_storage_isolated()) | 205 if (extension && extension->is_storage_isolated()) |
205 return PRIV_ISOLATED; | 206 return PRIV_ISOLATED; |
206 } | 207 } |
207 | 208 |
208 return PRIV_EXTENSION; | 209 return PRIV_EXTENSION; |
209 } | 210 } |
210 | 211 |
212 bool CertMatchesFilter(const net::X509Certificate& cert, | |
213 const base::DictionaryValue& filter) { | |
214 // TODO(markusheintz): This is the minimal required filter implementation. | |
215 // Implement a better matcher. | |
216 | |
217 // An empty filter matches any client certificate since no requirements are | |
218 // specified at all. | |
219 if (filter.empty()) | |
220 return true; | |
221 | |
222 std::string common_name; | |
223 if (filter.GetString("ISSUER.CN", &common_name) && | |
224 (cert.issuer().common_name == common_name)) { | |
225 return true; | |
226 } | |
227 return false; | |
228 } | |
229 | |
211 } // namespace | 230 } // namespace |
212 | 231 |
213 namespace chrome { | 232 namespace chrome { |
214 | 233 |
215 content::BrowserMainParts* ChromeContentBrowserClient::CreateBrowserMainParts( | 234 content::BrowserMainParts* ChromeContentBrowserClient::CreateBrowserMainParts( |
216 const content::MainFunctionParams& parameters) { | 235 const content::MainFunctionParams& parameters) { |
217 ChromeBrowserMainParts* main_parts; | 236 ChromeBrowserMainParts* main_parts; |
218 // Construct the Main browser parts based on the OS type. | 237 // Construct the Main browser parts based on the OS type. |
219 #if defined(OS_WIN) | 238 #if defined(OS_WIN) |
220 main_parts = new ChromeBrowserMainPartsWin(parameters); | 239 main_parts = new ChromeBrowserMainPartsWin(parameters); |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
847 int render_process_id, | 866 int render_process_id, |
848 int render_view_id, | 867 int render_view_id, |
849 SSLClientAuthHandler* handler) { | 868 SSLClientAuthHandler* handler) { |
850 TabContents* tab = tab_util::GetTabContentsByID( | 869 TabContents* tab = tab_util::GetTabContentsByID( |
851 render_process_id, render_view_id); | 870 render_process_id, render_view_id); |
852 if (!tab) { | 871 if (!tab) { |
853 NOTREACHED(); | 872 NOTREACHED(); |
854 return; | 873 return; |
855 } | 874 } |
856 | 875 |
876 net::SSLCertRequestInfo* cert_request_info = handler->cert_request_info(); | |
877 GURL requesting_url("https://" + cert_request_info->host_and_port); | |
878 DCHECK(requesting_url.is_valid()) << "Invalid URL string: https://" | |
879 << cert_request_info->host_and_port; | |
880 | |
881 Profile* profile = Profile::FromBrowserContext(tab->browser_context()); | |
882 DCHECK(profile); | |
883 scoped_ptr<Value> filter( | |
884 profile->GetHostContentSettingsMap()->GetWebsiteSetting( | |
885 requesting_url, | |
886 requesting_url, | |
887 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, | |
888 std::string(), NULL)); | |
889 | |
890 if (filter.get()) { | |
891 // Try to automatically select a client certificate. | |
892 if (filter->IsType(Value::TYPE_DICTIONARY)) { | |
893 DictionaryValue* filter_dict = | |
894 static_cast<DictionaryValue*>(filter.get()); | |
895 | |
896 const std::vector<scoped_refptr<net::X509Certificate> >& | |
897 all_client_certs = cert_request_info->client_certs; | |
898 for (size_t i = 0; i < all_client_certs.size(); ++i) { | |
899 if (CertMatchesFilter(*all_client_certs[i], *filter_dict)) { | |
900 // Use the first certificate that is matched by the filter. | |
901 handler->CertificateSelected(all_client_certs[i]); | |
902 return; | |
903 } | |
904 } | |
905 } else { | |
906 NOTREACHED(); | |
907 } | |
908 } | |
909 | |
857 TabContentsWrapper* wrapper = | 910 TabContentsWrapper* wrapper = |
858 TabContentsWrapper::GetCurrentWrapperForContents(tab); | 911 TabContentsWrapper::GetCurrentWrapperForContents(tab); |
859 wrapper->ssl_helper()->SelectClientCertificate(handler); | 912 if (!wrapper) { |
913 LOG(ERROR) << " *** No TabcontentsWrapper for: " << tab->GetURL().spec(); | |
914 // If there is no TabContentsWrapper for the given TabContents then we can't | |
915 // show the user a dialog to select a client certificate. So we simple | |
wtc
2011/12/02 19:01:48
Nit: simple => simply
NOTE: "cancel the request"
markusheintz_
2011/12/03 13:25:42
Done.
| |
916 // cancel the request. | |
917 handler->CertificateSelected(NULL); | |
918 return; | |
919 } | |
920 wrapper->ssl_helper()->ShowClientCertificateRequestDialog(handler); | |
860 } | 921 } |
861 | 922 |
862 void ChromeContentBrowserClient::AddNewCertificate( | 923 void ChromeContentBrowserClient::AddNewCertificate( |
863 net::URLRequest* request, | 924 net::URLRequest* request, |
864 net::X509Certificate* cert, | 925 net::X509Certificate* cert, |
865 int render_process_id, | 926 int render_process_id, |
866 int render_view_id) { | 927 int render_view_id) { |
867 // The handler will run the UI and delete itself when it's finished. | 928 // The handler will run the UI and delete itself when it's finished. |
868 new SSLAddCertHandler(request, cert, render_process_id, render_view_id); | 929 new SSLAddCertHandler(request, cert, render_process_id, render_view_id); |
869 } | 930 } |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1111 #if defined(USE_NSS) | 1172 #if defined(USE_NSS) |
1112 crypto::CryptoModuleBlockingPasswordDelegate* | 1173 crypto::CryptoModuleBlockingPasswordDelegate* |
1113 ChromeContentBrowserClient::GetCryptoPasswordDelegate( | 1174 ChromeContentBrowserClient::GetCryptoPasswordDelegate( |
1114 const GURL& url) { | 1175 const GURL& url) { |
1115 return browser::NewCryptoModuleBlockingDialogDelegate( | 1176 return browser::NewCryptoModuleBlockingDialogDelegate( |
1116 browser::kCryptoModulePasswordKeygen, url.host()); | 1177 browser::kCryptoModulePasswordKeygen, url.host()); |
1117 } | 1178 } |
1118 #endif | 1179 #endif |
1119 | 1180 |
1120 } // namespace chrome | 1181 } // namespace chrome |
OLD | NEW |