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

Unified Diff: components/subresource_filter/content/browser/subframe_navigation_filtering_throttle.cc

Issue 2632633006: Implement NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE. (Closed)
Patch Set: Fix navigation transition type. 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
Index: components/subresource_filter/content/browser/subframe_navigation_filtering_throttle.cc
diff --git a/components/subresource_filter/content/browser/subframe_navigation_filtering_throttle.cc b/components/subresource_filter/content/browser/subframe_navigation_filtering_throttle.cc
index ebb562e5278a6f19584c350ea235efd6285956b8..8254f538d793d7a2c1192d86112381fe1cfb87bc 100644
--- a/components/subresource_filter/content/browser/subframe_navigation_filtering_throttle.cc
+++ b/components/subresource_filter/content/browser/subframe_navigation_filtering_throttle.cc
@@ -9,6 +9,7 @@
#include "base/metrics/histogram_macros.h"
#include "components/subresource_filter/core/common/time_measurements.h"
#include "content/public/browser/navigation_handle.h"
+#include "content/public/common/browser_side_navigation_policy.h"
namespace subresource_filter {
@@ -38,12 +39,12 @@ SubframeNavigationFilteringThrottle::~SubframeNavigationFilteringThrottle() {
content::NavigationThrottle::ThrottleCheckResult
SubframeNavigationFilteringThrottle::WillStartRequest() {
- return DeferToCalculateLoadPolicy();
+ return DeferToCalculateLoadPolicy(ThrottlingStage::WillStartRequest);
}
content::NavigationThrottle::ThrottleCheckResult
SubframeNavigationFilteringThrottle::WillRedirectRequest() {
- return DeferToCalculateLoadPolicy();
+ return DeferToCalculateLoadPolicy(ThrottlingStage::WillRedirectRequest);
}
const char* SubframeNavigationFilteringThrottle::GetNameForLogging() {
@@ -51,26 +52,34 @@ const char* SubframeNavigationFilteringThrottle::GetNameForLogging() {
}
content::NavigationThrottle::ThrottleCheckResult
-SubframeNavigationFilteringThrottle::DeferToCalculateLoadPolicy() {
+SubframeNavigationFilteringThrottle::DeferToCalculateLoadPolicy(
+ ThrottlingStage stage) {
parent_frame_filter_->GetLoadPolicyForSubdocument(
navigation_handle()->GetURL(),
base::Bind(&SubframeNavigationFilteringThrottle::OnCalculatedLoadPolicy,
- weak_ptr_factory_.GetWeakPtr()));
+ weak_ptr_factory_.GetWeakPtr(), stage));
last_defer_timestamp_ = base::TimeTicks::Now();
return content::NavigationThrottle::ThrottleCheckResult::DEFER;
}
void SubframeNavigationFilteringThrottle::OnCalculatedLoadPolicy(
+ ThrottlingStage stage,
LoadPolicy policy) {
DCHECK(!last_defer_timestamp_.is_null());
total_defer_time_ += base::TimeTicks::Now() - last_defer_timestamp_;
// TODO(csharrison): Support WouldDisallow pattern and expose the policy for
- // metrics. Also, cancel with BLOCK_AND_COLLAPSE when it is implemented.
+ // metrics.
if (policy == LoadPolicy::DISALLOW) {
disallowed_ = true;
parent_frame_filter_->ReportDisallowedLoad();
+
+ const bool block_and_collapse_is_supported =
+ content::IsBrowserSideNavigationEnabled() ||
+ stage == ThrottlingStage::WillStartRequest;
navigation_handle()->CancelDeferredNavigation(
- content::NavigationThrottle::CANCEL);
+ block_and_collapse_is_supported
+ ? content::NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE
+ : content::NavigationThrottle::CANCEL);
} else {
navigation_handle()->Resume();
}

Powered by Google App Engine
This is Rietveld 408576698