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/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/i18n/time_formatting.h" | 8 #include "base/i18n/time_formatting.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 | 57 |
58 private: | 58 private: |
59 std::vector<string16> items_; | 59 std::vector<string16> items_; |
60 | 60 |
61 DISALLOW_COPY_AND_ASSIGN(CertificateSelectorTableModel); | 61 DISALLOW_COPY_AND_ASSIGN(CertificateSelectorTableModel); |
62 }; | 62 }; |
63 | 63 |
64 CertificateSelectorTableModel::CertificateSelectorTableModel( | 64 CertificateSelectorTableModel::CertificateSelectorTableModel( |
65 net::SSLCertRequestInfo* cert_request_info) { | 65 net::SSLCertRequestInfo* cert_request_info) { |
66 for (size_t i = 0; i < cert_request_info->client_certs.size(); ++i) { | 66 for (size_t i = 0; i < cert_request_info->client_certs.size(); ++i) { |
67 net::X509Certificate* cert = cert_request_info->client_certs[i]; | 67 net::X509Certificate* cert = cert_request_info->client_certs[i].get(); |
68 string16 text = l10n_util::GetStringFUTF16( | 68 string16 text = l10n_util::GetStringFUTF16( |
69 IDS_CERT_SELECTOR_TABLE_CERT_FORMAT, | 69 IDS_CERT_SELECTOR_TABLE_CERT_FORMAT, |
70 UTF8ToUTF16(cert->subject().GetDisplayName()), | 70 UTF8ToUTF16(cert->subject().GetDisplayName()), |
71 UTF8ToUTF16(cert->issuer().GetDisplayName())); | 71 UTF8ToUTF16(cert->issuer().GetDisplayName())); |
72 items_.push_back(text); | 72 items_.push_back(text); |
73 } | 73 } |
74 } | 74 } |
75 | 75 |
76 int CertificateSelectorTableModel::RowCount() { | 76 int CertificateSelectorTableModel::RowCount() { |
77 return items_.size(); | 77 return items_.size(); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 // Select the first row automatically. This must be done after the dialog has | 154 // Select the first row automatically. This must be done after the dialog has |
155 // been created. | 155 // been created. |
156 table_->Select(0); | 156 table_->Select(0); |
157 } | 157 } |
158 | 158 |
159 net::X509Certificate* SSLClientCertificateSelector::GetSelectedCert() const { | 159 net::X509Certificate* SSLClientCertificateSelector::GetSelectedCert() const { |
160 int selected = table_->FirstSelectedRow(); | 160 int selected = table_->FirstSelectedRow(); |
161 if (selected >= 0 && | 161 if (selected >= 0 && |
162 selected < static_cast<int>( | 162 selected < static_cast<int>( |
163 cert_request_info()->client_certs.size())) | 163 cert_request_info()->client_certs.size())) |
164 return cert_request_info()->client_certs[selected]; | 164 return cert_request_info()->client_certs[selected].get(); |
165 return NULL; | 165 return NULL; |
166 } | 166 } |
167 | 167 |
168 /////////////////////////////////////////////////////////////////////////////// | 168 /////////////////////////////////////////////////////////////////////////////// |
169 // SSLClientAuthObserver implementation: | 169 // SSLClientAuthObserver implementation: |
170 | 170 |
171 void SSLClientCertificateSelector::OnCertSelectedByNotification() { | 171 void SSLClientCertificateSelector::OnCertSelectedByNotification() { |
172 DVLOG(1) << __FUNCTION__; | 172 DVLOG(1) << __FUNCTION__; |
173 DCHECK(window_); | 173 DCHECK(window_); |
174 window_->Close(); | 174 window_->Close(); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 const net::HttpNetworkSession* network_session, | 292 const net::HttpNetworkSession* network_session, |
293 net::SSLCertRequestInfo* cert_request_info, | 293 net::SSLCertRequestInfo* cert_request_info, |
294 const chrome::SelectCertificateCallback& callback) { | 294 const chrome::SelectCertificateCallback& callback) { |
295 DVLOG(1) << __FUNCTION__ << " " << contents; | 295 DVLOG(1) << __FUNCTION__ << " " << contents; |
296 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 296 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
297 (new SSLClientCertificateSelector( | 297 (new SSLClientCertificateSelector( |
298 contents, network_session, cert_request_info, callback))->Init(); | 298 contents, network_session, cert_request_info, callback))->Init(); |
299 } | 299 } |
300 | 300 |
301 } // namespace chrome | 301 } // namespace chrome |
OLD | NEW |