| 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/tab_contents/tab_contents_ssl_helper.h" | 5 #include "chrome/browser/tab_contents/tab_contents_ssl_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" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chrome/browser/certificate_viewer.h" | 15 #include "chrome/browser/certificate_viewer.h" |
| 16 #include "chrome/browser/content_settings/host_content_settings_map.h" | 16 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 17 #include "chrome/browser/infobars/infobar.h" | 17 #include "chrome/browser/infobars/infobar.h" |
| 18 #include "chrome/browser/infobars/infobar_tab_helper.h" | 18 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/ssl/ssl_add_cert_handler.h" | 20 #include "chrome/browser/ssl/ssl_add_cert_handler.h" |
| 21 #include "chrome/browser/ssl_client_certificate_selector.h" | 21 #include "chrome/browser/ssl_client_certificate_selector.h" |
| 22 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 22 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
| 23 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" | 23 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" |
| 24 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 24 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 25 #include "chrome/common/chrome_notification_types.h" | 25 #include "chrome/common/chrome_notification_types.h" |
| 26 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
| 27 #include "content/browser/ssl/ssl_client_auth_handler.h" | |
| 28 #include "content/public/browser/notification_details.h" | 27 #include "content/public/browser/notification_details.h" |
| 29 #include "content/public/browser/notification_source.h" | 28 #include "content/public/browser/notification_source.h" |
| 30 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
| 31 #include "content/public/browser/web_contents_view.h" | 30 #include "content/public/browser/web_contents_view.h" |
| 32 #include "grit/generated_resources.h" | 31 #include "grit/generated_resources.h" |
| 33 #include "grit/theme_resources_standard.h" | 32 #include "grit/theme_resources_standard.h" |
| 34 #include "net/base/net_errors.h" | 33 #include "net/base/net_errors.h" |
| 35 #include "net/base/x509_certificate.h" | 34 #include "net/base/x509_certificate.h" |
| 36 #include "ui/base/l10n/l10n_util.h" | 35 #include "ui/base/l10n/l10n_util.h" |
| 37 #include "ui/base/resource/resource_bundle.h" | 36 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 // TabContentsSSLHelper ------------------------------------------------------- | 183 // TabContentsSSLHelper ------------------------------------------------------- |
| 185 | 184 |
| 186 TabContentsSSLHelper::TabContentsSSLHelper(TabContentsWrapper* tab_contents) | 185 TabContentsSSLHelper::TabContentsSSLHelper(TabContentsWrapper* tab_contents) |
| 187 : tab_contents_(tab_contents) { | 186 : tab_contents_(tab_contents) { |
| 188 } | 187 } |
| 189 | 188 |
| 190 TabContentsSSLHelper::~TabContentsSSLHelper() { | 189 TabContentsSSLHelper::~TabContentsSSLHelper() { |
| 191 } | 190 } |
| 192 | 191 |
| 193 void TabContentsSSLHelper::ShowClientCertificateRequestDialog( | 192 void TabContentsSSLHelper::ShowClientCertificateRequestDialog( |
| 194 scoped_refptr<SSLClientAuthHandler> handler) { | 193 const net::HttpNetworkSession* network_session, |
| 194 net::SSLCertRequestInfo* cert_request_info, |
| 195 const base::Callback<void(net::X509Certificate*)>& callback) { |
| 195 browser::ShowSSLClientCertificateSelector( | 196 browser::ShowSSLClientCertificateSelector( |
| 196 tab_contents_, handler->cert_request_info(), handler); | 197 tab_contents_, network_session, cert_request_info, callback); |
| 197 } | 198 } |
| 198 | 199 |
| 199 void TabContentsSSLHelper::OnVerifyClientCertificateError( | 200 void TabContentsSSLHelper::OnVerifyClientCertificateError( |
| 200 scoped_refptr<SSLAddCertHandler> handler, int error_code) { | 201 scoped_refptr<SSLAddCertHandler> handler, int error_code) { |
| 201 SSLAddCertData* add_cert_data = GetAddCertData(handler); | 202 SSLAddCertData* add_cert_data = GetAddCertData(handler); |
| 202 // Display an infobar with the error message. | 203 // Display an infobar with the error message. |
| 203 // TODO(davidben): Display a more user-friendly error string. | 204 // TODO(davidben): Display a more user-friendly error string. |
| 204 add_cert_data->ShowErrorInfoBar( | 205 add_cert_data->ShowErrorInfoBar( |
| 205 l10n_util::GetStringFUTF16(IDS_ADD_CERT_ERR_INVALID_CERT, | 206 l10n_util::GetStringFUTF16(IDS_ADD_CERT_ERR_INVALID_CERT, |
| 206 base::IntToString16(-error_code), | 207 base::IntToString16(-error_code), |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 TabContentsSSLHelper::SSLAddCertData* TabContentsSSLHelper::GetAddCertData( | 241 TabContentsSSLHelper::SSLAddCertData* TabContentsSSLHelper::GetAddCertData( |
| 241 SSLAddCertHandler* handler) { | 242 SSLAddCertHandler* handler) { |
| 242 // Find/create the slot. | 243 // Find/create the slot. |
| 243 linked_ptr<SSLAddCertData>& ptr_ref = | 244 linked_ptr<SSLAddCertData>& ptr_ref = |
| 244 request_id_to_add_cert_data_[handler->network_request_id()]; | 245 request_id_to_add_cert_data_[handler->network_request_id()]; |
| 245 // Fill it if necessary. | 246 // Fill it if necessary. |
| 246 if (!ptr_ref.get()) | 247 if (!ptr_ref.get()) |
| 247 ptr_ref.reset(new SSLAddCertData(tab_contents_)); | 248 ptr_ref.reset(new SSLAddCertData(tab_contents_)); |
| 248 return ptr_ref.get(); | 249 return ptr_ref.get(); |
| 249 } | 250 } |
| OLD | NEW |