| Index: content/browser/frame_host/navigation_handle_impl.cc
|
| diff --git a/content/browser/frame_host/navigation_handle_impl.cc b/content/browser/frame_host/navigation_handle_impl.cc
|
| index 743d2ead8e6d5ef85eb18bf6f1012a3839890b4d..87000a577569a6116350739b6afd815a06802140 100644
|
| --- a/content/browser/frame_host/navigation_handle_impl.cc
|
| +++ b/content/browser/frame_host/navigation_handle_impl.cc
|
| @@ -9,6 +9,7 @@
|
| #include "content/browser/frame_host/frame_tree_node.h"
|
| #include "content/browser/frame_host/navigator.h"
|
| #include "content/browser/frame_host/navigator_delegate.h"
|
| +#include "content/browser/frame_host/xfo_throttle.h"
|
| #include "content/browser/service_worker/service_worker_context_wrapper.h"
|
| #include "content/browser/service_worker/service_worker_navigation_handle.h"
|
| #include "content/public/browser/content_browser_client.h"
|
| @@ -231,10 +232,15 @@ void NavigationHandleImpl::WillStartRequest(
|
| state_ = WILL_SEND_REQUEST;
|
| complete_callback_ = callback;
|
|
|
| - // Register the navigation throttles. The ScopedVector returned by
|
| - // GetNavigationThrottles is not assigned to throttles_ directly because it
|
| - // would overwrite any throttle previously added with
|
| - // RegisterThrottleForTesting.
|
| + // Register the platform's navigation throttles.
|
| + //
|
| + // TODO(mkwst): Add support for CSP's 'frame-ancestors'.
|
| + if (scoped_ptr<content::NavigationThrottle> xfo_throttle =
|
| + XFOThrottle::MaybeCreateThrottleFor(this)) {
|
| + throttles_.push_back(std::move(xfo_throttle));
|
| + }
|
| +
|
| + // Register the embedder's navigation throttles.
|
| ScopedVector<NavigationThrottle> throttles_to_register =
|
| GetContentClient()->browser()->CreateThrottlesForNavigation(this);
|
| if (throttles_to_register.size() > 0) {
|
| @@ -282,6 +288,24 @@ void NavigationHandleImpl::DidRedirectNavigation(const GURL& new_url) {
|
| GetDelegate()->DidRedirectNavigation(this);
|
| }
|
|
|
| +void NavigationHandleImpl::WillProcessResponse(
|
| + RenderFrameHostImpl* render_frame_host,
|
| + scoped_refptr<net::HttpResponseHeaders> response_headers,
|
| + const ThrottleChecksFinishedCallback& callback) {
|
| + DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host);
|
| + render_frame_host_ = render_frame_host;
|
| + response_headers_ = response_headers;
|
| + state_ = READY_TO_COMMIT;
|
| + complete_callback_ = callback;
|
| +
|
| + NavigationThrottle::ThrottleCheckResult result = CheckWillProcessResponse();
|
| + DCHECK(result != NavigationThrottle::DEFER);
|
| + if (result == NavigationThrottle::PROCEED)
|
| + ReadyToCommitNavigation(render_frame_host, response_headers);
|
| +
|
| + RunCompleteCallback(result);
|
| +}
|
| +
|
| void NavigationHandleImpl::ReadyToCommitNavigation(
|
| RenderFrameHostImpl* render_frame_host,
|
| scoped_refptr<net::HttpResponseHeaders> response_headers) {
|
| @@ -317,6 +341,7 @@ NavigationHandleImpl::CheckWillStartRequest() {
|
| case NavigationThrottle::PROCEED:
|
| continue;
|
|
|
| + case NavigationThrottle::BLOCK:
|
| case NavigationThrottle::CANCEL:
|
| case NavigationThrottle::CANCEL_AND_IGNORE:
|
| state_ = CANCELING;
|
| @@ -348,6 +373,7 @@ NavigationHandleImpl::CheckWillRedirectRequest() {
|
| case NavigationThrottle::PROCEED:
|
| continue;
|
|
|
| + case NavigationThrottle::BLOCK:
|
| case NavigationThrottle::CANCEL:
|
| case NavigationThrottle::CANCEL_AND_IGNORE:
|
| state_ = CANCELING;
|
| @@ -367,6 +393,32 @@ NavigationHandleImpl::CheckWillRedirectRequest() {
|
| return NavigationThrottle::PROCEED;
|
| }
|
|
|
| +NavigationThrottle::ThrottleCheckResult
|
| +NavigationHandleImpl::CheckWillProcessResponse() {
|
| + DCHECK(state_ == READY_TO_COMMIT);
|
| + for (size_t i = next_index_; i < throttles_.size(); ++i) {
|
| + NavigationThrottle::ThrottleCheckResult result =
|
| + throttles_[i]->WillProcessResponse();
|
| + switch (result) {
|
| + case NavigationThrottle::PROCEED:
|
| + continue;
|
| +
|
| + case NavigationThrottle::BLOCK:
|
| + case NavigationThrottle::CANCEL:
|
| + case NavigationThrottle::CANCEL_AND_IGNORE:
|
| + state_ = CANCELING;
|
| + return result;
|
| +
|
| + case NavigationThrottle::DEFER:
|
| + default:
|
| + NOTREACHED();
|
| + }
|
| + }
|
| + next_index_ = 0;
|
| + state_ = READY_TO_COMMIT;
|
| + return NavigationThrottle::PROCEED;
|
| +}
|
| +
|
| void NavigationHandleImpl::RunCompleteCallback(
|
| NavigationThrottle::ThrottleCheckResult result) {
|
| DCHECK(result != NavigationThrottle::DEFER);
|
|
|