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

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

Issue 1530393003: WIP: Move 'X-Frame-Options' checking to the browser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years 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 b8599832965dd138885181db5bda485bc76a0bbb..889dd6c42660f472785c1b60a0d4c3c9287c7c9f 100644
--- a/content/browser/frame_host/navigation_handle_impl.cc
+++ b/content/browser/frame_host/navigation_handle_impl.cc
@@ -275,6 +275,27 @@ void NavigationHandleImpl::WillRedirectRequest(
RunCompleteCallback(result);
}
+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;
+
+ NavigationThrottle::ThrottleCheckResult result = CheckWillProcessResponse();
+
+ if (result != NavigationThrottle::PROCEED) {
+ DCHECK(result == NavigationThrottle::CANCEL ||
+ result == NavigationThrottle::CANCEL_AND_IGNORE);
+ complete_callback_ = callback;
+ RunCompleteCallback(result);
+ } else {
+ ReadyToCommitNavigation(render_frame_host, response_headers);
+ }
+}
+
void NavigationHandleImpl::ReadyToCommitNavigation(
RenderFrameHostImpl* render_frame_host,
scoped_refptr<net::HttpResponseHeaders> response_headers) {
@@ -364,6 +385,31 @@ 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::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);

Powered by Google App Engine
This is Rietveld 408576698