Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Unified Diff: content/browser/frame_host/navigation_handle_impl.cc

Issue 1617043002: Introduce AncestorThrottle, which will process 'X-Frame-Options' headers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@block-response
Patch Set: DCHECK. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 0bdcce93ae786251d10410fbd256c138cdf676d8..98d559b0947123679adc64ef770eb75344d7d895 100644
--- a/content/browser/frame_host/navigation_handle_impl.cc
+++ b/content/browser/frame_host/navigation_handle_impl.cc
@@ -6,6 +6,7 @@
#include <utility>
+#include "content/browser/frame_host/ancestor_throttle.h"
#include "content/browser/frame_host/frame_tree_node.h"
#include "content/browser/frame_host/navigator.h"
#include "content/browser/frame_host/navigator_delegate.h"
@@ -171,9 +172,9 @@ net::Error NavigationHandleImpl::GetNetErrorCode() {
}
RenderFrameHostImpl* NavigationHandleImpl::GetRenderFrameHost() {
- CHECK(state_ >= READY_TO_COMMIT)
+ CHECK_GE(state_, WILL_PROCESS_RESPONSE)
<< "This accessor should only be called "
- "after the navigation is ready to commit.";
+ "after a response has been received.";
return render_frame_host_;
}
@@ -292,10 +293,13 @@ 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.
+ std::unique_ptr<content::NavigationThrottle> ancestor_throttle =
+ content::AncestorThrottle::MaybeCreateThrottleFor(this);
+ if (ancestor_throttle)
+ throttles_.push_back(std::move(ancestor_throttle));
+
+ // Register the embedder's navigation throttles.
ScopedVector<NavigationThrottle> throttles_to_register =
GetContentClient()->browser()->CreateThrottlesForNavigation(this);
if (throttles_to_register.size() > 0) {
@@ -412,7 +416,7 @@ NavigationHandleImpl::CheckWillStartRequest() {
next_index_ = i + 1;
return result;
- default:
+ case NavigationThrottle::BLOCK_RESPONSE:
NOTREACHED();
}
}
@@ -443,7 +447,7 @@ NavigationHandleImpl::CheckWillRedirectRequest() {
next_index_ = i + 1;
return result;
- default:
+ case NavigationThrottle::BLOCK_RESPONSE:
NOTREACHED();
}
}
@@ -469,6 +473,7 @@ NavigationHandleImpl::CheckWillProcessResponse() {
case NavigationThrottle::PROCEED:
continue;
+ case NavigationThrottle::BLOCK_RESPONSE:
case NavigationThrottle::CANCEL:
case NavigationThrottle::CANCEL_AND_IGNORE:
state_ = CANCELING;

Powered by Google App Engine
This is Rietveld 408576698