Chromium Code Reviews| Index: content/browser/loader/cross_site_resource_handler.cc | 
| diff --git a/content/browser/loader/cross_site_resource_handler.cc b/content/browser/loader/cross_site_resource_handler.cc | 
| index 3e88d3395f36e831dcdafe54d1a85af0edaa9c7f..f344a06f3d64808c2641248c1ee67cfb19781ab7 100644 | 
| --- a/content/browser/loader/cross_site_resource_handler.cc | 
| +++ b/content/browser/loader/cross_site_resource_handler.cc | 
| @@ -16,6 +16,7 @@ | 
| #include "content/browser/frame_host/render_frame_host_impl.h" | 
| #include "content/browser/loader/resource_dispatcher_host_impl.h" | 
| #include "content/browser/loader/resource_request_info_impl.h" | 
| +#include "content/browser/transition_request_manager.h" | 
| #include "content/public/browser/browser_thread.h" | 
| #include "content/public/browser/content_browser_client.h" | 
| #include "content/public/browser/global_request_id.h" | 
| @@ -84,6 +85,17 @@ void OnCrossSiteResponseHelper(const CrossSiteResponseParams& params) { | 
| } | 
| } | 
| +void OnDeferredAfterResponseStartedHelper( | 
| + const GlobalRequestID& global_request_id, int render_frame_id) { | 
| 
 
nasko
2014/05/28 22:59:00
style: parameters need to be on line of their own.
 
shatch
2014/05/29 21:41:22
Done.
 
 | 
| + | 
| + RenderFrameHostImpl* rfh = | 
| + RenderFrameHostImpl::FromID(global_request_id.child_id, | 
| + render_frame_id); | 
| + if (rfh) { | 
| 
 
nasko
2014/05/28 22:59:00
style: no need for braces here
 
shatch
2014/05/29 21:41:22
Done.
 
 | 
| + rfh->OnDeferredAfterResponseStarted(global_request_id); | 
| + } | 
| +} | 
| + | 
| bool CheckNavigationPolicyOnUI(GURL url, int process_id, int render_frame_id) { | 
| RenderFrameHostImpl* rfh = | 
| RenderFrameHostImpl::FromID(process_id, render_frame_id); | 
| @@ -136,12 +148,31 @@ bool CrossSiteResourceHandler::OnResponseStarted( | 
| int request_id, | 
| ResourceResponse* response, | 
| bool* defer) { | 
| + response_ = response; | 
| + has_started_response_ = true; | 
| + | 
| + // Store this handler on the ExtraRequestInfo, so that RDH can call our | 
| + // ResumeResponse method when we are ready to resume. | 
| + ResourceRequestInfoImpl* info = GetRequestInfo(); | 
| + info->set_cross_site_handler(this); | 
| + | 
| + bool is_navigation_transition = | 
| + TransitionRequestManager::GetInstance()->HasPendingTransitionRequest( | 
| + info->GetChildID(), info->GetRouteID()); | 
| + | 
| + if (is_navigation_transition) | 
| + return OnNavigationTransitionResponseStarted(request_id, response, defer); | 
| + else | 
| + return OnNormalResponseStarted(request_id, response, defer); | 
| +} | 
| + | 
| +bool CrossSiteResourceHandler::OnNormalResponseStarted( | 
| + int request_id, ResourceResponse* response, bool* defer) { | 
| // At this point, we know that the response is safe to send back to the | 
| // renderer: it is not a download, and it has passed the SSL and safe | 
| // browsing checks. | 
| // We should not have already started the transition before now. | 
| DCHECK(!in_cross_site_transition_); | 
| - has_started_response_ = true; | 
| ResourceRequestInfoImpl* info = GetRequestInfo(); | 
| @@ -200,6 +231,39 @@ bool CrossSiteResourceHandler::OnResponseStarted( | 
| return true; | 
| } | 
| +bool CrossSiteResourceHandler::OnNavigationTransitionResponseStarted( | 
| + int request_id, ResourceResponse* response, bool* defer) { | 
| + ResourceRequestInfoImpl* info = GetRequestInfo(); | 
| + DCHECK_EQ(request_id, info->GetRequestID()); | 
| + | 
| + request()->LogBlockedBy("CrossSiteResourceHandler"); | 
| + | 
| + DCHECK_EQ(request_id, info->GetRequestID()); | 
| + GlobalRequestID global_id(info->GetChildID(), info->GetRequestID()); | 
| + int render_frame_id = info->GetRenderFrameID(); | 
| + BrowserThread::PostTask( | 
| + BrowserThread::UI, | 
| 
 
nasko
2014/05/28 22:59:00
style: wrong indent
 
shatch
2014/05/29 21:41:22
Done.
 
 | 
| + FROM_HERE, | 
| + base::Bind( | 
| + &OnDeferredAfterResponseStartedHelper, | 
| + global_id, render_frame_id)); | 
| + | 
| + *defer = true; | 
| 
 
nasko
2014/05/28 22:59:00
Shouldn't there be a call to OnDidDefer()?
 
shatch
2014/05/29 21:41:22
Done.
 
 | 
| + return true; | 
| +} | 
| + | 
| +void CrossSiteResourceHandler::ResumeResponseDeferredAtStart( | 
| + int request_id) { | 
| + request()->LogUnblocked(); | 
| + | 
| + bool defer; | 
| + if (!OnNormalResponseStarted(request_id, response_, &defer)) { | 
| + controller()->Cancel(); | 
| + } else { | 
| + controller()->Resume(); | 
| + } | 
| +} | 
| + | 
| void CrossSiteResourceHandler::ResumeOrTransfer(bool is_transfer) { | 
| if (is_transfer) { | 
| ResourceRequestInfoImpl* info = GetRequestInfo(); |