Chromium Code Reviews| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 id, | 73 id, |
| 74 resource_type, | 74 resource_type, |
| 75 url, | 75 url, |
| 76 render_process_id, | 76 render_process_id, |
| 77 render_frame_id, | 77 render_frame_id, |
| 78 ssl_info, | 78 ssl_info, |
| 79 fatal))); | 79 fatal))); |
| 80 } | 80 } |
| 81 | 81 |
| 82 // static | 82 // static |
| 83 void SSLManager::OnAuthDialog(int render_process_id, | |
| 84 int render_frame_host, | |
| 85 const std::string& serialized_security_info, | |
| 86 bool is_main_frame) { | |
| 87 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | |
| 88 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | |
| 89 base::Bind(SSLManager::OnAuthDialog, | |
| 90 render_process_id, | |
| 91 render_frame_host, | |
| 92 serialized_security_info, | |
| 93 is_main_frame)); | |
| 94 return; | |
| 95 } | |
| 96 RenderFrameHost* host = | |
|
Charlie Reis
2014/07/24 18:39:32
nit: render_frame_host (once we've renamed the id
meacer
2014/07/24 18:48:32
Done.
| |
| 97 RenderFrameHostImpl::FromID(render_process_id, render_frame_host); | |
| 98 WebContents* web_contents = WebContents::FromRenderFrameHost(host); | |
| 99 if (!web_contents) | |
| 100 return; | |
| 101 NavigationControllerImpl* controller = | |
| 102 static_cast<NavigationControllerImpl*>(&web_contents->GetController()); | |
| 103 NavigationEntryImpl* entry = | |
| 104 NavigationEntryImpl::FromNavigationEntry(controller->GetVisibleEntry()); | |
| 105 controller->ssl_manager()->UpdateEntry(serialized_security_info, | |
| 106 is_main_frame, | |
| 107 entry); | |
| 108 } | |
| 109 | |
| 110 // static | |
| 83 void SSLManager::NotifySSLInternalStateChanged(BrowserContext* context) { | 111 void SSLManager::NotifySSLInternalStateChanged(BrowserContext* context) { |
| 84 SSLManagerSet* managers = static_cast<SSLManagerSet*>( | 112 SSLManagerSet* managers = static_cast<SSLManagerSet*>( |
| 85 context->GetUserData(kSSLManagerKeyName)); | 113 context->GetUserData(kSSLManagerKeyName)); |
| 86 | 114 |
| 87 for (std::set<SSLManager*>::iterator i = managers->get().begin(); | 115 for (std::set<SSLManager*>::iterator i = managers->get().begin(); |
| 88 i != managers->get().end(); ++i) { | 116 i != managers->get().end(); ++i) { |
| 89 (*i)->UpdateEntry(NavigationEntryImpl::FromNavigationEntry( | 117 (*i)->UpdateEntry(NavigationEntryImpl::FromNavigationEntry( |
| 90 (*i)->controller()->GetLastCommittedEntry())); | 118 (*i)->controller()->GetLastCommittedEntry())); |
| 91 } | 119 } |
| 92 } | 120 } |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 109 SSLManager::~SSLManager() { | 137 SSLManager::~SSLManager() { |
| 110 SSLManagerSet* managers = static_cast<SSLManagerSet*>( | 138 SSLManagerSet* managers = static_cast<SSLManagerSet*>( |
| 111 controller_->GetBrowserContext()->GetUserData(kSSLManagerKeyName)); | 139 controller_->GetBrowserContext()->GetUserData(kSSLManagerKeyName)); |
| 112 managers->get().erase(this); | 140 managers->get().erase(this); |
| 113 } | 141 } |
| 114 | 142 |
| 115 void SSLManager::DidCommitProvisionalLoad(const LoadCommittedDetails& details) { | 143 void SSLManager::DidCommitProvisionalLoad(const LoadCommittedDetails& details) { |
| 116 NavigationEntryImpl* entry = | 144 NavigationEntryImpl* entry = |
| 117 NavigationEntryImpl::FromNavigationEntry( | 145 NavigationEntryImpl::FromNavigationEntry( |
| 118 controller_->GetLastCommittedEntry()); | 146 controller_->GetLastCommittedEntry()); |
| 147 UpdateEntry(details.serialized_security_info, | |
| 148 details.is_main_frame, | |
| 149 entry); | |
| 150 } | |
| 119 | 151 |
| 120 if (details.is_main_frame) { | 152 void SSLManager::UpdateEntry(const std::string& serialized_security_info, |
| 121 if (entry) { | 153 bool is_main_frame, |
| 122 // Decode the security details. | 154 NavigationEntryImpl* entry) { |
| 123 int ssl_cert_id; | 155 if (is_main_frame && entry) { |
| 124 net::CertStatus ssl_cert_status; | 156 // Decode the security details. |
| 125 int ssl_security_bits; | 157 int ssl_cert_id; |
| 126 int ssl_connection_status; | 158 net::CertStatus ssl_cert_status; |
| 127 SignedCertificateTimestampIDStatusList | 159 int ssl_security_bits; |
| 128 ssl_signed_certificate_timestamp_ids; | 160 int ssl_connection_status; |
| 129 DeserializeSecurityInfo(details.serialized_security_info, | 161 SignedCertificateTimestampIDStatusList |
| 130 &ssl_cert_id, | 162 ssl_signed_certificate_timestamp_ids; |
| 131 &ssl_cert_status, | 163 DeserializeSecurityInfo(serialized_security_info, |
| 132 &ssl_security_bits, | 164 &ssl_cert_id, |
| 133 &ssl_connection_status, | 165 &ssl_cert_status, |
| 134 &ssl_signed_certificate_timestamp_ids); | 166 &ssl_security_bits, |
| 167 &ssl_connection_status, | |
| 168 &ssl_signed_certificate_timestamp_ids); | |
| 135 | 169 |
| 136 // We may not have an entry if this is a navigation to an initial blank | 170 // We may not have an entry if this is a navigation to an initial blank |
| 137 // page. Reset the SSL information and add the new data we have. | 171 // page. Reset the SSL information and add the new data we have. |
| 138 entry->GetSSL() = SSLStatus(); | 172 entry->GetSSL() = SSLStatus(); |
| 139 entry->GetSSL().cert_id = ssl_cert_id; | 173 entry->GetSSL().cert_id = ssl_cert_id; |
| 140 entry->GetSSL().cert_status = ssl_cert_status; | 174 entry->GetSSL().cert_status = ssl_cert_status; |
| 141 entry->GetSSL().security_bits = ssl_security_bits; | 175 entry->GetSSL().security_bits = ssl_security_bits; |
| 142 entry->GetSSL().connection_status = ssl_connection_status; | 176 entry->GetSSL().connection_status = ssl_connection_status; |
| 143 entry->GetSSL().signed_certificate_timestamp_ids = | 177 entry->GetSSL().signed_certificate_timestamp_ids = |
| 144 ssl_signed_certificate_timestamp_ids; | 178 ssl_signed_certificate_timestamp_ids; |
| 145 } | |
| 146 } | 179 } |
| 147 | |
| 148 UpdateEntry(entry); | 180 UpdateEntry(entry); |
| 149 } | 181 } |
| 150 | 182 |
| 151 void SSLManager::DidDisplayInsecureContent() { | 183 void SSLManager::DidDisplayInsecureContent() { |
| 152 UpdateEntry( | 184 UpdateEntry( |
| 153 NavigationEntryImpl::FromNavigationEntry( | 185 NavigationEntryImpl::FromNavigationEntry( |
| 154 controller_->GetLastCommittedEntry())); | 186 controller_->GetLastCommittedEntry())); |
| 155 } | 187 } |
| 156 | 188 |
| 157 void SSLManager::DidRunInsecureContent(const std::string& security_origin) { | 189 void SSLManager::DidRunInsecureContent(const std::string& security_origin) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 214 | 246 |
| 215 WebContentsImpl* contents = | 247 WebContentsImpl* contents = |
| 216 static_cast<WebContentsImpl*>(controller_->delegate()->GetWebContents()); | 248 static_cast<WebContentsImpl*>(controller_->delegate()->GetWebContents()); |
| 217 policy()->UpdateEntry(entry, contents); | 249 policy()->UpdateEntry(entry, contents); |
| 218 | 250 |
| 219 if (!entry->GetSSL().Equals(original_ssl_status)) | 251 if (!entry->GetSSL().Equals(original_ssl_status)) |
| 220 contents->DidChangeVisibleSSLState(); | 252 contents->DidChangeVisibleSSLState(); |
| 221 } | 253 } |
| 222 | 254 |
| 223 } // namespace content | 255 } // namespace content |
| OLD | NEW |