| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_manager.h" | 5 #include "content/browser/ssl/ssl_manager.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/load_from_memory_cache_details.h" | 8 #include "chrome/browser/load_from_memory_cache_details.h" |
| 9 #include "chrome/browser/ssl/ssl_cert_error_handler.h" | |
| 10 #include "chrome/browser/ssl/ssl_policy.h" | |
| 11 #include "chrome/browser/ssl/ssl_request_info.h" | |
| 12 #include "content/browser/browser_thread.h" | 9 #include "content/browser/browser_thread.h" |
| 13 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 10 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 14 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" | 11 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" |
| 15 #include "content/browser/renderer_host/resource_request_details.h" | 12 #include "content/browser/renderer_host/resource_request_details.h" |
| 13 #include "content/browser/ssl/ssl_cert_error_handler.h" |
| 14 #include "content/browser/ssl/ssl_policy.h" |
| 15 #include "content/browser/ssl/ssl_request_info.h" |
| 16 #include "content/browser/tab_contents/navigation_details.h" | 16 #include "content/browser/tab_contents/navigation_details.h" |
| 17 #include "content/browser/tab_contents/navigation_entry.h" | 17 #include "content/browser/tab_contents/navigation_entry.h" |
| 18 #include "content/browser/tab_contents/provisional_load_details.h" | 18 #include "content/browser/tab_contents/provisional_load_details.h" |
| 19 #include "content/browser/tab_contents/tab_contents.h" | 19 #include "content/browser/tab_contents/tab_contents.h" |
| 20 #include "content/common/notification_service.h" | 20 #include "content/common/notification_service.h" |
| 21 #include "grit/generated_resources.h" | |
| 22 #include "net/base/cert_status_flags.h" | 21 #include "net/base/cert_status_flags.h" |
| 23 #include "ui/base/l10n/l10n_util.h" | |
| 24 | 22 |
| 25 // static | 23 // static |
| 26 void SSLManager::OnSSLCertificateError(ResourceDispatcherHost* rdh, | 24 void SSLManager::OnSSLCertificateError(ResourceDispatcherHost* rdh, |
| 27 net::URLRequest* request, | 25 net::URLRequest* request, |
| 28 int cert_error, | 26 int cert_error, |
| 29 net::X509Certificate* cert) { | 27 net::X509Certificate* cert) { |
| 30 DVLOG(1) << "OnSSLCertificateError() cert_error: " << cert_error | 28 DVLOG(1) << "OnSSLCertificateError() cert_error: " << cert_error |
| 31 << " url: " << request->url().spec(); | 29 << " url: " << request->url().spec(); |
| 32 | 30 |
| 33 ResourceDispatcherHostRequestInfo* info = | 31 ResourceDispatcherHostRequestInfo* info = |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 } | 83 } |
| 86 | 84 |
| 87 Pickle pickle(state.data(), static_cast<int>(state.size())); | 85 Pickle pickle(state.data(), static_cast<int>(state.size())); |
| 88 void * iter = NULL; | 86 void * iter = NULL; |
| 89 return pickle.ReadInt(&iter, cert_id) && | 87 return pickle.ReadInt(&iter, cert_id) && |
| 90 pickle.ReadInt(&iter, cert_status) && | 88 pickle.ReadInt(&iter, cert_status) && |
| 91 pickle.ReadInt(&iter, security_bits) && | 89 pickle.ReadInt(&iter, security_bits) && |
| 92 pickle.ReadInt(&iter, ssl_connection_status); | 90 pickle.ReadInt(&iter, ssl_connection_status); |
| 93 } | 91 } |
| 94 | 92 |
| 95 // static | |
| 96 string16 SSLManager::GetEVCertName(const net::X509Certificate& cert) { | |
| 97 // EV are required to have an organization name and country. | |
| 98 if (cert.subject().organization_names.empty() || | |
| 99 cert.subject().country_name.empty()) { | |
| 100 NOTREACHED(); | |
| 101 return string16(); | |
| 102 } | |
| 103 | |
| 104 return l10n_util::GetStringFUTF16( | |
| 105 IDS_SECURE_CONNECTION_EV, | |
| 106 UTF8ToUTF16(cert.subject().organization_names[0]), | |
| 107 UTF8ToUTF16(cert.subject().country_name)); | |
| 108 } | |
| 109 | |
| 110 SSLManager::SSLManager(NavigationController* controller) | 93 SSLManager::SSLManager(NavigationController* controller) |
| 111 : backend_(controller), | 94 : backend_(controller), |
| 112 policy_(new SSLPolicy(&backend_)), | 95 policy_(new SSLPolicy(&backend_)), |
| 113 controller_(controller) { | 96 controller_(controller) { |
| 114 DCHECK(controller_); | 97 DCHECK(controller_); |
| 115 | 98 |
| 116 // Subscribe to various notifications. | 99 // Subscribe to various notifications. |
| 117 registrar_.Add(this, NotificationType::FAIL_PROVISIONAL_LOAD_WITH_ERROR, | 100 registrar_.Add(this, NotificationType::FAIL_PROVISIONAL_LOAD_WITH_ERROR, |
| 118 Source<NavigationController>(controller_)); | 101 Source<NavigationController>(controller_)); |
| 119 registrar_.Add(this, NotificationType::RESOURCE_RESPONSE_STARTED, | 102 registrar_.Add(this, NotificationType::RESOURCE_RESPONSE_STARTED, |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 | 238 |
| 256 policy()->UpdateEntry(entry, controller_->tab_contents()); | 239 policy()->UpdateEntry(entry, controller_->tab_contents()); |
| 257 | 240 |
| 258 if (!entry->ssl().Equals(original_ssl_status)) { | 241 if (!entry->ssl().Equals(original_ssl_status)) { |
| 259 NotificationService::current()->Notify( | 242 NotificationService::current()->Notify( |
| 260 NotificationType::SSL_VISIBLE_STATE_CHANGED, | 243 NotificationType::SSL_VISIBLE_STATE_CHANGED, |
| 261 Source<NavigationController>(controller_), | 244 Source<NavigationController>(controller_), |
| 262 NotificationService::NoDetails()); | 245 NotificationService::NoDetails()); |
| 263 } | 246 } |
| 264 } | 247 } |
| OLD | NEW |