Index: chrome/browser/ui/views/ssl_client_certificate_selector.cc |
diff --git a/chrome/browser/ui/views/ssl_client_certificate_selector.cc b/chrome/browser/ui/views/ssl_client_certificate_selector.cc |
index 097195fc71714aa5cbe7c1e4b24fa41ee0f81f30..72f4a4987e73625bfa1549ccf83af84d449bb009 100644 |
--- a/chrome/browser/ui/views/ssl_client_certificate_selector.cc |
+++ b/chrome/browser/ui/views/ssl_client_certificate_selector.cc |
@@ -9,7 +9,9 @@ |
#include "base/logging.h" |
#include "base/strings/utf_string_conversions.h" |
#include "chrome/grit/generated_resources.h" |
+#include "components/web_modal/popup_manager.h" |
#include "content/public/browser/browser_thread.h" |
+#include "content/public/browser/client_certificate_delegate.h" |
#include "content/public/browser/web_contents.h" |
#include "net/cert/x509_certificate.h" |
#include "net/ssl/ssl_cert_request_info.h" |
@@ -23,11 +25,11 @@ |
SSLClientCertificateSelector::SSLClientCertificateSelector( |
content::WebContents* web_contents, |
const scoped_refptr<net::SSLCertRequestInfo>& cert_request_info, |
- const chrome::SelectCertificateCallback& callback) |
+ scoped_ptr<content::ClientCertificateDelegate> delegate) |
: CertificateSelector(cert_request_info->client_certs, web_contents), |
SSLClientAuthObserver(web_contents->GetBrowserContext(), |
cert_request_info, |
- callback) { |
+ delegate.Pass()) { |
DVLOG(1) << __FUNCTION__; |
} |
@@ -76,6 +78,15 @@ bool SSLClientCertificateSelector::Accept() { |
return false; |
} |
+bool SSLClientCertificateSelector::Close() { |
+ // By default, closing the dialog calls the Cancel method. However, selecting |
+ // cancel in the UI currently continues the request with no certificate, |
+ // remembering the selection. If the dialog is closed by closing the |
+ // containing tab, the request should abort. |
+ CancelCertificateSelection(); |
+ return true; |
+} |
+ |
void SSLClientCertificateSelector::Unlocked(net::X509Certificate* cert) { |
DVLOG(1) << __FUNCTION__; |
CertificateSelected(cert); |
@@ -87,11 +98,19 @@ namespace chrome { |
void ShowSSLClientCertificateSelector( |
content::WebContents* contents, |
net::SSLCertRequestInfo* cert_request_info, |
- const chrome::SelectCertificateCallback& callback) { |
+ scoped_ptr<content::ClientCertificateDelegate> delegate) { |
DVLOG(1) << __FUNCTION__ << " " << contents; |
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
- SSLClientCertificateSelector* selector = |
- new SSLClientCertificateSelector(contents, cert_request_info, callback); |
+ |
+ // Not all WebContentses can show modal dialogs. |
+ // |
+ // TODO(davidben): Move this hook to the WebContentsDelegate and only try to |
+ // show a dialog in Browser's implementation. https://crbug.com/456255 |
+ if (web_modal::PopupManager::FromWebContents(contents) == nullptr) |
+ return; |
+ |
+ SSLClientCertificateSelector* selector = new SSLClientCertificateSelector( |
+ contents, cert_request_info, delegate.Pass()); |
selector->Init(); |
selector->Show(); |
} |