| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 fatal))); | 78 fatal))); |
| 79 } | 79 } |
| 80 | 80 |
| 81 // static | 81 // static |
| 82 void SSLManager::NotifySSLInternalStateChanged(BrowserContext* context) { | 82 void SSLManager::NotifySSLInternalStateChanged(BrowserContext* context) { |
| 83 SSLManagerSet* managers = static_cast<SSLManagerSet*>( | 83 SSLManagerSet* managers = static_cast<SSLManagerSet*>( |
| 84 context->GetUserData(kSSLManagerKeyName)); | 84 context->GetUserData(kSSLManagerKeyName)); |
| 85 | 85 |
| 86 for (std::set<SSLManager*>::iterator i = managers->get().begin(); | 86 for (std::set<SSLManager*>::iterator i = managers->get().begin(); |
| 87 i != managers->get().end(); ++i) { | 87 i != managers->get().end(); ++i) { |
| 88 (*i)->UpdateEntry(NavigationEntryImpl::FromNavigationEntry( | 88 (*i)->UpdateEntry((*i)->controller()->GetLastCommittedEntry()); |
| 89 (*i)->controller()->GetLastCommittedEntry())); | |
| 90 } | 89 } |
| 91 } | 90 } |
| 92 | 91 |
| 93 SSLManager::SSLManager(NavigationControllerImpl* controller) | 92 SSLManager::SSLManager(NavigationControllerImpl* controller) |
| 94 : backend_(controller), | 93 : backend_(controller), |
| 95 policy_(new SSLPolicy(&backend_)), | 94 policy_(new SSLPolicy(&backend_)), |
| 96 controller_(controller) { | 95 controller_(controller) { |
| 97 DCHECK(controller_); | 96 DCHECK(controller_); |
| 98 | 97 |
| 99 SSLManagerSet* managers = static_cast<SSLManagerSet*>( | 98 SSLManagerSet* managers = static_cast<SSLManagerSet*>( |
| 100 controller_->GetBrowserContext()->GetUserData(kSSLManagerKeyName)); | 99 controller_->GetBrowserContext()->GetUserData(kSSLManagerKeyName)); |
| 101 if (!managers) { | 100 if (!managers) { |
| 102 managers = new SSLManagerSet; | 101 managers = new SSLManagerSet; |
| 103 controller_->GetBrowserContext()->SetUserData(kSSLManagerKeyName, managers); | 102 controller_->GetBrowserContext()->SetUserData(kSSLManagerKeyName, managers); |
| 104 } | 103 } |
| 105 managers->get().insert(this); | 104 managers->get().insert(this); |
| 106 } | 105 } |
| 107 | 106 |
| 108 SSLManager::~SSLManager() { | 107 SSLManager::~SSLManager() { |
| 109 SSLManagerSet* managers = static_cast<SSLManagerSet*>( | 108 SSLManagerSet* managers = static_cast<SSLManagerSet*>( |
| 110 controller_->GetBrowserContext()->GetUserData(kSSLManagerKeyName)); | 109 controller_->GetBrowserContext()->GetUserData(kSSLManagerKeyName)); |
| 111 managers->get().erase(this); | 110 managers->get().erase(this); |
| 112 } | 111 } |
| 113 | 112 |
| 114 void SSLManager::DidCommitProvisionalLoad(const LoadCommittedDetails& details) { | 113 void SSLManager::DidCommitProvisionalLoad(const LoadCommittedDetails& details) { |
| 115 NavigationEntryImpl* entry = | 114 NavigationEntryImpl* entry = controller_->GetLastCommittedEntry(); |
| 116 NavigationEntryImpl::FromNavigationEntry( | |
| 117 controller_->GetLastCommittedEntry()); | |
| 118 | 115 |
| 119 if (details.is_main_frame) { | 116 if (details.is_main_frame) { |
| 120 if (entry) { | 117 if (entry) { |
| 121 // Decode the security details. | 118 // Decode the security details. |
| 122 int ssl_cert_id; | 119 int ssl_cert_id; |
| 123 net::CertStatus ssl_cert_status; | 120 net::CertStatus ssl_cert_status; |
| 124 int ssl_security_bits; | 121 int ssl_security_bits; |
| 125 int ssl_connection_status; | 122 int ssl_connection_status; |
| 126 SignedCertificateTimestampIDStatusList | 123 SignedCertificateTimestampIDStatusList |
| 127 ssl_signed_certificate_timestamp_ids; | 124 ssl_signed_certificate_timestamp_ids; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 141 entry->GetSSL().connection_status = ssl_connection_status; | 138 entry->GetSSL().connection_status = ssl_connection_status; |
| 142 entry->GetSSL().signed_certificate_timestamp_ids = | 139 entry->GetSSL().signed_certificate_timestamp_ids = |
| 143 ssl_signed_certificate_timestamp_ids; | 140 ssl_signed_certificate_timestamp_ids; |
| 144 } | 141 } |
| 145 } | 142 } |
| 146 | 143 |
| 147 UpdateEntry(entry); | 144 UpdateEntry(entry); |
| 148 } | 145 } |
| 149 | 146 |
| 150 void SSLManager::DidDisplayInsecureContent() { | 147 void SSLManager::DidDisplayInsecureContent() { |
| 151 UpdateEntry( | 148 UpdateEntry(controller_->GetLastCommittedEntry()); |
| 152 NavigationEntryImpl::FromNavigationEntry( | |
| 153 controller_->GetLastCommittedEntry())); | |
| 154 } | 149 } |
| 155 | 150 |
| 156 void SSLManager::DidRunInsecureContent(const std::string& security_origin) { | 151 void SSLManager::DidRunInsecureContent(const std::string& security_origin) { |
| 157 NavigationEntryImpl* navigation_entry = | 152 NavigationEntryImpl* navigation_entry = controller_->GetLastCommittedEntry(); |
| 158 NavigationEntryImpl::FromNavigationEntry( | |
| 159 controller_->GetLastCommittedEntry()); | |
| 160 policy()->DidRunInsecureContent(navigation_entry, security_origin); | 153 policy()->DidRunInsecureContent(navigation_entry, security_origin); |
| 161 UpdateEntry(navigation_entry); | 154 UpdateEntry(navigation_entry); |
| 162 } | 155 } |
| 163 | 156 |
| 164 void SSLManager::DidLoadFromMemoryCache( | 157 void SSLManager::DidLoadFromMemoryCache( |
| 165 const LoadFromMemoryCacheDetails& details) { | 158 const LoadFromMemoryCacheDetails& details) { |
| 166 // Simulate loading this resource through the usual path. | 159 // Simulate loading this resource through the usual path. |
| 167 // Note that we specify SUB_RESOURCE as the resource type as WebCore only | 160 // Note that we specify SUB_RESOURCE as the resource type as WebCore only |
| 168 // caches sub-resources. | 161 // caches sub-resources. |
| 169 // This resource must have been loaded with no filtering because filtered | 162 // This resource must have been loaded with no filtering because filtered |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 | 206 |
| 214 WebContentsImpl* contents = | 207 WebContentsImpl* contents = |
| 215 static_cast<WebContentsImpl*>(controller_->delegate()->GetWebContents()); | 208 static_cast<WebContentsImpl*>(controller_->delegate()->GetWebContents()); |
| 216 policy()->UpdateEntry(entry, contents); | 209 policy()->UpdateEntry(entry, contents); |
| 217 | 210 |
| 218 if (!entry->GetSSL().Equals(original_ssl_status)) | 211 if (!entry->GetSSL().Equals(original_ssl_status)) |
| 219 contents->DidChangeVisibleSSLState(); | 212 contents->DidChangeVisibleSSLState(); |
| 220 } | 213 } |
| 221 | 214 |
| 222 } // namespace content | 215 } // namespace content |
| OLD | NEW |