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

Unified Diff: chrome/browser/ui/views/ssl_client_certificate_selector.cc

Issue 859213006: Cancel client auth requests when not promptable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@client-auth-cancel-1
Patch Set: worker_common.js was missing a license header (also a rebase) Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
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();
}

Powered by Google App Engine
This is Rietveld 408576698