| OLD | NEW | 
|---|
| 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/ui/views/ssl_client_certificate_selector.h" | 5 #include "chrome/browser/ui/views/ssl_client_certificate_selector.h" | 
| 6 | 6 | 
| 7 #include "base/bind.h" | 7 #include "base/bind.h" | 
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" | 
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" | 
| 10 #include "chrome/grit/generated_resources.h" | 10 #include "chrome/grit/generated_resources.h" | 
| 11 #include "components/web_modal/popup_manager.h" | 11 #include "components/web_modal/popup_manager.h" | 
| 12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" | 
| 13 #include "content/public/browser/client_certificate_delegate.h" | 13 #include "content/public/browser/client_certificate_delegate.h" | 
| 14 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" | 
| 15 #include "net/cert/x509_certificate.h" | 15 #include "net/cert/x509_certificate.h" | 
| 16 #include "net/ssl/ssl_cert_request_info.h" | 16 #include "net/ssl/ssl_cert_request_info.h" | 
| 17 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" | 
| 18 #include "ui/views/widget/widget.h" | 18 #include "ui/views/widget/widget.h" | 
| 19 | 19 | 
| 20 #if defined(USE_NSS) | 20 #if defined(USE_NSS_CERTS) | 
| 21 #include "chrome/browser/ui/crypto_module_password_dialog_nss.h" | 21 #include "chrome/browser/ui/crypto_module_password_dialog_nss.h" | 
| 22 #endif | 22 #endif | 
| 23 | 23 | 
| 24 SSLClientCertificateSelector::SSLClientCertificateSelector( | 24 SSLClientCertificateSelector::SSLClientCertificateSelector( | 
| 25     content::WebContents* web_contents, | 25     content::WebContents* web_contents, | 
| 26     const scoped_refptr<net::SSLCertRequestInfo>& cert_request_info, | 26     const scoped_refptr<net::SSLCertRequestInfo>& cert_request_info, | 
| 27     scoped_ptr<content::ClientCertificateDelegate> delegate) | 27     scoped_ptr<content::ClientCertificateDelegate> delegate) | 
| 28     : CertificateSelector(cert_request_info->client_certs, web_contents), | 28     : CertificateSelector(cert_request_info->client_certs, web_contents), | 
| 29       SSLClientAuthObserver(web_contents->GetBrowserContext(), | 29       SSLClientAuthObserver(web_contents->GetBrowserContext(), | 
| 30                             cert_request_info, | 30                             cert_request_info, | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 50   return true; | 50   return true; | 
| 51 } | 51 } | 
| 52 | 52 | 
| 53 bool SSLClientCertificateSelector::Accept() { | 53 bool SSLClientCertificateSelector::Accept() { | 
| 54   scoped_refptr<net::X509Certificate> cert = GetSelectedCert(); | 54   scoped_refptr<net::X509Certificate> cert = GetSelectedCert(); | 
| 55   if (cert.get()) { | 55   if (cert.get()) { | 
| 56     // Remove the observer before we try unlocking, otherwise we might act on a | 56     // Remove the observer before we try unlocking, otherwise we might act on a | 
| 57     // notification while waiting for the unlock dialog, causing us to delete | 57     // notification while waiting for the unlock dialog, causing us to delete | 
| 58     // ourself before the Unlocked callback gets called. | 58     // ourself before the Unlocked callback gets called. | 
| 59     StopObserving(); | 59     StopObserving(); | 
| 60 #if defined(USE_NSS) | 60 #if defined(USE_NSS_CERTS) | 
| 61     chrome::UnlockCertSlotIfNecessary( | 61     chrome::UnlockCertSlotIfNecessary( | 
| 62         cert.get(), chrome::kCryptoModulePasswordClientAuth, | 62         cert.get(), chrome::kCryptoModulePasswordClientAuth, | 
| 63         cert_request_info()->host_and_port, GetWidget()->GetNativeView(), | 63         cert_request_info()->host_and_port, GetWidget()->GetNativeView(), | 
| 64         base::Bind(&SSLClientCertificateSelector::Unlocked, | 64         base::Bind(&SSLClientCertificateSelector::Unlocked, | 
| 65                    base::Unretained(this), cert)); | 65                    base::Unretained(this), cert)); | 
| 66 #else | 66 #else | 
| 67     Unlocked(cert.get()); | 67     Unlocked(cert.get()); | 
| 68 #endif | 68 #endif | 
| 69     return false;  // Unlocked() will close the dialog. | 69     return false;  // Unlocked() will close the dialog. | 
| 70   } | 70   } | 
| (...skipping 30 matching lines...) Expand all  Loading... | 
| 101   if (web_modal::PopupManager::FromWebContents(contents) == nullptr) | 101   if (web_modal::PopupManager::FromWebContents(contents) == nullptr) | 
| 102     return; | 102     return; | 
| 103 | 103 | 
| 104   SSLClientCertificateSelector* selector = new SSLClientCertificateSelector( | 104   SSLClientCertificateSelector* selector = new SSLClientCertificateSelector( | 
| 105       contents, cert_request_info, delegate.Pass()); | 105       contents, cert_request_info, delegate.Pass()); | 
| 106   selector->Init(); | 106   selector->Init(); | 
| 107   selector->Show(); | 107   selector->Show(); | 
| 108 } | 108 } | 
| 109 | 109 | 
| 110 }  // namespace chrome | 110 }  // namespace chrome | 
| OLD | NEW | 
|---|