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

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

Issue 9384014: Remove knowledge about SSLClientAuthHandler from chrome. Instead a callback is given to the embed... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: review comments+sync Created 8 years, 10 months 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
OLDNEW
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 #include "chrome/common/chrome_constants.h" 60 #include "chrome/common/chrome_constants.h"
61 #include "chrome/common/chrome_switches.h" 61 #include "chrome/common/chrome_switches.h"
62 #include "chrome/common/extensions/extension.h" 62 #include "chrome/common/extensions/extension.h"
63 #include "chrome/common/extensions/extension_set.h" 63 #include "chrome/common/extensions/extension_set.h"
64 #include "chrome/common/logging_chrome.h" 64 #include "chrome/common/logging_chrome.h"
65 #include "chrome/common/pref_names.h" 65 #include "chrome/common/pref_names.h"
66 #include "chrome/common/render_messages.h" 66 #include "chrome/common/render_messages.h"
67 #include "chrome/common/url_constants.h" 67 #include "chrome/common/url_constants.h"
68 #include "content/browser/browser_url_handler.h" 68 #include "content/browser/browser_url_handler.h"
69 #include "content/browser/renderer_host/render_view_host.h" 69 #include "content/browser/renderer_host/render_view_host.h"
70 #include "content/browser/ssl/ssl_client_auth_handler.h"
71 #include "content/public/browser/browser_main_parts.h" 70 #include "content/public/browser/browser_main_parts.h"
72 #include "content/public/browser/child_process_security_policy.h" 71 #include "content/public/browser/child_process_security_policy.h"
73 #include "content/public/browser/render_process_host.h" 72 #include "content/public/browser/render_process_host.h"
74 #include "content/public/browser/resource_context.h" 73 #include "content/public/browser/resource_context.h"
75 #include "content/public/browser/site_instance.h" 74 #include "content/public/browser/site_instance.h"
76 #include "content/public/browser/web_contents.h" 75 #include "content/public/browser/web_contents.h"
77 #include "content/public/browser/web_contents_view.h" 76 #include "content/public/browser/web_contents_view.h"
78 #include "grit/generated_resources.h" 77 #include "grit/generated_resources.h"
79 #include "grit/ui_resources.h" 78 #include "grit/ui_resources.h"
80 #include "net/base/cookie_monster.h" 79 #include "net/base/cookie_monster.h"
81 #include "net/base/cookie_options.h" 80 #include "net/base/cookie_options.h"
81 #include "net/base/ssl_cert_request_info.h"
82 #include "ui/base/l10n/l10n_util.h" 82 #include "ui/base/l10n/l10n_util.h"
83 #include "ui/base/resource/resource_bundle.h" 83 #include "ui/base/resource/resource_bundle.h"
84 #include "webkit/glue/webpreferences.h" 84 #include "webkit/glue/webpreferences.h"
85 85
86 #if defined(OS_WIN) 86 #if defined(OS_WIN)
87 #include "chrome/browser/chrome_browser_main_win.h" 87 #include "chrome/browser/chrome_browser_main_win.h"
88 #elif defined(OS_MACOSX) 88 #elif defined(OS_MACOSX)
89 #include "chrome/browser/chrome_browser_main_mac.h" 89 #include "chrome/browser/chrome_browser_main_mac.h"
90 #include "chrome/browser/spellchecker/spellcheck_message_filter_mac.h" 90 #include "chrome/browser/spellchecker/spellcheck_message_filter_mac.h"
91 #elif defined(OS_CHROMEOS) 91 #elif defined(OS_CHROMEOS)
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 } 885 }
886 886
887 // Otherwise, display an SSL blocking page. 887 // Otherwise, display an SSL blocking page.
888 new SSLBlockingPage( 888 new SSLBlockingPage(
889 tab, cert_error, ssl_info, request_url, overridable, callback); 889 tab, cert_error, ssl_info, request_url, overridable, callback);
890 } 890 }
891 891
892 void ChromeContentBrowserClient::SelectClientCertificate( 892 void ChromeContentBrowserClient::SelectClientCertificate(
893 int render_process_id, 893 int render_process_id,
894 int render_view_id, 894 int render_view_id,
895 SSLClientAuthHandler* handler) { 895 const net::HttpNetworkSession* network_session,
896 net::SSLCertRequestInfo* cert_request_info,
897 const base::Callback<void(net::X509Certificate*)>& callback) {
896 WebContents* tab = tab_util::GetWebContentsByID( 898 WebContents* tab = tab_util::GetWebContentsByID(
897 render_process_id, render_view_id); 899 render_process_id, render_view_id);
898 if (!tab) { 900 if (!tab) {
899 NOTREACHED(); 901 NOTREACHED();
900 return; 902 return;
901 } 903 }
902 904
903 net::SSLCertRequestInfo* cert_request_info = handler->cert_request_info();
904 GURL requesting_url("https://" + cert_request_info->host_and_port); 905 GURL requesting_url("https://" + cert_request_info->host_and_port);
905 DCHECK(requesting_url.is_valid()) << "Invalid URL string: https://" 906 DCHECK(requesting_url.is_valid()) << "Invalid URL string: https://"
906 << cert_request_info->host_and_port; 907 << cert_request_info->host_and_port;
907 908
908 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); 909 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext());
909 DCHECK(profile);
910 scoped_ptr<Value> filter( 910 scoped_ptr<Value> filter(
911 profile->GetHostContentSettingsMap()->GetWebsiteSetting( 911 profile->GetHostContentSettingsMap()->GetWebsiteSetting(
912 requesting_url, 912 requesting_url,
913 requesting_url, 913 requesting_url,
914 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, 914 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE,
915 std::string(), NULL)); 915 std::string(), NULL));
916 916
917 if (filter.get()) { 917 if (filter.get()) {
918 // Try to automatically select a client certificate. 918 // Try to automatically select a client certificate.
919 if (filter->IsType(Value::TYPE_DICTIONARY)) { 919 if (filter->IsType(Value::TYPE_DICTIONARY)) {
920 DictionaryValue* filter_dict = 920 DictionaryValue* filter_dict =
921 static_cast<DictionaryValue*>(filter.get()); 921 static_cast<DictionaryValue*>(filter.get());
922 922
923 const std::vector<scoped_refptr<net::X509Certificate> >& 923 const std::vector<scoped_refptr<net::X509Certificate> >&
924 all_client_certs = cert_request_info->client_certs; 924 all_client_certs = cert_request_info->client_certs;
925 for (size_t i = 0; i < all_client_certs.size(); ++i) { 925 for (size_t i = 0; i < all_client_certs.size(); ++i) {
926 if (CertMatchesFilter(*all_client_certs[i], *filter_dict)) { 926 if (CertMatchesFilter(*all_client_certs[i], *filter_dict)) {
927 // Use the first certificate that is matched by the filter. 927 // Use the first certificate that is matched by the filter.
928 handler->CertificateSelected(all_client_certs[i]); 928 callback.Run(all_client_certs[i]);
929 return; 929 return;
930 } 930 }
931 } 931 }
932 } else { 932 } else {
933 NOTREACHED(); 933 NOTREACHED();
934 } 934 }
935 } 935 }
936 936
937 TabContentsWrapper* wrapper = 937 TabContentsWrapper* wrapper =
938 TabContentsWrapper::GetCurrentWrapperForContents(tab); 938 TabContentsWrapper::GetCurrentWrapperForContents(tab);
939 if (!wrapper) { 939 if (!wrapper) {
940 // If there is no TabContentsWrapper for the given WebContents then we can't 940 // If there is no TabContentsWrapper for the given WebContents then we can't
941 // show the user a dialog to select a client certificate. So we simply 941 // show the user a dialog to select a client certificate. So we simply
942 // proceed with no client certificate. 942 // proceed with no client certificate.
943 handler->CertificateSelected(NULL); 943 callback.Run(NULL);
944 return; 944 return;
945 } 945 }
946 wrapper->ssl_helper()->ShowClientCertificateRequestDialog(handler); 946 wrapper->ssl_helper()->ShowClientCertificateRequestDialog(
947 network_session, cert_request_info, callback);
947 } 948 }
948 949
949 void ChromeContentBrowserClient::AddNewCertificate( 950 void ChromeContentBrowserClient::AddNewCertificate(
950 net::URLRequest* request, 951 net::URLRequest* request,
951 net::X509Certificate* cert, 952 net::X509Certificate* cert,
952 int render_process_id, 953 int render_process_id,
953 int render_view_id) { 954 int render_view_id) {
954 // The handler will run the UI and delete itself when it's finished. 955 // The handler will run the UI and delete itself when it's finished.
955 new SSLAddCertHandler(request, cert, render_process_id, render_view_id); 956 new SSLAddCertHandler(request, cert, render_process_id, render_view_id);
956 } 957 }
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
1340 #if defined(USE_NSS) 1341 #if defined(USE_NSS)
1341 crypto::CryptoModuleBlockingPasswordDelegate* 1342 crypto::CryptoModuleBlockingPasswordDelegate*
1342 ChromeContentBrowserClient::GetCryptoPasswordDelegate( 1343 ChromeContentBrowserClient::GetCryptoPasswordDelegate(
1343 const GURL& url) { 1344 const GURL& url) {
1344 return browser::NewCryptoModuleBlockingDialogDelegate( 1345 return browser::NewCryptoModuleBlockingDialogDelegate(
1345 browser::kCryptoModulePasswordKeygen, url.host()); 1346 browser::kCryptoModulePasswordKeygen, url.host());
1346 } 1347 }
1347 #endif 1348 #endif
1348 1349
1349 } // namespace chrome 1350 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/chrome_content_browser_client.h ('k') | chrome/browser/ssl/ssl_client_auth_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698