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" |
| 11 #include "base/supports_user_data.h" | 11 #include "base/supports_user_data.h" |
| 12 #include "content/browser/frame_host/navigation_entry_impl.h" | 12 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 13 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 13 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 14 #include "content/browser/loader/resource_request_info_impl.h" | 14 #include "content/browser/loader/resource_request_info_impl.h" |
| 15 #include "content/browser/ssl/ssl_cert_error_handler.h" | 15 #include "content/browser/ssl/ssl_cert_error_handler.h" |
| 16 #include "content/browser/ssl/ssl_policy.h" | 16 #include "content/browser/ssl/ssl_policy.h" |
| 17 #include "content/browser/ssl/ssl_request_info.h" | 17 #include "content/browser/ssl/ssl_request_info.h" |
| 18 #include "content/browser/web_contents/web_contents_impl.h" | 18 #include "content/browser/web_contents/web_contents_impl.h" |
| 19 #include "content/common/ssl_status_serialization.h" | 19 #include "content/common/ssl_status_serialization.h" |
| 20 #include "content/public/browser/browser_context.h" | 20 #include "content/public/browser/browser_context.h" |
| 21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 22 #include "content/public/browser/load_from_memory_cache_details.h" | 22 #include "content/public/browser/load_from_memory_cache_details.h" |
| 23 #include "content/public/browser/navigation_details.h" | 23 #include "content/public/browser/navigation_details.h" |
| 24 #include "content/public/browser/navigation_entry.h" | |
| 24 #include "content/public/browser/resource_request_details.h" | 25 #include "content/public/browser/resource_request_details.h" |
| 25 #include "content/public/common/ssl_status.h" | 26 #include "content/public/common/ssl_status.h" |
| 26 #include "net/url_request/url_request.h" | 27 #include "net/url_request/url_request.h" |
| 27 | 28 |
| 28 namespace content { | 29 namespace content { |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| 31 | 32 |
| 32 const char kSSLManagerKeyName[] = "content_ssl_manager"; | 33 const char kSSLManagerKeyName[] = "content_ssl_manager"; |
| 33 | 34 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 new SSLCertErrorHandler(delegate, | 73 new SSLCertErrorHandler(delegate, |
| 73 resource_type, | 74 resource_type, |
| 74 url, | 75 url, |
| 75 render_process_id, | 76 render_process_id, |
| 76 render_frame_id, | 77 render_frame_id, |
| 77 ssl_info, | 78 ssl_info, |
| 78 fatal))); | 79 fatal))); |
| 79 } | 80 } |
| 80 | 81 |
| 81 // static | 82 // static |
| 83 void SSLManager::OnAuthDialog(int render_process_id, | |
| 84 int render_frame_id, | |
| 85 const std::string& serialized_security_info, | |
| 86 bool is_main_frame) { | |
| 87 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | |
|
Charlie Reis
2015/03/18 17:46:38
Please have a separate method for the UI thread ve
palmer
2015/09/29 00:03:33
The sole call site is on the IO thread. Making the
| |
| 88 BrowserThread::PostTask( | |
| 89 BrowserThread::UI, FROM_HERE, | |
| 90 base::Bind(SSLManager::OnAuthDialog, render_process_id, render_frame_id, | |
| 91 serialized_security_info, is_main_frame)); | |
| 92 return; | |
| 93 } | |
| 94 RenderFrameHost* render_frame_host = | |
| 95 RenderFrameHostImpl::FromID(render_process_id, render_frame_id); | |
| 96 WebContents* web_contents = | |
| 97 WebContents::FromRenderFrameHost(render_frame_host); | |
| 98 if (!web_contents) | |
| 99 return; | |
| 100 NavigationControllerImpl* controller = | |
| 101 static_cast<NavigationControllerImpl*>(&web_contents->GetController()); | |
| 102 NavigationEntryImpl* entry = controller->GetPendingEntry(); | |
|
Charlie Reis
2015/03/18 17:46:38
If you've just done a PostTask to get here, then t
palmer
2015/09/29 00:03:33
Added a comment on the other CL.
| |
| 103 controller->ssl_manager()->UpdateEntry(serialized_security_info, | |
| 104 is_main_frame, entry); | |
| 105 } | |
| 106 | |
| 107 // static | |
| 82 void SSLManager::NotifySSLInternalStateChanged(BrowserContext* context) { | 108 void SSLManager::NotifySSLInternalStateChanged(BrowserContext* context) { |
| 83 SSLManagerSet* managers = static_cast<SSLManagerSet*>( | 109 SSLManagerSet* managers = static_cast<SSLManagerSet*>( |
| 84 context->GetUserData(kSSLManagerKeyName)); | 110 context->GetUserData(kSSLManagerKeyName)); |
| 85 | 111 |
| 86 for (std::set<SSLManager*>::iterator i = managers->get().begin(); | 112 for (std::set<SSLManager*>::iterator i = managers->get().begin(); |
| 87 i != managers->get().end(); ++i) { | 113 i != managers->get().end(); ++i) { |
| 88 (*i)->UpdateEntry((*i)->controller()->GetLastCommittedEntry()); | 114 (*i)->UpdateEntry((*i)->controller()->GetLastCommittedEntry()); |
| 89 } | 115 } |
| 90 } | 116 } |
| 91 | 117 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 105 } | 131 } |
| 106 | 132 |
| 107 SSLManager::~SSLManager() { | 133 SSLManager::~SSLManager() { |
| 108 SSLManagerSet* managers = static_cast<SSLManagerSet*>( | 134 SSLManagerSet* managers = static_cast<SSLManagerSet*>( |
| 109 controller_->GetBrowserContext()->GetUserData(kSSLManagerKeyName)); | 135 controller_->GetBrowserContext()->GetUserData(kSSLManagerKeyName)); |
| 110 managers->get().erase(this); | 136 managers->get().erase(this); |
| 111 } | 137 } |
| 112 | 138 |
| 113 void SSLManager::DidCommitProvisionalLoad(const LoadCommittedDetails& details) { | 139 void SSLManager::DidCommitProvisionalLoad(const LoadCommittedDetails& details) { |
| 114 NavigationEntryImpl* entry = controller_->GetLastCommittedEntry(); | 140 NavigationEntryImpl* entry = controller_->GetLastCommittedEntry(); |
| 141 UpdateEntry(details.serialized_security_info, details.is_main_frame, entry); | |
| 142 } | |
| 115 | 143 |
| 116 if (details.is_main_frame) { | 144 void SSLManager::UpdateEntry(const std::string& serialized_security_info, |
| 117 if (entry) { | 145 bool is_main_frame, |
| 118 // Decode the security details. | 146 NavigationEntryImpl* entry) { |
| 119 int ssl_cert_id; | 147 if (is_main_frame && entry) { |
| 120 net::CertStatus ssl_cert_status; | 148 // Decode the security details. |
| 121 int ssl_security_bits; | 149 int ssl_cert_id; |
| 122 int ssl_connection_status; | 150 net::CertStatus ssl_cert_status; |
| 123 SignedCertificateTimestampIDStatusList | 151 int ssl_security_bits; |
| 124 ssl_signed_certificate_timestamp_ids; | 152 int ssl_connection_status; |
| 125 DeserializeSecurityInfo(details.serialized_security_info, | 153 SignedCertificateTimestampIDStatusList ssl_signed_certificate_timestamp_ids; |
| 126 &ssl_cert_id, | 154 DeserializeSecurityInfo(serialized_security_info, &ssl_cert_id, |
| 127 &ssl_cert_status, | 155 &ssl_cert_status, &ssl_security_bits, |
| 128 &ssl_security_bits, | 156 &ssl_connection_status, |
| 129 &ssl_connection_status, | 157 &ssl_signed_certificate_timestamp_ids); |
| 130 &ssl_signed_certificate_timestamp_ids); | |
| 131 | 158 |
| 132 // We may not have an entry if this is a navigation to an initial blank | 159 // 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. | 160 // page. Reset the SSL information and add the new data we have. |
| 134 entry->GetSSL() = SSLStatus(); | 161 entry->GetSSL() = SSLStatus(); |
| 135 entry->GetSSL().cert_id = ssl_cert_id; | 162 entry->GetSSL().cert_id = ssl_cert_id; |
| 136 entry->GetSSL().cert_status = ssl_cert_status; | 163 entry->GetSSL().cert_status = ssl_cert_status; |
| 137 entry->GetSSL().security_bits = ssl_security_bits; | 164 entry->GetSSL().security_bits = ssl_security_bits; |
| 138 entry->GetSSL().connection_status = ssl_connection_status; | 165 entry->GetSSL().connection_status = ssl_connection_status; |
| 139 entry->GetSSL().signed_certificate_timestamp_ids = | 166 entry->GetSSL().signed_certificate_timestamp_ids = |
| 140 ssl_signed_certificate_timestamp_ids; | 167 ssl_signed_certificate_timestamp_ids; |
| 141 } | |
| 142 } | 168 } |
| 143 | 169 |
| 144 UpdateEntry(entry); | 170 UpdateEntry(entry); |
| 145 } | 171 } |
| 146 | 172 |
| 147 void SSLManager::DidDisplayInsecureContent() { | 173 void SSLManager::DidDisplayInsecureContent() { |
| 148 UpdateEntry(controller_->GetLastCommittedEntry()); | 174 UpdateEntry(controller_->GetLastCommittedEntry()); |
| 149 } | 175 } |
| 150 | 176 |
| 151 void SSLManager::DidRunInsecureContent(const std::string& security_origin) { | 177 void SSLManager::DidRunInsecureContent(const std::string& security_origin) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 | 232 |
| 207 WebContentsImpl* contents = | 233 WebContentsImpl* contents = |
| 208 static_cast<WebContentsImpl*>(controller_->delegate()->GetWebContents()); | 234 static_cast<WebContentsImpl*>(controller_->delegate()->GetWebContents()); |
| 209 policy()->UpdateEntry(entry, contents); | 235 policy()->UpdateEntry(entry, contents); |
| 210 | 236 |
| 211 if (!entry->GetSSL().Equals(original_ssl_status)) | 237 if (!entry->GetSSL().Equals(original_ssl_status)) |
| 212 contents->DidChangeVisibleSSLState(); | 238 contents->DidChangeVisibleSSLState(); |
| 213 } | 239 } |
| 214 | 240 |
| 215 } // namespace content | 241 } // namespace content |
| OLD | NEW |