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

Side by Side Diff: chrome/browser/ui/views/ssl_client_certificate_selector.cc

Issue 1865213004: Convert //chrome/browser/ui from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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 unified diff | Download patch
OLDNEW
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 scoped_ptr<content::ClientCertificateDelegate> delegate) 30 std::unique_ptr<content::ClientCertificateDelegate> delegate)
31 : CertificateSelector(cert_request_info->client_certs, web_contents), 31 : CertificateSelector(cert_request_info->client_certs, web_contents),
32 SSLClientAuthObserver(web_contents->GetBrowserContext(), 32 SSLClientAuthObserver(web_contents->GetBrowserContext(),
33 cert_request_info, 33 cert_request_info,
34 std::move(delegate)) {} 34 std::move(delegate)) {}
35 35
36 SSLClientCertificateSelector::~SSLClientCertificateSelector() { 36 SSLClientCertificateSelector::~SSLClientCertificateSelector() {
37 } 37 }
38 38
39 void SSLClientCertificateSelector::Init() { 39 void SSLClientCertificateSelector::Init() {
40 StartObserving(); 40 StartObserving();
41 scoped_ptr<views::Label> text_label( 41 std::unique_ptr<views::Label> text_label(
42 new views::Label(l10n_util::GetStringFUTF16( 42 new views::Label(l10n_util::GetStringFUTF16(
43 IDS_CLIENT_CERT_DIALOG_TEXT, 43 IDS_CLIENT_CERT_DIALOG_TEXT,
44 base::ASCIIToUTF16(cert_request_info()->host_and_port.ToString())))); 44 base::ASCIIToUTF16(cert_request_info()->host_and_port.ToString()))));
45 text_label->SetMultiLine(true); 45 text_label->SetMultiLine(true);
46 text_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 46 text_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
47 text_label->SetAllowCharacterBreak(true); 47 text_label->SetAllowCharacterBreak(true);
48 text_label->SizeToFit(kTableViewWidth); 48 text_label->SizeToFit(kTableViewWidth);
49 InitWithText(std::move(text_label)); 49 InitWithText(std::move(text_label));
50 } 50 }
51 51
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 void SSLClientCertificateSelector::Unlocked(net::X509Certificate* cert) { 92 void SSLClientCertificateSelector::Unlocked(net::X509Certificate* cert) {
93 CertificateSelected(cert); 93 CertificateSelected(cert);
94 GetWidget()->Close(); 94 GetWidget()->Close();
95 } 95 }
96 96
97 namespace chrome { 97 namespace chrome {
98 98
99 void ShowSSLClientCertificateSelector( 99 void ShowSSLClientCertificateSelector(
100 content::WebContents* contents, 100 content::WebContents* contents,
101 net::SSLCertRequestInfo* cert_request_info, 101 net::SSLCertRequestInfo* cert_request_info,
102 scoped_ptr<content::ClientCertificateDelegate> delegate) { 102 std::unique_ptr<content::ClientCertificateDelegate> delegate) {
103 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 103 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
104 104
105 // Not all WebContentses can show modal dialogs. 105 // Not all WebContentses can show modal dialogs.
106 // 106 //
107 // 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
108 // show a dialog in Browser's implementation. https://crbug.com/456255 108 // show a dialog in Browser's implementation. https://crbug.com/456255
109 if (!SSLClientCertificateSelector::CanShow(contents)) 109 if (!SSLClientCertificateSelector::CanShow(contents))
110 return; 110 return;
111 111
112 SSLClientCertificateSelector* selector = new SSLClientCertificateSelector( 112 SSLClientCertificateSelector* selector = new SSLClientCertificateSelector(
113 contents, cert_request_info, std::move(delegate)); 113 contents, cert_request_info, std::move(delegate));
114 selector->Init(); 114 selector->Init();
115 selector->Show(); 115 selector->Show();
116 } 116 }
117 117
118 } // namespace chrome 118 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698