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

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

Issue 2696493003: Introduce SubframeNavigationFilteringThrottle (Closed)
Patch Set: fix use after stack return, make code nicer Created 3 years, 10 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 74e0b202c6f005ffc79bb32c909b01bb847c83f2..1ab5e8d2c7ececb6e41864c2f3f921fbb2703a62 100644
--- a/content/browser/frame_host/navigation_handle_impl.cc
+++ b/content/browser/frame_host/navigation_handle_impl.cc
@@ -42,12 +42,6 @@ namespace content {
namespace {
-void UpdateThrottleCheckResult(
- NavigationThrottle::ThrottleCheckResult* to_update,
- NavigationThrottle::ThrottleCheckResult result) {
- *to_update = result;
-}
-
void NotifyAbandonedTransferNavigation(const GlobalRequestID& id) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get())
@@ -354,9 +348,8 @@ NavigationHandleImpl::CallWillStartRequestForTesting(
const Referrer& sanitized_referrer,
bool has_user_gesture,
ui::PageTransition transition,
- bool is_external_protocol) {
- NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER;
-
+ bool is_external_protocol,
+ const ThrottleChecksFinishedCallback& complete_callback) {
scoped_refptr<ResourceRequestBodyImpl> resource_request_body;
std::string method = "GET";
if (is_post) {
@@ -366,16 +359,10 @@ NavigationHandleImpl::CallWillStartRequestForTesting(
resource_request_body = new ResourceRequestBodyImpl();
resource_request_body->AppendBytes(body.data(), body.size());
}
-
- WillStartRequest(method, resource_request_body, sanitized_referrer,
- has_user_gesture, transition, is_external_protocol,
- REQUEST_CONTEXT_TYPE_LOCATION,
- blink::WebMixedContentContextType::Blockable,
- base::Bind(&UpdateThrottleCheckResult, &result));
-
- // Reset the callback to ensure it will not be called later.
- complete_callback_.Reset();
- return result;
+ return WillStartRequest(
+ method, resource_request_body, sanitized_referrer, has_user_gesture,
+ transition, is_external_protocol, REQUEST_CONTEXT_TYPE_LOCATION,
+ blink::WebMixedContentContextType::Blockable, complete_callback);
}
NavigationThrottle::ThrottleCheckResult
@@ -383,35 +370,26 @@ NavigationHandleImpl::CallWillRedirectRequestForTesting(
const GURL& new_url,
bool new_method_is_post,
const GURL& new_referrer_url,
- bool new_is_external_protocol) {
- NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER;
- WillRedirectRequest(new_url, new_method_is_post ? "POST" : "GET",
- new_referrer_url, new_is_external_protocol,
- scoped_refptr<net::HttpResponseHeaders>(),
- net::HttpResponseInfo::CONNECTION_INFO_UNKNOWN,
- base::Bind(&UpdateThrottleCheckResult, &result));
-
- // Reset the callback to ensure it will not be called later.
- complete_callback_.Reset();
- return result;
+ bool new_is_external_protocol,
+ const ThrottleChecksFinishedCallback& complete_callback) {
+ return WillRedirectRequest(
+ new_url, new_method_is_post ? "POST" : "GET", new_referrer_url,
+ new_is_external_protocol, scoped_refptr<net::HttpResponseHeaders>(),
+ net::HttpResponseInfo::CONNECTION_INFO_UNKNOWN, complete_callback);
}
NavigationThrottle::ThrottleCheckResult
NavigationHandleImpl::CallWillProcessResponseForTesting(
content::RenderFrameHost* render_frame_host,
- const std::string& raw_response_headers) {
+ const std::string& raw_response_headers,
+ const ThrottleChecksFinishedCallback& complete_callback) {
scoped_refptr<net::HttpResponseHeaders> headers =
new net::HttpResponseHeaders(raw_response_headers);
- NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER;
- WillProcessResponse(static_cast<RenderFrameHostImpl*>(render_frame_host),
- headers, net::HttpResponseInfo::CONNECTION_INFO_UNKNOWN,
- SSLStatus(), GlobalRequestID(), false, false, false,
- base::Closure(),
- base::Bind(&UpdateThrottleCheckResult, &result));
-
- // Reset the callback to ensure it will not be called later.
- complete_callback_.Reset();
- return result;
+ return WillProcessResponse(
+ static_cast<RenderFrameHostImpl*>(render_frame_host), headers,
+ net::HttpResponseInfo::CONNECTION_INFO_UNKNOWN, SSLStatus(),
+ GlobalRequestID(), false, false, false, base::Closure(),
+ complete_callback);
}
void NavigationHandleImpl::CallDidCommitNavigationForTesting(const GURL& url) {
@@ -475,7 +453,7 @@ void NavigationHandleImpl::InitAppCacheHandle(
appcache_handle_.reset(new AppCacheNavigationHandle(appcache_service));
}
-void NavigationHandleImpl::WillStartRequest(
+NavigationThrottle::ThrottleCheckResult NavigationHandleImpl::WillStartRequest(
const std::string& method,
scoped_refptr<content::ResourceRequestBodyImpl> resource_request_body,
const Referrer& sanitized_referrer,
@@ -520,9 +498,11 @@ void NavigationHandleImpl::WillStartRequest(
// If the navigation is not deferred, run the callback.
if (result != NavigationThrottle::DEFER)
RunCompleteCallback(result);
+ return result;
}
-void NavigationHandleImpl::WillRedirectRequest(
+NavigationThrottle::ThrottleCheckResult
+NavigationHandleImpl::WillRedirectRequest(
const GURL& new_url,
const std::string& new_method,
const GURL& new_referrer_url,
@@ -557,9 +537,11 @@ void NavigationHandleImpl::WillRedirectRequest(
// If the navigation is not deferred, run the callback.
if (result != NavigationThrottle::DEFER)
RunCompleteCallback(result);
+ return result;
}
-void NavigationHandleImpl::WillProcessResponse(
+NavigationThrottle::ThrottleCheckResult
+NavigationHandleImpl::WillProcessResponse(
RenderFrameHostImpl* render_frame_host,
scoped_refptr<net::HttpResponseHeaders> response_headers,
net::HttpResponseInfo::ConnectionInfo connection_info,
@@ -592,11 +574,12 @@ void NavigationHandleImpl::WillProcessResponse(
// Note: if MaybeTransferAndProceed returns false, this means that this
// NavigationHandle was deleted, so return immediately.
if (result == NavigationThrottle::PROCEED && !MaybeTransferAndProceed())
- return;
+ return result;
// If the navigation is not deferred, run the callback.
if (result != NavigationThrottle::DEFER)
RunCompleteCallback(result);
+ return result;
}
void NavigationHandleImpl::ReadyToCommitNavigation(

Powered by Google App Engine
This is Rietveld 408576698