Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(314)

Side by Side Diff: chrome/browser/chrome_content_browser_client.cc

Issue 8745020: Don't select a client certs for TabContents with no TabContentsWrapper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove bad rebase change Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/tab_contents/tab_contents_ssl_helper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 int render_process_id, 867 int render_process_id,
849 int render_view_id, 868 int render_view_id,
850 SSLClientAuthHandler* handler) { 869 SSLClientAuthHandler* handler) {
851 TabContents* tab = tab_util::GetTabContentsByID( 870 TabContents* tab = tab_util::GetTabContentsByID(
852 render_process_id, render_view_id); 871 render_process_id, render_view_id);
853 if (!tab) { 872 if (!tab) {
854 NOTREACHED(); 873 NOTREACHED();
855 return; 874 return;
856 } 875 }
857 876
877 net::SSLCertRequestInfo* cert_request_info = handler->cert_request_info();
878 GURL requesting_url("https://" + cert_request_info->host_and_port);
879 DCHECK(requesting_url.is_valid()) << "Invalid URL string: https://"
880 << cert_request_info->host_and_port;
881
882 Profile* profile = Profile::FromBrowserContext(tab->browser_context());
883 DCHECK(profile);
884 scoped_ptr<Value> filter(
885 profile->GetHostContentSettingsMap()->GetWebsiteSetting(
886 requesting_url,
887 requesting_url,
888 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE,
889 std::string(), NULL));
890
891 if (filter.get()) {
892 // Try to automatically select a client certificate.
893 if (filter->IsType(Value::TYPE_DICTIONARY)) {
894 DictionaryValue* filter_dict =
895 static_cast<DictionaryValue*>(filter.get());
896
897 const std::vector<scoped_refptr<net::X509Certificate> >&
898 all_client_certs = cert_request_info->client_certs;
899 for (size_t i = 0; i < all_client_certs.size(); ++i) {
900 if (CertMatchesFilter(*all_client_certs[i], *filter_dict)) {
901 // Use the first certificate that is matched by the filter.
902 handler->CertificateSelected(all_client_certs[i]);
903 return;
904 }
905 }
906 } else {
907 NOTREACHED();
908 }
909 }
910
858 TabContentsWrapper* wrapper = 911 TabContentsWrapper* wrapper =
859 TabContentsWrapper::GetCurrentWrapperForContents(tab); 912 TabContentsWrapper::GetCurrentWrapperForContents(tab);
860 wrapper->ssl_helper()->SelectClientCertificate(handler); 913 if (!wrapper) {
914 LOG(ERROR) << " *** No TabcontentsWrapper for: " << tab->GetURL().spec();
915 // If there is no TabContentsWrapper for the given TabContents then we can't
916 // show the user a dialog to select a client certificate. So we simply
917 // cancel the request.
wtc 2011/12/06 00:22:47 Nit: you should also change "cancel the request" t
918 handler->CertificateSelected(NULL);
919 return;
920 }
921 wrapper->ssl_helper()->ShowClientCertificateRequestDialog(handler);
861 } 922 }
862 923
863 void ChromeContentBrowserClient::AddNewCertificate( 924 void ChromeContentBrowserClient::AddNewCertificate(
864 net::URLRequest* request, 925 net::URLRequest* request,
865 net::X509Certificate* cert, 926 net::X509Certificate* cert,
866 int render_process_id, 927 int render_process_id,
867 int render_view_id) { 928 int render_view_id) {
868 // The handler will run the UI and delete itself when it's finished. 929 // The handler will run the UI and delete itself when it's finished.
869 new SSLAddCertHandler(request, cert, render_process_id, render_view_id); 930 new SSLAddCertHandler(request, cert, render_process_id, render_view_id);
870 } 931 }
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 #if defined(USE_NSS) 1173 #if defined(USE_NSS)
1113 crypto::CryptoModuleBlockingPasswordDelegate* 1174 crypto::CryptoModuleBlockingPasswordDelegate*
1114 ChromeContentBrowserClient::GetCryptoPasswordDelegate( 1175 ChromeContentBrowserClient::GetCryptoPasswordDelegate(
1115 const GURL& url) { 1176 const GURL& url) {
1116 return browser::NewCryptoModuleBlockingDialogDelegate( 1177 return browser::NewCryptoModuleBlockingDialogDelegate(
1117 browser::kCryptoModulePasswordKeygen, url.host()); 1178 browser::kCryptoModulePasswordKeygen, url.host());
1118 } 1179 }
1119 #endif 1180 #endif
1120 1181
1121 } // namespace chrome 1182 } // namespace chrome
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/tab_contents/tab_contents_ssl_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698