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

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: 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 8904071971d98abe681d66e45323855444bb4f87..95ae0ff5bcd3b5855c8025ee114b5e8c204d4423 100644
--- a/content/browser/frame_host/navigation_handle_impl.cc
+++ b/content/browser/frame_host/navigation_handle_impl.cc
@@ -280,6 +280,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);
Mike West 2015/12/17 13:09:15 This feels a bit hacky. I'd appreciate suggestions
+ }
+}
+
void NavigationHandleImpl::DidRedirectNavigation(const GURL& new_url) {
url_ = new_url;
GetDelegate()->DidRedirectNavigation(this);
@@ -372,6 +393,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