| 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/ssl/ssl_tab_helper.h" | 5 #include "chrome/browser/ssl/ssl_tab_helper.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 cert_request_info, callback); | 212 cert_request_info, callback); |
| 213 } | 213 } |
| 214 | 214 |
| 215 void SSLTabHelper::OnVerifyClientCertificateError( | 215 void SSLTabHelper::OnVerifyClientCertificateError( |
| 216 scoped_refptr<SSLAddCertHandler> handler, int error_code) { | 216 scoped_refptr<SSLAddCertHandler> handler, int error_code) { |
| 217 // Display an infobar with the error message. | 217 // Display an infobar with the error message. |
| 218 // TODO(davidben): Display a more user-friendly error string. | 218 // TODO(davidben): Display a more user-friendly error string. |
| 219 GetAddCertData(handler.get())->ShowInfoBar( | 219 GetAddCertData(handler.get())->ShowInfoBar( |
| 220 l10n_util::GetStringFUTF16(IDS_ADD_CERT_ERR_INVALID_CERT, | 220 l10n_util::GetStringFUTF16(IDS_ADD_CERT_ERR_INVALID_CERT, |
| 221 base::IntToString16(-error_code), | 221 base::IntToString16(-error_code), |
| 222 ASCIIToUTF16(net::ErrorToString(error_code))), | 222 base::ASCIIToUTF16( |
| 223 net::ErrorToString(error_code))), |
| 223 NULL); | 224 NULL); |
| 224 } | 225 } |
| 225 | 226 |
| 226 void SSLTabHelper::AskToAddClientCertificate( | 227 void SSLTabHelper::AskToAddClientCertificate( |
| 227 scoped_refptr<SSLAddCertHandler> handler) { | 228 scoped_refptr<SSLAddCertHandler> handler) { |
| 228 NOTREACHED(); // Not implemented yet. | 229 NOTREACHED(); // Not implemented yet. |
| 229 } | 230 } |
| 230 | 231 |
| 231 void SSLTabHelper::OnAddClientCertificateSuccess( | 232 void SSLTabHelper::OnAddClientCertificateSuccess( |
| 232 scoped_refptr<SSLAddCertHandler> handler) { | 233 scoped_refptr<SSLAddCertHandler> handler) { |
| 233 net::X509Certificate* cert = handler->cert(); | 234 net::X509Certificate* cert = handler->cert(); |
| 234 // TODO(evanm): GetDisplayName should return UTF-16. | 235 // TODO(evanm): GetDisplayName should return UTF-16. |
| 235 GetAddCertData(handler.get())->ShowInfoBar( | 236 GetAddCertData(handler.get())->ShowInfoBar( |
| 236 l10n_util::GetStringFUTF16(IDS_ADD_CERT_SUCCESS_INFOBAR_LABEL, | 237 l10n_util::GetStringFUTF16(IDS_ADD_CERT_SUCCESS_INFOBAR_LABEL, |
| 237 UTF8ToUTF16(cert->issuer().GetDisplayName())), | 238 base::UTF8ToUTF16( |
| 239 cert->issuer().GetDisplayName())), |
| 238 cert); | 240 cert); |
| 239 } | 241 } |
| 240 | 242 |
| 241 void SSLTabHelper::OnAddClientCertificateError( | 243 void SSLTabHelper::OnAddClientCertificateError( |
| 242 scoped_refptr<SSLAddCertHandler> handler, | 244 scoped_refptr<SSLAddCertHandler> handler, |
| 243 int error_code) { | 245 int error_code) { |
| 244 // TODO(davidben): Display a more user-friendly error string. | 246 // TODO(davidben): Display a more user-friendly error string. |
| 245 GetAddCertData(handler.get())->ShowInfoBar( | 247 GetAddCertData(handler.get())->ShowInfoBar( |
| 246 l10n_util::GetStringFUTF16(IDS_ADD_CERT_ERR_FAILED, | 248 l10n_util::GetStringFUTF16(IDS_ADD_CERT_ERR_FAILED, |
| 247 base::IntToString16(-error_code), | 249 base::IntToString16(-error_code), |
| 248 ASCIIToUTF16(net::ErrorToString(error_code))), | 250 base::ASCIIToUTF16( |
| 251 net::ErrorToString(error_code))), |
| 249 NULL); | 252 NULL); |
| 250 } | 253 } |
| 251 | 254 |
| 252 void SSLTabHelper::OnAddClientCertificateFinished( | 255 void SSLTabHelper::OnAddClientCertificateFinished( |
| 253 scoped_refptr<SSLAddCertHandler> handler) { | 256 scoped_refptr<SSLAddCertHandler> handler) { |
| 254 // Clean up. | 257 // Clean up. |
| 255 request_id_to_add_cert_data_.erase(handler->network_request_id()); | 258 request_id_to_add_cert_data_.erase(handler->network_request_id()); |
| 256 } | 259 } |
| 257 | 260 |
| 258 SSLTabHelper::SSLAddCertData* | 261 SSLTabHelper::SSLAddCertData* |
| 259 SSLTabHelper::GetAddCertData(SSLAddCertHandler* handler) { | 262 SSLTabHelper::GetAddCertData(SSLAddCertHandler* handler) { |
| 260 // Find/create the slot. | 263 // Find/create the slot. |
| 261 linked_ptr<SSLAddCertData>& ptr_ref = | 264 linked_ptr<SSLAddCertData>& ptr_ref = |
| 262 request_id_to_add_cert_data_[handler->network_request_id()]; | 265 request_id_to_add_cert_data_[handler->network_request_id()]; |
| 263 // Fill it if necessary. | 266 // Fill it if necessary. |
| 264 if (!ptr_ref.get()) { | 267 if (!ptr_ref.get()) { |
| 265 ptr_ref.reset( | 268 ptr_ref.reset( |
| 266 new SSLAddCertData(InfoBarService::FromWebContents(web_contents_))); | 269 new SSLAddCertData(InfoBarService::FromWebContents(web_contents_))); |
| 267 } | 270 } |
| 268 return ptr_ref.get(); | 271 return ptr_ref.get(); |
| 269 } | 272 } |
| OLD | NEW |