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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
13 #include "chrome/grit/generated_resources.h" | 13 #include "chrome/grit/generated_resources.h" |
14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
15 #include "content/public/browser/client_certificate_delegate.h" | 15 #include "content/public/browser/client_certificate_delegate.h" |
16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
17 #include "net/cert/x509_certificate.h" | 17 #include "net/cert/x509_certificate.h" |
18 #include "net/ssl/ssl_cert_request_info.h" | 18 #include "net/ssl/ssl_cert_request_info.h" |
19 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
20 #include "ui/views/controls/label.h" | 20 #include "ui/views/controls/label.h" |
21 #include "ui/views/widget/widget.h" | 21 #include "ui/views/widget/widget.h" |
22 | 22 |
23 #if defined(USE_NSS_CERTS) && !defined(OS_CHROMEOS) | 23 #if defined(USE_NSS_CERTS) && !defined(OS_CHROMEOS) |
24 #include "chrome/browser/ui/crypto_module_password_dialog_nss.h" | 24 #include "chrome/browser/ui/crypto_module_password_dialog_nss.h" |
25 #endif | 25 #endif |
26 | 26 |
27 SSLClientCertificateSelector::SSLClientCertificateSelector( | 27 SSLClientCertificateSelector::SSLClientCertificateSelector( |
28 content::WebContents* web_contents, | 28 content::WebContents* web_contents, |
29 const scoped_refptr<net::SSLCertRequestInfo>& cert_request_info, | 29 const scoped_refptr<net::SSLCertRequestInfo>& cert_request_info, |
30 net::CertificateList client_certs, | |
31 std::unique_ptr<content::ClientCertificateDelegate> delegate) | 30 std::unique_ptr<content::ClientCertificateDelegate> delegate) |
32 : CertificateSelector(std::move(client_certs), web_contents), | 31 : CertificateSelector(cert_request_info->client_certs, web_contents), |
33 SSLClientAuthObserver(web_contents->GetBrowserContext(), | 32 SSLClientAuthObserver(web_contents->GetBrowserContext(), |
34 cert_request_info, | 33 cert_request_info, |
35 std::move(delegate)), | 34 std::move(delegate)), |
36 WebContentsObserver(web_contents) {} | 35 WebContentsObserver(web_contents) {} |
37 | 36 |
38 SSLClientCertificateSelector::~SSLClientCertificateSelector() {} | 37 SSLClientCertificateSelector::~SSLClientCertificateSelector() {} |
39 | 38 |
40 void SSLClientCertificateSelector::Init() { | 39 void SSLClientCertificateSelector::Init() { |
41 StartObserving(); | 40 StartObserving(); |
42 std::unique_ptr<views::Label> text_label( | 41 std::unique_ptr<views::Label> text_label( |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 void SSLClientCertificateSelector::Unlocked(net::X509Certificate* cert) { | 92 void SSLClientCertificateSelector::Unlocked(net::X509Certificate* cert) { |
94 CertificateSelected(cert); | 93 CertificateSelected(cert); |
95 GetWidget()->Close(); | 94 GetWidget()->Close(); |
96 } | 95 } |
97 | 96 |
98 namespace chrome { | 97 namespace chrome { |
99 | 98 |
100 void ShowSSLClientCertificateSelector( | 99 void ShowSSLClientCertificateSelector( |
101 content::WebContents* contents, | 100 content::WebContents* contents, |
102 net::SSLCertRequestInfo* cert_request_info, | 101 net::SSLCertRequestInfo* cert_request_info, |
103 net::CertificateList client_certs, | |
104 std::unique_ptr<content::ClientCertificateDelegate> delegate) { | 102 std::unique_ptr<content::ClientCertificateDelegate> delegate) { |
105 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 103 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
106 | 104 |
107 // Not all WebContentses can show modal dialogs. | 105 // Not all WebContentses can show modal dialogs. |
108 // | 106 // |
109 // TODO(davidben): Move this hook to the WebContentsDelegate and only try to | 107 // TODO(davidben): Move this hook to the WebContentsDelegate and only try to |
110 // show a dialog in Browser's implementation. https://crbug.com/456255 | 108 // show a dialog in Browser's implementation. https://crbug.com/456255 |
111 if (!SSLClientCertificateSelector::CanShow(contents)) | 109 if (!SSLClientCertificateSelector::CanShow(contents)) |
112 return; | 110 return; |
113 | 111 |
114 SSLClientCertificateSelector* selector = new SSLClientCertificateSelector( | 112 SSLClientCertificateSelector* selector = new SSLClientCertificateSelector( |
115 contents, cert_request_info, std::move(client_certs), | 113 contents, cert_request_info, std::move(delegate)); |
116 std::move(delegate)); | |
117 selector->Init(); | 114 selector->Init(); |
118 selector->Show(); | 115 selector->Show(); |
119 } | 116 } |
120 | 117 |
121 } // namespace chrome | 118 } // namespace chrome |
OLD | NEW |