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

Unified Diff: content/public/test/navigation_simulator.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/public/browser/navigation_throttle.cc ('k') | extensions/browser/extension_navigation_throttle.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/test/navigation_simulator.cc
diff --git a/content/public/test/navigation_simulator.cc b/content/public/test/navigation_simulator.cc
index 3530e615c36ffc798ed6ea973f01fec0eea03410..d2eb3f9b4f61e7894d727016a4cdd124172cab35 100644
--- a/content/public/test/navigation_simulator.cc
+++ b/content/public/test/navigation_simulator.cc
@@ -156,10 +156,11 @@ void NavigationSimulator::Start() {
WaitForThrottleChecksComplete();
CHECK_EQ(1, num_did_start_navigation_called_);
- if (GetLastThrottleCheckResult() == NavigationThrottle::PROCEED) {
+ NavigationThrottle::ThrottleCheckResult result = GetLastThrottleCheckResult();
+ if (result.action() == NavigationThrottle::PROCEED) {
CHECK_EQ(1, num_will_start_request_called_);
} else {
- FailFromThrottleCheck(GetLastThrottleCheckResult());
+ FailFromThrottleCheck(result);
}
}
@@ -211,14 +212,14 @@ void NavigationSimulator::Redirect(const GURL& new_url) {
}
WaitForThrottleChecksComplete();
-
- if (GetLastThrottleCheckResult() == NavigationThrottle::PROCEED) {
+ NavigationThrottle::ThrottleCheckResult result = GetLastThrottleCheckResult();
+ if (result.action() == NavigationThrottle::PROCEED) {
CHECK_EQ(previous_num_will_redirect_request_called + 1,
num_will_redirect_request_called_);
CHECK_EQ(previous_did_redirect_navigation_called + 1,
num_did_redirect_navigation_called_);
} else {
- FailFromThrottleCheck(GetLastThrottleCheckResult());
+ FailFromThrottleCheck(result);
}
}
@@ -261,8 +262,9 @@ void NavigationSimulator::Commit() {
WaitForThrottleChecksComplete();
- if (GetLastThrottleCheckResult() != NavigationThrottle::PROCEED) {
- FailFromThrottleCheck(GetLastThrottleCheckResult());
+ NavigationThrottle::ThrottleCheckResult result = GetLastThrottleCheckResult();
+ if (result.action() != NavigationThrottle::PROCEED) {
+ FailFromThrottleCheck(result);
return;
}
@@ -575,37 +577,23 @@ RenderFrameHost* NavigationSimulator::GetFinalRenderFrameHost() {
void NavigationSimulator::FailFromThrottleCheck(
NavigationThrottle::ThrottleCheckResult result) {
- DCHECK_NE(result, NavigationThrottle::PROCEED);
+ DCHECK_NE(result.action(), NavigationThrottle::PROCEED);
state_ = FAILED;
// Special failure logic only needed for non-PlzNavigate case.
if (IsBrowserSideNavigationEnabled())
return;
- int error_code = net::OK;
- switch (result) {
- case NavigationThrottle::PROCEED:
- case NavigationThrottle::DEFER:
- NOTREACHED();
- break;
- case NavigationThrottle::CANCEL:
- case NavigationThrottle::CANCEL_AND_IGNORE:
- error_code = net::ERR_ABORTED;
- break;
- case NavigationThrottle::BLOCK_REQUEST:
- error_code = net::ERR_BLOCKED_BY_CLIENT;
- break;
- case NavigationThrottle::BLOCK_RESPONSE:
- error_code = net::ERR_BLOCKED_BY_RESPONSE;
- break;
- };
+ DCHECK_NE(result.action(), NavigationThrottle::DEFER);
+ DCHECK_NE(result.net_error_code(), net::OK);
FrameHostMsg_DidFailProvisionalLoadWithError_Params error_params;
- error_params.error_code = error_code;
+ error_params.error_code = result.net_error_code();
error_params.url = navigation_url_;
render_frame_host_->OnMessageReceived(
FrameHostMsg_DidFailProvisionalLoadWithError(
render_frame_host_->GetRoutingID(), error_params));
- bool should_result_in_error_page = error_code != net::ERR_ABORTED;
+ bool should_result_in_error_page =
+ result.net_error_code() != net::ERR_ABORTED;
if (!should_result_in_error_page) {
render_frame_host_->OnMessageReceived(
FrameHostMsg_DidStopLoading(render_frame_host_->GetRoutingID()));
« no previous file with comments | « content/public/browser/navigation_throttle.cc ('k') | extensions/browser/extension_navigation_throttle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698