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

Side by Side Diff: components/subresource_filter/content/browser/subframe_navigation_filtering_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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/subresource_filter/content/browser/subframe_navigation_filt ering_throttle.h" 5 #include "components/subresource_filter/content/browser/subframe_navigation_filt ering_throttle.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "components/subresource_filter/core/common/time_measurements.h" 10 #include "components/subresource_filter/core/common/time_measurements.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 return "SubframeNavigationFilteringThrottle"; 50 return "SubframeNavigationFilteringThrottle";
51 } 51 }
52 52
53 content::NavigationThrottle::ThrottleCheckResult 53 content::NavigationThrottle::ThrottleCheckResult
54 SubframeNavigationFilteringThrottle::DeferToCalculateLoadPolicy() { 54 SubframeNavigationFilteringThrottle::DeferToCalculateLoadPolicy() {
55 parent_frame_filter_->GetLoadPolicyForSubdocument( 55 parent_frame_filter_->GetLoadPolicyForSubdocument(
56 navigation_handle()->GetURL(), 56 navigation_handle()->GetURL(),
57 base::Bind(&SubframeNavigationFilteringThrottle::OnCalculatedLoadPolicy, 57 base::Bind(&SubframeNavigationFilteringThrottle::OnCalculatedLoadPolicy,
58 weak_ptr_factory_.GetWeakPtr())); 58 weak_ptr_factory_.GetWeakPtr()));
59 last_defer_timestamp_ = base::TimeTicks::Now(); 59 last_defer_timestamp_ = base::TimeTicks::Now();
60 return content::NavigationThrottle::ThrottleCheckResult::DEFER; 60 return content::NavigationThrottle::DEFER;
61 } 61 }
62 62
63 void SubframeNavigationFilteringThrottle::OnCalculatedLoadPolicy( 63 void SubframeNavigationFilteringThrottle::OnCalculatedLoadPolicy(
64 LoadPolicy policy) { 64 LoadPolicy policy) {
65 DCHECK(!last_defer_timestamp_.is_null()); 65 DCHECK(!last_defer_timestamp_.is_null());
66 total_defer_time_ += base::TimeTicks::Now() - last_defer_timestamp_; 66 total_defer_time_ += base::TimeTicks::Now() - last_defer_timestamp_;
67 // TODO(csharrison): Support WouldDisallow pattern and expose the policy for 67 // TODO(csharrison): Support WouldDisallow pattern and expose the policy for
68 // metrics. Also, cancel with BLOCK_AND_COLLAPSE when it is implemented. 68 // metrics. Also, cancel with BLOCK_AND_COLLAPSE when it is implemented.
69 if (policy == LoadPolicy::DISALLOW) { 69 if (policy == LoadPolicy::DISALLOW) {
70 disallowed_ = true; 70 disallowed_ = true;
71 parent_frame_filter_->ReportDisallowedLoad(); 71 parent_frame_filter_->ReportDisallowedLoad();
72 navigation_handle()->CancelDeferredNavigation( 72 navigation_handle()->CancelDeferredNavigation(
73 content::NavigationThrottle::CANCEL); 73 content::NavigationThrottle::CANCEL);
74 } else { 74 } else {
75 navigation_handle()->Resume(); 75 navigation_handle()->Resume();
76 } 76 }
77 } 77 }
78 78
79 } // namespace subresource_filter 79 } // namespace subresource_filter
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698