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

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: fix aura 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_cert_error_handler.h" 70 #include "content/browser/ssl/ssl_cert_error_handler.h"
71 #include "content/browser/ssl/ssl_client_auth_handler.h"
72 #include "content/public/browser/browser_main_parts.h" 71 #include "content/public/browser/browser_main_parts.h"
73 #include "content/public/browser/child_process_security_policy.h" 72 #include "content/public/browser/child_process_security_policy.h"
74 #include "content/public/browser/render_process_host.h" 73 #include "content/public/browser/render_process_host.h"
75 #include "content/public/browser/resource_context.h" 74 #include "content/public/browser/resource_context.h"
76 #include "content/public/browser/site_instance.h" 75 #include "content/public/browser/site_instance.h"
77 #include "content/public/browser/web_contents.h" 76 #include "content/public/browser/web_contents.h"
78 #include "content/public/browser/web_contents_view.h" 77 #include "content/public/browser/web_contents_view.h"
79 #include "grit/generated_resources.h" 78 #include "grit/generated_resources.h"
80 #include "grit/ui_resources.h" 79 #include "grit/ui_resources.h"
81 #include "net/base/cookie_monster.h" 80 #include "net/base/cookie_monster.h"
82 #include "net/base/cookie_options.h" 81 #include "net/base/cookie_options.h"
82 #include "net/base/ssl_cert_request_info.h"
83 #include "ui/base/l10n/l10n_util.h" 83 #include "ui/base/l10n/l10n_util.h"
84 #include "ui/base/resource/resource_bundle.h" 84 #include "ui/base/resource/resource_bundle.h"
85 #include "webkit/glue/webpreferences.h" 85 #include "webkit/glue/webpreferences.h"
86 86
87 #if defined(OS_WIN) 87 #if defined(OS_WIN)
88 #include "chrome/browser/chrome_browser_main_win.h" 88 #include "chrome/browser/chrome_browser_main_win.h"
89 #elif defined(OS_MACOSX) 89 #elif defined(OS_MACOSX)
90 #include "chrome/browser/chrome_browser_main_mac.h" 90 #include "chrome/browser/chrome_browser_main_mac.h"
91 #include "chrome/browser/spellchecker/spellcheck_message_filter_mac.h" 91 #include "chrome/browser/spellchecker/spellcheck_message_filter_mac.h"
92 #elif defined(OS_CHROMEOS) 92 #elif defined(OS_CHROMEOS)
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 } 873 }
874 } 874 }
875 875
876 // Otherwise, display an SSL blocking page. 876 // Otherwise, display an SSL blocking page.
877 new SSLBlockingPage(handler, overridable, callback); 877 new SSLBlockingPage(handler, overridable, callback);
878 } 878 }
879 879
880 void ChromeContentBrowserClient::SelectClientCertificate( 880 void ChromeContentBrowserClient::SelectClientCertificate(
881 int render_process_id, 881 int render_process_id,
882 int render_view_id, 882 int render_view_id,
883 SSLClientAuthHandler* handler) { 883 const net::HttpNetworkSession* network_session,
884 net::SSLCertRequestInfo* cert_request_info,
885 const base::Callback<void(net::X509Certificate*)>& callback) {
884 WebContents* tab = tab_util::GetWebContentsByID( 886 WebContents* tab = tab_util::GetWebContentsByID(
885 render_process_id, render_view_id); 887 render_process_id, render_view_id);
886 if (!tab) { 888 if (!tab) {
887 NOTREACHED(); 889 NOTREACHED();
888 return; 890 return;
889 } 891 }
890 892
891 net::SSLCertRequestInfo* cert_request_info = handler->cert_request_info();
892 GURL requesting_url("https://" + cert_request_info->host_and_port); 893 GURL requesting_url("https://" + cert_request_info->host_and_port);
893 DCHECK(requesting_url.is_valid()) << "Invalid URL string: https://" 894 DCHECK(requesting_url.is_valid()) << "Invalid URL string: https://"
894 << cert_request_info->host_and_port; 895 << cert_request_info->host_and_port;
895 896
896 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); 897 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext());
897 DCHECK(profile);
898 scoped_ptr<Value> filter( 898 scoped_ptr<Value> filter(
899 profile->GetHostContentSettingsMap()->GetWebsiteSetting( 899 profile->GetHostContentSettingsMap()->GetWebsiteSetting(
900 requesting_url, 900 requesting_url,
901 requesting_url, 901 requesting_url,
902 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, 902 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE,
903 std::string(), NULL)); 903 std::string(), NULL));
904 904
905 if (filter.get()) { 905 if (filter.get()) {
906 // Try to automatically select a client certificate. 906 // Try to automatically select a client certificate.
907 if (filter->IsType(Value::TYPE_DICTIONARY)) { 907 if (filter->IsType(Value::TYPE_DICTIONARY)) {
908 DictionaryValue* filter_dict = 908 DictionaryValue* filter_dict =
909 static_cast<DictionaryValue*>(filter.get()); 909 static_cast<DictionaryValue*>(filter.get());
910 910
911 const std::vector<scoped_refptr<net::X509Certificate> >& 911 const std::vector<scoped_refptr<net::X509Certificate> >&
912 all_client_certs = cert_request_info->client_certs; 912 all_client_certs = cert_request_info->client_certs;
913 for (size_t i = 0; i < all_client_certs.size(); ++i) { 913 for (size_t i = 0; i < all_client_certs.size(); ++i) {
914 if (CertMatchesFilter(*all_client_certs[i], *filter_dict)) { 914 if (CertMatchesFilter(*all_client_certs[i], *filter_dict)) {
915 // Use the first certificate that is matched by the filter. 915 // Use the first certificate that is matched by the filter.
916 handler->CertificateSelected(all_client_certs[i]); 916 callback.Run(all_client_certs[i]);
917 return; 917 return;
918 } 918 }
919 } 919 }
920 } else { 920 } else {
921 NOTREACHED(); 921 NOTREACHED();
922 } 922 }
923 } 923 }
924 924
925 TabContentsWrapper* wrapper = 925 TabContentsWrapper* wrapper =
926 TabContentsWrapper::GetCurrentWrapperForContents(tab); 926 TabContentsWrapper::GetCurrentWrapperForContents(tab);
927 if (!wrapper) { 927 if (!wrapper) {
928 // If there is no TabContentsWrapper for the given WebContents then we can't 928 // If there is no TabContentsWrapper for the given WebContents then we can't
929 // show the user a dialog to select a client certificate. So we simply 929 // show the user a dialog to select a client certificate. So we simply
930 // proceed with no client certificate. 930 // proceed with no client certificate.
931 handler->CertificateSelected(NULL); 931 callback.Run(NULL);
932 return; 932 return;
933 } 933 }
934 wrapper->ssl_helper()->ShowClientCertificateRequestDialog(handler); 934 wrapper->ssl_helper()->ShowClientCertificateRequestDialog(
935 network_session, cert_request_info, callback);
935 } 936 }
936 937
937 void ChromeContentBrowserClient::AddNewCertificate( 938 void ChromeContentBrowserClient::AddNewCertificate(
938 net::URLRequest* request, 939 net::URLRequest* request,
939 net::X509Certificate* cert, 940 net::X509Certificate* cert,
940 int render_process_id, 941 int render_process_id,
941 int render_view_id) { 942 int render_view_id) {
942 // The handler will run the UI and delete itself when it's finished. 943 // The handler will run the UI and delete itself when it's finished.
943 new SSLAddCertHandler(request, cert, render_process_id, render_view_id); 944 new SSLAddCertHandler(request, cert, render_process_id, render_view_id);
944 } 945 }
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
1322 #if defined(USE_NSS) 1323 #if defined(USE_NSS)
1323 crypto::CryptoModuleBlockingPasswordDelegate* 1324 crypto::CryptoModuleBlockingPasswordDelegate*
1324 ChromeContentBrowserClient::GetCryptoPasswordDelegate( 1325 ChromeContentBrowserClient::GetCryptoPasswordDelegate(
1325 const GURL& url) { 1326 const GURL& url) {
1326 return browser::NewCryptoModuleBlockingDialogDelegate( 1327 return browser::NewCryptoModuleBlockingDialogDelegate(
1327 browser::kCryptoModulePasswordKeygen, url.host()); 1328 browser::kCryptoModulePasswordKeygen, url.host());
1328 } 1329 }
1329 #endif 1330 #endif
1330 1331
1331 } // namespace chrome 1332 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698