Chromium Code Reviews| Index: content/browser/ssl/ssl_manager.cc | 
| diff --git a/content/browser/ssl/ssl_manager.cc b/content/browser/ssl/ssl_manager.cc | 
| index e4c71e3dc4e0f8b2c520afe4cb9d9979d51140d9..ba1a73d59015b17bdf634aaa18cc06796020ef42 100644 | 
| --- a/content/browser/ssl/ssl_manager.cc | 
| +++ b/content/browser/ssl/ssl_manager.cc | 
| @@ -21,6 +21,7 @@ | 
| #include "content/public/browser/browser_thread.h" | 
| #include "content/public/browser/load_from_memory_cache_details.h" | 
| #include "content/public/browser/navigation_details.h" | 
| +#include "content/public/browser/navigation_entry.h" | 
| #include "content/public/browser/resource_request_details.h" | 
| #include "content/public/common/ssl_status.h" | 
| #include "net/url_request/url_request.h" | 
| @@ -79,6 +80,39 @@ void SSLManager::OnSSLCertificateError( | 
| } | 
| // static | 
| +void SSLManager::OnAuthDialog(int render_process_id, | 
| + int render_frame_id, | 
| + const SSLStatus& ssl_status, | 
| + bool is_main_frame) { | 
| + BrowserThread::PostTask( | 
| + BrowserThread::UI, FROM_HERE, | 
| + base::Bind(SSLManager::OnAuthDialogOnUI, render_process_id, | 
| + render_frame_id, ssl_status, is_main_frame)); | 
| +} | 
| + | 
| +// static | 
| +void SSLManager::OnAuthDialogOnUI(int render_process_id, | 
| + int render_frame_id, | 
| + const SSLStatus& ssl_status, | 
| + bool is_main_frame) { | 
| + DCHECK_CURRENTLY_ON(BrowserThread::UI); | 
| + RenderFrameHost* render_frame_host = | 
| + RenderFrameHostImpl::FromID(render_process_id, render_frame_id); | 
| + WebContents* web_contents = | 
| + WebContents::FromRenderFrameHost(render_frame_host); | 
| + if (!web_contents) | 
| + return; | 
| + NavigationControllerImpl* controller = | 
| + static_cast<NavigationControllerImpl*>(&web_contents->GetController()); | 
| + // TODO(palmer, creis, meacer): If you've just done a PostTask to get here, | 
| + // then there's no guarantee that the pending entry still exists or is for the | 
| + // same navigation. (It may have been discarded or replaced with a different | 
| + // one in the meantime.) Ensure this is safe. | 
| 
 
Charlie Reis
2015/09/29 22:52:11
Same concerns.  I don't know how to make this safe
 
 | 
| + NavigationEntryImpl* entry = controller->GetPendingEntry(); | 
| + controller->ssl_manager()->UpdateEntry(ssl_status, is_main_frame, entry); | 
| +} | 
| + | 
| +// static | 
| void SSLManager::NotifySSLInternalStateChanged(BrowserContext* context) { | 
| SSLManagerSet* managers = static_cast<SSLManagerSet*>( | 
| context->GetUserData(kSSLManagerKeyName)); | 
| @@ -112,13 +146,27 @@ SSLManager::~SSLManager() { | 
| void SSLManager::DidCommitProvisionalLoad(const LoadCommittedDetails& details) { | 
| NavigationEntryImpl* entry = controller_->GetLastCommittedEntry(); | 
| + UpdateEntry(details.ssl_status, details.is_main_frame, entry); | 
| +} | 
| - if (details.is_main_frame) { | 
| - if (entry) { | 
| - // We may not have an entry if this is a navigation to an initial blank | 
| - // page. Add the new data we have. | 
| - entry->GetSSL() = details.ssl_status; | 
| - } | 
| +void SSLManager::UpdateEntry(const SSLStatus& ssl_status, | 
| + bool is_main_frame, | 
| + NavigationEntryImpl* entry) { | 
| + if (!entry) | 
| + return; | 
| + if (is_main_frame) { | 
| + // We may not have an entry if this is a navigation to an initial blank | 
| + // page. Reset the SSL information and add the new data we have. | 
| + entry->GetSSL() = SSLStatus(); | 
| + entry->GetSSL().security_style = ssl_status.security_style; | 
| + entry->GetSSL().cert_id = ssl_status.cert_id; | 
| + entry->GetSSL().cert_status = ssl_status.cert_status; | 
| + entry->GetSSL().security_bits = ssl_status.security_bits; | 
| + entry->GetSSL().key_exchange_info = ssl_status.key_exchange_info; | 
| + entry->GetSSL().connection_status = ssl_status.connection_status; | 
| + entry->GetSSL().content_status = ssl_status.content_status; | 
| + entry->GetSSL().signed_certificate_timestamp_ids = | 
| + ssl_status.signed_certificate_timestamp_ids; | 
| } | 
| policy()->UpdateEntry(entry, controller_->delegate()->GetWebContents()); |