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..5b0a31af3bd8858ee4c9fbf1c806ba4c3f377896 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,13 @@ bool SSLClientCertificateSelector::Accept() { |
return false; |
} |
+bool SSLClientCertificateSelector::Close() { |
+ DVLOG(1) << __FUNCTION__; |
+ StopObserving(); |
+ CancelCertificateSelection(); |
+ return true; |
+} |
+ |
void SSLClientCertificateSelector::Unlocked(net::X509Certificate* cert) { |
DVLOG(1) << __FUNCTION__; |
CertificateSelected(cert); |
@@ -87,11 +96,21 @@ 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) { |
+ delegate->CancelCertificateSelection(); |
sky
2015/02/20 21:32:29
Same comment about cancel here.
|
+ return; |
+ } |
+ |
+ SSLClientCertificateSelector* selector = new SSLClientCertificateSelector( |
+ contents, cert_request_info, delegate.Pass()); |
selector->Init(); |
selector->Show(); |
} |