Index: content/browser/frame_host/navigation_request.cc |
diff --git a/content/browser/frame_host/navigation_request.cc b/content/browser/frame_host/navigation_request.cc |
index df0f7a1e7b7128331b36debd5882b31dd4f37bd5..606b441255fbaf4324aa673cd3d74998b0c048af 100644 |
--- a/content/browser/frame_host/navigation_request.cc |
+++ b/content/browser/frame_host/navigation_request.cc |
@@ -259,8 +259,10 @@ void NavigationRequest::OnRequestRedirected( |
void NavigationRequest::OnResponseStarted( |
const scoped_refptr<ResourceResponse>& response, |
scoped_ptr<StreamHandle> body) { |
- DCHECK(state_ == STARTED); |
+ DCHECK(state_ == STARTED && !response_ && !body_); |
state_ = RESPONSE_STARTED; |
+ response_ = response.get(); |
+ body_ = std::move(body); |
// Update the service worker params of the request params. |
request_params_.should_create_service_worker = |
@@ -272,8 +274,10 @@ void NavigationRequest::OnResponseStarted( |
->service_worker_provider_host_id(); |
} |
- frame_tree_node_->navigator()->CommitNavigation( |
- frame_tree_node_, response.get(), std::move(body)); |
+ navigation_handle_->WillProcessResponse( |
+ frame_tree_node_->current_frame_host(), response->head.headers, |
+ base::Bind(&NavigationRequest::OnResponseChecksComplete, |
+ base::Unretained(this))); |
} |
void NavigationRequest::OnRequestFailed(bool has_stale_copy_in_cache, |
@@ -302,7 +306,8 @@ void NavigationRequest::OnStartChecksComplete( |
// Abort the request if needed. This will destroy the NavigationRequest. |
if (result == NavigationThrottle::CANCEL_AND_IGNORE || |
- result == NavigationThrottle::CANCEL) { |
+ result == NavigationThrottle::CANCEL || |
+ result == NavigationThrottle::BLOCK) { |
// TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. |
frame_tree_node_->ResetNavigationRequest(false); |
return; |
@@ -320,7 +325,8 @@ void NavigationRequest::OnRedirectChecksComplete( |
// Abort the request if needed. This will destroy the NavigationRequest. |
if (result == NavigationThrottle::CANCEL_AND_IGNORE || |
- result == NavigationThrottle::CANCEL) { |
+ result == NavigationThrottle::CANCEL || |
+ result == NavigationThrottle::BLOCK) { |
// TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. |
frame_tree_node_->ResetNavigationRequest(false); |
return; |
@@ -330,6 +336,23 @@ void NavigationRequest::OnRedirectChecksComplete( |
navigation_handle_->DidRedirectNavigation(common_params_.url); |
} |
+void NavigationRequest::OnResponseChecksComplete( |
+ NavigationThrottle::ThrottleCheckResult result) { |
+ CHECK(result != NavigationThrottle::DEFER); |
+ |
+ // Abort the request if needed. This will destroy the NavigationRequest. |
+ if (result == NavigationThrottle::CANCEL_AND_IGNORE || |
+ result == NavigationThrottle::CANCEL || |
+ result == NavigationThrottle::BLOCK) { |
+ // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. |
nasko
2016/01/20 23:15:07
Do we need to distinguish BLOCK as well?
|
+ frame_tree_node_->ResetNavigationRequest(false); |
+ return; |
+ } |
+ |
+ frame_tree_node_->navigator()->CommitNavigation( |
+ frame_tree_node_, response_.get(), std::move(body_)); |
+} |
+ |
void NavigationRequest::InitializeServiceWorkerHandleIfNeeded() { |
// Only initialize the ServiceWorkerNavigationHandle if it can be created for |
// this frame. |