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> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
9 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
10 #include "build/build_config.h" | 12 #include "build/build_config.h" |
11 #include "chrome/grit/generated_resources.h" | 13 #include "chrome/grit/generated_resources.h" |
12 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
13 #include "content/public/browser/client_certificate_delegate.h" | 15 #include "content/public/browser/client_certificate_delegate.h" |
14 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
15 #include "net/cert/x509_certificate.h" | 17 #include "net/cert/x509_certificate.h" |
16 #include "net/ssl/ssl_cert_request_info.h" | 18 #include "net/ssl/ssl_cert_request_info.h" |
17 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
18 #include "ui/views/controls/label.h" | 20 #include "ui/views/controls/label.h" |
19 #include "ui/views/widget/widget.h" | 21 #include "ui/views/widget/widget.h" |
20 | 22 |
21 #if defined(USE_NSS_CERTS) && !defined(OS_CHROMEOS) | 23 #if defined(USE_NSS_CERTS) && !defined(OS_CHROMEOS) |
22 #include "chrome/browser/ui/crypto_module_password_dialog_nss.h" | 24 #include "chrome/browser/ui/crypto_module_password_dialog_nss.h" |
23 #endif | 25 #endif |
24 | 26 |
25 SSLClientCertificateSelector::SSLClientCertificateSelector( | 27 SSLClientCertificateSelector::SSLClientCertificateSelector( |
26 content::WebContents* web_contents, | 28 content::WebContents* web_contents, |
27 const scoped_refptr<net::SSLCertRequestInfo>& cert_request_info, | 29 const scoped_refptr<net::SSLCertRequestInfo>& cert_request_info, |
28 scoped_ptr<content::ClientCertificateDelegate> delegate) | 30 scoped_ptr<content::ClientCertificateDelegate> delegate) |
29 : CertificateSelector(cert_request_info->client_certs, web_contents), | 31 : CertificateSelector(cert_request_info->client_certs, web_contents), |
30 SSLClientAuthObserver(web_contents->GetBrowserContext(), | 32 SSLClientAuthObserver(web_contents->GetBrowserContext(), |
31 cert_request_info, | 33 cert_request_info, |
32 delegate.Pass()) { | 34 std::move(delegate)) {} |
33 } | |
34 | 35 |
35 SSLClientCertificateSelector::~SSLClientCertificateSelector() { | 36 SSLClientCertificateSelector::~SSLClientCertificateSelector() { |
36 } | 37 } |
37 | 38 |
38 void SSLClientCertificateSelector::Init() { | 39 void SSLClientCertificateSelector::Init() { |
39 StartObserving(); | 40 StartObserving(); |
40 scoped_ptr<views::Label> text_label( | 41 scoped_ptr<views::Label> text_label( |
41 new views::Label(l10n_util::GetStringFUTF16( | 42 new views::Label(l10n_util::GetStringFUTF16( |
42 IDS_CLIENT_CERT_DIALOG_TEXT, | 43 IDS_CLIENT_CERT_DIALOG_TEXT, |
43 base::ASCIIToUTF16(cert_request_info()->host_and_port.ToString())))); | 44 base::ASCIIToUTF16(cert_request_info()->host_and_port.ToString())))); |
44 text_label->SetMultiLine(true); | 45 text_label->SetMultiLine(true); |
45 text_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 46 text_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
46 text_label->SetAllowCharacterBreak(true); | 47 text_label->SetAllowCharacterBreak(true); |
47 text_label->SizeToFit(kTableViewWidth); | 48 text_label->SizeToFit(kTableViewWidth); |
48 InitWithText(text_label.Pass()); | 49 InitWithText(std::move(text_label)); |
49 } | 50 } |
50 | 51 |
51 void SSLClientCertificateSelector::OnCertSelectedByNotification() { | 52 void SSLClientCertificateSelector::OnCertSelectedByNotification() { |
52 GetWidget()->Close(); | 53 GetWidget()->Close(); |
53 } | 54 } |
54 | 55 |
55 bool SSLClientCertificateSelector::Cancel() { | 56 bool SSLClientCertificateSelector::Cancel() { |
56 CertificateSelected(nullptr); | 57 CertificateSelected(nullptr); |
57 return true; | 58 return true; |
58 } | 59 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 103 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
103 | 104 |
104 // Not all WebContentses can show modal dialogs. | 105 // Not all WebContentses can show modal dialogs. |
105 // | 106 // |
106 // 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 |
107 // show a dialog in Browser's implementation. https://crbug.com/456255 | 108 // show a dialog in Browser's implementation. https://crbug.com/456255 |
108 if (!SSLClientCertificateSelector::CanShow(contents)) | 109 if (!SSLClientCertificateSelector::CanShow(contents)) |
109 return; | 110 return; |
110 | 111 |
111 SSLClientCertificateSelector* selector = new SSLClientCertificateSelector( | 112 SSLClientCertificateSelector* selector = new SSLClientCertificateSelector( |
112 contents, cert_request_info, delegate.Pass()); | 113 contents, cert_request_info, std::move(delegate)); |
113 selector->Init(); | 114 selector->Init(); |
114 selector->Show(); | 115 selector->Show(); |
115 } | 116 } |
116 | 117 |
117 } // namespace chrome | 118 } // namespace chrome |
OLD | NEW |