| 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 "content/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 "content/browser/browser_thread.h" | 8 #include "content/browser/browser_thread.h" |
| 9 #include "content/browser/load_from_memory_cache_details.h" | 9 #include "content/browser/load_from_memory_cache_details.h" |
| 10 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 10 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 void SSLManager::NotifySSLInternalStateChanged( | 48 void SSLManager::NotifySSLInternalStateChanged( |
| 49 NavigationController* controller) { | 49 NavigationController* controller) { |
| 50 NotificationService::current()->Notify( | 50 NotificationService::current()->Notify( |
| 51 content::NOTIFICATION_SSL_INTERNAL_STATE_CHANGED, | 51 content::NOTIFICATION_SSL_INTERNAL_STATE_CHANGED, |
| 52 Source<content::BrowserContext>(controller->browser_context()), | 52 Source<content::BrowserContext>(controller->browser_context()), |
| 53 NotificationService::NoDetails()); | 53 NotificationService::NoDetails()); |
| 54 } | 54 } |
| 55 | 55 |
| 56 // static | 56 // static |
| 57 std::string SSLManager::SerializeSecurityInfo(int cert_id, | 57 std::string SSLManager::SerializeSecurityInfo(int cert_id, |
| 58 int cert_status, | 58 net::CertStatus cert_status, |
| 59 int security_bits, | 59 int security_bits, |
| 60 int ssl_connection_status) { | 60 int ssl_connection_status) { |
| 61 Pickle pickle; | 61 Pickle pickle; |
| 62 pickle.WriteInt(cert_id); | 62 pickle.WriteInt(cert_id); |
| 63 pickle.WriteInt(cert_status); | 63 pickle.WriteUInt32(cert_status); |
| 64 pickle.WriteInt(security_bits); | 64 pickle.WriteInt(security_bits); |
| 65 pickle.WriteInt(ssl_connection_status); | 65 pickle.WriteInt(ssl_connection_status); |
| 66 return std::string(static_cast<const char*>(pickle.data()), pickle.size()); | 66 return std::string(static_cast<const char*>(pickle.data()), pickle.size()); |
| 67 } | 67 } |
| 68 | 68 |
| 69 // static | 69 // static |
| 70 bool SSLManager::DeserializeSecurityInfo(const std::string& state, | 70 bool SSLManager::DeserializeSecurityInfo(const std::string& state, |
| 71 int* cert_id, | 71 int* cert_id, |
| 72 int* cert_status, | 72 net::CertStatus* cert_status, |
| 73 int* security_bits, | 73 int* security_bits, |
| 74 int* ssl_connection_status) { | 74 int* ssl_connection_status) { |
| 75 DCHECK(cert_id && cert_status && security_bits && ssl_connection_status); | 75 DCHECK(cert_id && cert_status && security_bits && ssl_connection_status); |
| 76 if (state.empty()) { | 76 if (state.empty()) { |
| 77 // No SSL used. | 77 // No SSL used. |
| 78 *cert_id = 0; | 78 *cert_id = 0; |
| 79 // The following are not applicable and are set to the default values. | 79 // The following are not applicable and are set to the default values. |
| 80 *cert_status = 0; | 80 *cert_status = 0; |
| 81 *security_bits = -1; | 81 *security_bits = -1; |
| 82 *ssl_connection_status = 0; | 82 *ssl_connection_status = 0; |
| 83 return false; | 83 return false; |
| 84 } | 84 } |
| 85 | 85 |
| 86 Pickle pickle(state.data(), static_cast<int>(state.size())); | 86 Pickle pickle(state.data(), static_cast<int>(state.size())); |
| 87 void * iter = NULL; | 87 void * iter = NULL; |
| 88 return pickle.ReadInt(&iter, cert_id) && | 88 return pickle.ReadInt(&iter, cert_id) && |
| 89 pickle.ReadInt(&iter, cert_status) && | 89 pickle.ReadUInt32(&iter, cert_status) && |
| 90 pickle.ReadInt(&iter, security_bits) && | 90 pickle.ReadInt(&iter, security_bits) && |
| 91 pickle.ReadInt(&iter, ssl_connection_status); | 91 pickle.ReadInt(&iter, ssl_connection_status); |
| 92 } | 92 } |
| 93 | 93 |
| 94 SSLManager::SSLManager(NavigationController* controller) | 94 SSLManager::SSLManager(NavigationController* controller) |
| 95 : backend_(controller), | 95 : backend_(controller), |
| 96 policy_(new SSLPolicy(&backend_)), | 96 policy_(new SSLPolicy(&backend_)), |
| 97 controller_(controller) { | 97 controller_(controller) { |
| 98 DCHECK(controller_); | 98 DCHECK(controller_); |
| 99 | 99 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 117 void SSLManager::DidCommitProvisionalLoad( | 117 void SSLManager::DidCommitProvisionalLoad( |
| 118 const NotificationDetails& in_details) { | 118 const NotificationDetails& in_details) { |
| 119 content::LoadCommittedDetails* details = | 119 content::LoadCommittedDetails* details = |
| 120 Details<content::LoadCommittedDetails>(in_details).ptr(); | 120 Details<content::LoadCommittedDetails>(in_details).ptr(); |
| 121 | 121 |
| 122 NavigationEntry* entry = controller_->GetActiveEntry(); | 122 NavigationEntry* entry = controller_->GetActiveEntry(); |
| 123 | 123 |
| 124 if (details->is_main_frame) { | 124 if (details->is_main_frame) { |
| 125 if (entry) { | 125 if (entry) { |
| 126 // Decode the security details. | 126 // Decode the security details. |
| 127 int ssl_cert_id, ssl_cert_status, ssl_security_bits, | 127 int ssl_cert_id; |
| 128 ssl_connection_status; | 128 net::CertStatus ssl_cert_status; |
| 129 int ssl_security_bits; |
| 130 int ssl_connection_status; |
| 129 DeserializeSecurityInfo(details->serialized_security_info, | 131 DeserializeSecurityInfo(details->serialized_security_info, |
| 130 &ssl_cert_id, | 132 &ssl_cert_id, |
| 131 &ssl_cert_status, | 133 &ssl_cert_status, |
| 132 &ssl_security_bits, | 134 &ssl_security_bits, |
| 133 &ssl_connection_status); | 135 &ssl_connection_status); |
| 134 | 136 |
| 135 // We may not have an entry if this is a navigation to an initial blank | 137 // We may not have an entry if this is a navigation to an initial blank |
| 136 // page. Reset the SSL information and add the new data we have. | 138 // page. Reset the SSL information and add the new data we have. |
| 137 entry->ssl() = NavigationEntry::SSLStatus(); | 139 entry->ssl() = NavigationEntry::SSLStatus(); |
| 138 entry->ssl().set_cert_id(ssl_cert_id); | 140 entry->ssl().set_cert_id(ssl_cert_id); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 | 242 |
| 241 policy()->UpdateEntry(entry, controller_->tab_contents()); | 243 policy()->UpdateEntry(entry, controller_->tab_contents()); |
| 242 | 244 |
| 243 if (!entry->ssl().Equals(original_ssl_status)) { | 245 if (!entry->ssl().Equals(original_ssl_status)) { |
| 244 NotificationService::current()->Notify( | 246 NotificationService::current()->Notify( |
| 245 content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED, | 247 content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED, |
| 246 Source<NavigationController>(controller_), | 248 Source<NavigationController>(controller_), |
| 247 NotificationService::NoDetails()); | 249 NotificationService::NoDetails()); |
| 248 } | 250 } |
| 249 } | 251 } |
| OLD | NEW |