| 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 "content/browser/ssl/ssl_manager.h" | 5 #include "content/browser/ssl/ssl_manager.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 } | 80 } |
| 81 | 81 |
| 82 // static | 82 // static |
| 83 void SSLManager::NotifySSLInternalStateChanged(BrowserContext* context) { | 83 void SSLManager::NotifySSLInternalStateChanged(BrowserContext* context) { |
| 84 SSLManagerSet* managers = static_cast<SSLManagerSet*>( | 84 SSLManagerSet* managers = static_cast<SSLManagerSet*>( |
| 85 context->GetUserData(kSSLManagerKeyName)); | 85 context->GetUserData(kSSLManagerKeyName)); |
| 86 | 86 |
| 87 for (std::set<SSLManager*>::iterator i = managers->get().begin(); | 87 for (std::set<SSLManager*>::iterator i = managers->get().begin(); |
| 88 i != managers->get().end(); ++i) { | 88 i != managers->get().end(); ++i) { |
| 89 (*i)->UpdateEntry(NavigationEntryImpl::FromNavigationEntry( | 89 (*i)->UpdateEntry(NavigationEntryImpl::FromNavigationEntry( |
| 90 (*i)->controller()->GetActiveEntry())); | 90 (*i)->controller()->GetLastCommittedEntry())); |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 | 93 |
| 94 SSLManager::SSLManager(NavigationControllerImpl* controller) | 94 SSLManager::SSLManager(NavigationControllerImpl* 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 |
| 100 SSLManagerSet* managers = static_cast<SSLManagerSet*>( | 100 SSLManagerSet* managers = static_cast<SSLManagerSet*>( |
| 101 controller_->GetBrowserContext()->GetUserData(kSSLManagerKeyName)); | 101 controller_->GetBrowserContext()->GetUserData(kSSLManagerKeyName)); |
| 102 if (!managers) { | 102 if (!managers) { |
| 103 managers = new SSLManagerSet; | 103 managers = new SSLManagerSet; |
| 104 controller_->GetBrowserContext()->SetUserData(kSSLManagerKeyName, managers); | 104 controller_->GetBrowserContext()->SetUserData(kSSLManagerKeyName, managers); |
| 105 } | 105 } |
| 106 managers->get().insert(this); | 106 managers->get().insert(this); |
| 107 } | 107 } |
| 108 | 108 |
| 109 SSLManager::~SSLManager() { | 109 SSLManager::~SSLManager() { |
| 110 SSLManagerSet* managers = static_cast<SSLManagerSet*>( | 110 SSLManagerSet* managers = static_cast<SSLManagerSet*>( |
| 111 controller_->GetBrowserContext()->GetUserData(kSSLManagerKeyName)); | 111 controller_->GetBrowserContext()->GetUserData(kSSLManagerKeyName)); |
| 112 managers->get().erase(this); | 112 managers->get().erase(this); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void SSLManager::DidCommitProvisionalLoad(const LoadCommittedDetails& details) { | 115 void SSLManager::DidCommitProvisionalLoad(const LoadCommittedDetails& details) { |
| 116 NavigationEntryImpl* entry = | 116 NavigationEntryImpl* entry = |
| 117 NavigationEntryImpl::FromNavigationEntry(controller_->GetActiveEntry()); | 117 NavigationEntryImpl::FromNavigationEntry( |
| 118 controller_->GetLastCommittedEntry()); |
| 118 | 119 |
| 119 if (details.is_main_frame) { | 120 if (details.is_main_frame) { |
| 120 if (entry) { | 121 if (entry) { |
| 121 // Decode the security details. | 122 // Decode the security details. |
| 122 int ssl_cert_id; | 123 int ssl_cert_id; |
| 123 net::CertStatus ssl_cert_status; | 124 net::CertStatus ssl_cert_status; |
| 124 int ssl_security_bits; | 125 int ssl_security_bits; |
| 125 int ssl_connection_status; | 126 int ssl_connection_status; |
| 126 DeserializeSecurityInfo(details.serialized_security_info, | 127 DeserializeSecurityInfo(details.serialized_security_info, |
| 127 &ssl_cert_id, | 128 &ssl_cert_id, |
| 128 &ssl_cert_status, | 129 &ssl_cert_status, |
| 129 &ssl_security_bits, | 130 &ssl_security_bits, |
| 130 &ssl_connection_status); | 131 &ssl_connection_status); |
| 131 | 132 |
| 132 // We may not have an entry if this is a navigation to an initial blank | 133 // We may not have an entry if this is a navigation to an initial blank |
| 133 // page. Reset the SSL information and add the new data we have. | 134 // page. Reset the SSL information and add the new data we have. |
| 134 entry->GetSSL() = SSLStatus(); | 135 entry->GetSSL() = SSLStatus(); |
| 135 entry->GetSSL().cert_id = ssl_cert_id; | 136 entry->GetSSL().cert_id = ssl_cert_id; |
| 136 entry->GetSSL().cert_status = ssl_cert_status; | 137 entry->GetSSL().cert_status = ssl_cert_status; |
| 137 entry->GetSSL().security_bits = ssl_security_bits; | 138 entry->GetSSL().security_bits = ssl_security_bits; |
| 138 entry->GetSSL().connection_status = ssl_connection_status; | 139 entry->GetSSL().connection_status = ssl_connection_status; |
| 139 } | 140 } |
| 140 } | 141 } |
| 141 | 142 |
| 142 UpdateEntry(entry); | 143 UpdateEntry(entry); |
| 143 } | 144 } |
| 144 | 145 |
| 145 void SSLManager::DidDisplayInsecureContent() { | 146 void SSLManager::DidDisplayInsecureContent() { |
| 146 UpdateEntry( | 147 UpdateEntry( |
| 147 NavigationEntryImpl::FromNavigationEntry(controller_->GetActiveEntry())); | 148 NavigationEntryImpl::FromNavigationEntry( |
| 149 controller_->GetLastCommittedEntry())); |
| 148 } | 150 } |
| 149 | 151 |
| 150 void SSLManager::DidRunInsecureContent(const std::string& security_origin) { | 152 void SSLManager::DidRunInsecureContent(const std::string& security_origin) { |
| 151 NavigationEntryImpl* navigation_entry = | 153 NavigationEntryImpl* navigation_entry = |
| 152 NavigationEntryImpl::FromNavigationEntry(controller_->GetActiveEntry()); | 154 NavigationEntryImpl::FromNavigationEntry( |
| 155 controller_->GetLastCommittedEntry()); |
| 153 policy()->DidRunInsecureContent(navigation_entry, security_origin); | 156 policy()->DidRunInsecureContent(navigation_entry, security_origin); |
| 154 UpdateEntry(navigation_entry); | 157 UpdateEntry(navigation_entry); |
| 155 } | 158 } |
| 156 | 159 |
| 157 void SSLManager::DidLoadFromMemoryCache( | 160 void SSLManager::DidLoadFromMemoryCache( |
| 158 const LoadFromMemoryCacheDetails& details) { | 161 const LoadFromMemoryCacheDetails& details) { |
| 159 // Simulate loading this resource through the usual path. | 162 // Simulate loading this resource through the usual path. |
| 160 // Note that we specify SUB_RESOURCE as the resource type as WebCore only | 163 // Note that we specify SUB_RESOURCE as the resource type as WebCore only |
| 161 // caches sub-resources. | 164 // caches sub-resources. |
| 162 // This resource must have been loaded with no filtering because filtered | 165 // This resource must have been loaded with no filtering because filtered |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 207 |
| 205 SSLStatus original_ssl_status = entry->GetSSL(); // Copy! | 208 SSLStatus original_ssl_status = entry->GetSSL(); // Copy! |
| 206 | 209 |
| 207 policy()->UpdateEntry(entry, controller_->web_contents()); | 210 policy()->UpdateEntry(entry, controller_->web_contents()); |
| 208 | 211 |
| 209 if (!entry->GetSSL().Equals(original_ssl_status)) | 212 if (!entry->GetSSL().Equals(original_ssl_status)) |
| 210 controller_->web_contents()->DidChangeVisibleSSLState(); | 213 controller_->web_contents()->DidChangeVisibleSSLState(); |
| 211 } | 214 } |
| 212 | 215 |
| 213 } // namespace content | 216 } // namespace content |
| OLD | NEW |