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

Unified Diff: content/browser/loader/navigation_resource_throttle.cc

Issue 2867833002: NavigationThrottle: allow customization of net::Error when blocking
Patch Set: Rebase Created 3 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
« no previous file with comments | « content/browser/frame_host/navigation_request.cc ('k') | content/public/browser/navigation_handle.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/loader/navigation_resource_throttle.cc
diff --git a/content/browser/loader/navigation_resource_throttle.cc b/content/browser/loader/navigation_resource_throttle.cc
index b8787626e829a86be9c43a5583d41c5bfe093eab..cde679c5f4a3b7dc7930d6954cf82676059012a1 100644
--- a/content/browser/loader/navigation_resource_throttle.cc
+++ b/content/browser/loader/navigation_resource_throttle.cc
@@ -48,7 +48,7 @@ typedef base::Callback<void(NavigationThrottle::ThrottleCheckResult)>
void SendCheckResultToIOThread(UIChecksPerformedCallback callback,
NavigationThrottle::ThrottleCheckResult result) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- DCHECK_NE(result, NavigationThrottle::DEFER);
+ DCHECK_NE(result.action(), NavigationThrottle::DEFER);
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::Bind(callback, result));
}
@@ -344,19 +344,23 @@ void NavigationResourceThrottle::set_force_transfer_for_testing(
void NavigationResourceThrottle::OnUIChecksPerformed(
NavigationThrottle::ThrottleCheckResult result) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- DCHECK_NE(NavigationThrottle::DEFER, result);
+ DCHECK_NE(NavigationThrottle::DEFER, result.action());
if (in_cross_site_transition_) {
on_transfer_done_result_ = result;
return;
}
- if (result == NavigationThrottle::CANCEL_AND_IGNORE) {
+ if (result.action() == NavigationThrottle::CANCEL_AND_IGNORE) {
+ DCHECK_EQ(net::ERR_ABORTED, result.net_error_code());
CancelAndIgnore();
- } else if (result == NavigationThrottle::CANCEL) {
+ } else if (result.action() == NavigationThrottle::CANCEL) {
+ DCHECK_EQ(net::ERR_ABORTED, result.net_error_code());
Cancel();
- } else if (result == NavigationThrottle::BLOCK_REQUEST) {
- CancelWithError(net::ERR_BLOCKED_BY_CLIENT);
- } else if (result == NavigationThrottle::BLOCK_RESPONSE) {
+ } else if (result.action() == NavigationThrottle::BLOCK_REQUEST) {
+ DCHECK_NE(net::OK, result.net_error_code());
+ CancelWithError(result.net_error_code());
+ } else if (result.action() == NavigationThrottle::BLOCK_RESPONSE) {
+ DCHECK_NE(net::OK, result.net_error_code());
// TODO(mkwst): If we cancel the main frame request with anything other than
// 'net::ERR_ABORTED', we'll trigger some special behavior that might not be
// desirable here (non-POSTs will reload the page, while POST has some logic
@@ -365,7 +369,7 @@ void NavigationResourceThrottle::OnUIChecksPerformed(
// block main frame navigations in the future, we'll need to carefully
// consider the right thing to do here.
DCHECK(!ResourceRequestInfo::ForRequest(request_)->IsMainFrame());
- CancelWithError(net::ERR_BLOCKED_BY_RESPONSE);
+ CancelWithError(result.net_error_code());
} else {
Resume();
}
@@ -389,7 +393,7 @@ void NavigationResourceThrottle::OnTransferComplete() {
// If the results of the checks on the UI thread are known, unblock the
// navigation. Otherwise, wait until the callback has executed.
- if (on_transfer_done_result_ != NavigationThrottle::DEFER) {
+ if (on_transfer_done_result_.action() != NavigationThrottle::DEFER) {
OnUIChecksPerformed(on_transfer_done_result_);
on_transfer_done_result_ = NavigationThrottle::DEFER;
}
« no previous file with comments | « content/browser/frame_host/navigation_request.cc ('k') | content/public/browser/navigation_handle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698