Chromium Code Reviews| Index: content/browser/loader/resource_loader.cc |
| diff --git a/content/browser/loader/resource_loader.cc b/content/browser/loader/resource_loader.cc |
| index 0becbf42a3d19ea4ad7804f2163b5279d5937106..936a43be0d81c5b6ab5bcc23a223ca8aa05e9109 100644 |
| --- a/content/browser/loader/resource_loader.cc |
| +++ b/content/browser/loader/resource_loader.cc |
| @@ -63,6 +63,46 @@ void PopulateResourceResponse(net::URLRequest* request, |
| request->GetLoadTimingInfo(&response->head.load_timing); |
| } |
| +// Stores the SignedCertificateTimestamps held in |sct_list| in the |
| +// SignedCertificateTimestampStore singleton, associated with |process_id|. |
| +// On return, |sct_ids| contains the assigned ID and verification status of |
| +// each SignedCertificateTimestamp. |
| +void StoreSignedCertificateTimestamps( |
| + const net::SignedCertificateTimestampAndStatusList& sct_list, |
| + int process_id, |
| + SignedCertificateTimestampIDStatusList* sct_ids) { |
| + SignedCertificateTimestampStore* sct_store( |
| + SignedCertificateTimestampStore::GetInstance()); |
| + |
| + for (net::SignedCertificateTimestampAndStatusList::const_iterator iter = |
| + sct_list.begin(); iter != sct_list.end(); ++iter) { |
| + const int sct_id(sct_store->Store(iter->sct, process_id)); |
| + sct_ids->push_back( |
| + SignedCertificateTimestampIDAndStatus(sct_id, iter->status)); |
| + } |
| +} |
| + |
| +std::string StoreAndSerializeSecurityInfo( |
| + const net::SSLInfo& ssl_info, |
| + int process_id) { |
| + DCHECK(ssl_info.cert.get()); |
| + int cert_id = CertStore::GetInstance()->StoreCert( |
| + ssl_info.cert.get(), process_id); |
| + |
| + SignedCertificateTimestampIDStatusList signed_certificate_timestamp_ids; |
| + StoreSignedCertificateTimestamps( |
| + ssl_info.signed_certificate_timestamps, |
| + process_id, |
| + &signed_certificate_timestamp_ids); |
| + |
| + return SerializeSecurityInfo( |
| + cert_id, |
| + ssl_info.cert_status, |
| + ssl_info.security_bits, |
| + ssl_info.connection_status, |
| + signed_certificate_timestamp_ids); |
| +} |
| + |
| } // namespace |
| ResourceLoader::ResourceLoader(scoped_ptr<net::URLRequest> request, |
| @@ -239,9 +279,28 @@ void ResourceLoader::OnAuthRequired(net::URLRequest* unused, |
| return; |
| } |
| + // Update the SSL state before showing the auth prompt. |
| + const net::SSLInfo& ssl_info = request_->response_info().ssl_info; |
| + if (ssl_info.cert.get()) { |
| + bool is_main_frame = (request_->load_flags() & net::LOAD_MAIN_FRAME) != 0; |
| + ResourceRequestInfoImpl* info = GetRequestInfo(); |
| + int render_process_id; |
| + int render_frame_id; |
| + if (!info->GetAssociatedRenderFrame(&render_process_id, &render_frame_id)) |
| + NOTREACHED(); |
| + std::string security_info = |
| + StoreAndSerializeSecurityInfo(ssl_info, info->GetChildID()); |
| + SSLManager::OnAuthDialog( |
| + render_process_id, render_frame_id, security_info, is_main_frame); |
| + } else { |
| + // We should not have any SSL state. |
|
nasko
2014/07/24 09:32:34
nit: indent 2 more spaces
meacer
2014/07/24 17:32:32
Done.
|
| + DCHECK(!ssl_info.cert_status && |
| + ssl_info.security_bits == -1 && |
| + !ssl_info.connection_status); |
| + } |
| + |
| // Create a login dialog on the UI thread to get authentication data, or pull |
| // from cache and continue on the IO thread. |
| - |
| DCHECK(!login_delegate_.get()) |
| << "OnAuthRequired called with login_delegate pending"; |
| login_delegate_ = delegate_->CreateLoginDelegate(this, auth_info); |
| @@ -501,21 +560,6 @@ void ResourceLoader::CancelRequestInternal(int error, bool from_renderer) { |
| } |
| } |
| -void ResourceLoader::StoreSignedCertificateTimestamps( |
| - const net::SignedCertificateTimestampAndStatusList& sct_list, |
| - int process_id, |
| - SignedCertificateTimestampIDStatusList* sct_ids) { |
| - SignedCertificateTimestampStore* sct_store( |
| - SignedCertificateTimestampStore::GetInstance()); |
| - |
| - for (net::SignedCertificateTimestampAndStatusList::const_iterator iter = |
| - sct_list.begin(); iter != sct_list.end(); ++iter) { |
| - const int sct_id(sct_store->Store(iter->sct, process_id)); |
| - sct_ids->push_back( |
| - SignedCertificateTimestampIDAndStatus(sct_id, iter->status)); |
| - } |
| -} |
| - |
| void ResourceLoader::CompleteResponseStarted() { |
| ResourceRequestInfoImpl* info = GetRequestInfo(); |
| @@ -523,21 +567,8 @@ void ResourceLoader::CompleteResponseStarted() { |
| PopulateResourceResponse(request_.get(), response.get()); |
| if (request_->ssl_info().cert.get()) { |
| - int cert_id = CertStore::GetInstance()->StoreCert( |
| - request_->ssl_info().cert.get(), info->GetChildID()); |
| - |
| - SignedCertificateTimestampIDStatusList signed_certificate_timestamp_ids; |
| - StoreSignedCertificateTimestamps( |
| - request_->ssl_info().signed_certificate_timestamps, |
| - info->GetChildID(), |
| - &signed_certificate_timestamp_ids); |
| - |
| - response->head.security_info = SerializeSecurityInfo( |
| - cert_id, |
| - request_->ssl_info().cert_status, |
| - request_->ssl_info().security_bits, |
| - request_->ssl_info().connection_status, |
| - signed_certificate_timestamp_ids); |
| + response->head.security_info = |
| + StoreAndSerializeSecurityInfo(request_->ssl_info(), info->GetChildID()); |
| } else { |
| // We should not have any SSL state. |
| DCHECK(!request_->ssl_info().cert_status && |
| @@ -640,18 +671,8 @@ void ResourceLoader::ResponseCompleted() { |
| std::string security_info; |
| const net::SSLInfo& ssl_info = request_->ssl_info(); |
| - if (ssl_info.cert.get() != NULL) { |
| - int cert_id = CertStore::GetInstance()->StoreCert(ssl_info.cert.get(), |
| - info->GetChildID()); |
| - SignedCertificateTimestampIDStatusList signed_certificate_timestamp_ids; |
| - StoreSignedCertificateTimestamps(ssl_info.signed_certificate_timestamps, |
| - info->GetChildID(), |
| - &signed_certificate_timestamp_ids); |
| - |
| - security_info = SerializeSecurityInfo( |
| - cert_id, ssl_info.cert_status, ssl_info.security_bits, |
| - ssl_info.connection_status, signed_certificate_timestamp_ids); |
| - } |
| + if (ssl_info.cert.get() != NULL) |
| + security_info = StoreAndSerializeSecurityInfo(ssl_info, info->GetChildID()); |
| bool defer = false; |
| handler_->OnResponseCompleted(request_->status(), security_info, &defer); |