| OLD | NEW |
| 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 "content/public/browser/navigation_handle.h" | 9 #include "content/public/browser/navigation_handle.h" |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 content::NavigationThrottle::ThrottleCheckResult | 25 content::NavigationThrottle::ThrottleCheckResult |
| 26 SubframeNavigationFilteringThrottle::WillStartRequest() { | 26 SubframeNavigationFilteringThrottle::WillStartRequest() { |
| 27 return DeferToCalculateLoadPolicy(); | 27 return DeferToCalculateLoadPolicy(); |
| 28 } | 28 } |
| 29 | 29 |
| 30 content::NavigationThrottle::ThrottleCheckResult | 30 content::NavigationThrottle::ThrottleCheckResult |
| 31 SubframeNavigationFilteringThrottle::WillRedirectRequest() { | 31 SubframeNavigationFilteringThrottle::WillRedirectRequest() { |
| 32 return DeferToCalculateLoadPolicy(); | 32 return DeferToCalculateLoadPolicy(); |
| 33 } | 33 } |
| 34 | 34 |
| 35 const char* SubframeNavigationFilteringThrottle::GetNameForLogging() { |
| 36 return "SubframeNavigationFilteringThrottle"; |
| 37 } |
| 38 |
| 35 content::NavigationThrottle::ThrottleCheckResult | 39 content::NavigationThrottle::ThrottleCheckResult |
| 36 SubframeNavigationFilteringThrottle::DeferToCalculateLoadPolicy() { | 40 SubframeNavigationFilteringThrottle::DeferToCalculateLoadPolicy() { |
| 37 parent_frame_filter_->GetLoadPolicyForSubdocument( | 41 parent_frame_filter_->GetLoadPolicyForSubdocument( |
| 38 navigation_handle()->GetURL(), | 42 navigation_handle()->GetURL(), |
| 39 base::Bind(&SubframeNavigationFilteringThrottle::OnCalculatedLoadPolicy, | 43 base::Bind(&SubframeNavigationFilteringThrottle::OnCalculatedLoadPolicy, |
| 40 weak_ptr_factory_.GetWeakPtr())); | 44 weak_ptr_factory_.GetWeakPtr())); |
| 41 return content::NavigationThrottle::ThrottleCheckResult::DEFER; | 45 return content::NavigationThrottle::ThrottleCheckResult::DEFER; |
| 42 } | 46 } |
| 43 | 47 |
| 44 void SubframeNavigationFilteringThrottle::OnCalculatedLoadPolicy( | 48 void SubframeNavigationFilteringThrottle::OnCalculatedLoadPolicy( |
| 45 LoadPolicy policy) { | 49 LoadPolicy policy) { |
| 46 // TODO(csharrison): Support WouldDisallow pattern and expose the policy for | 50 // TODO(csharrison): Support WouldDisallow pattern and expose the policy for |
| 47 // metrics. Also, cancel with BLOCK_AND_COLLAPSE when it is implemented. | 51 // metrics. Also, cancel with BLOCK_AND_COLLAPSE when it is implemented. |
| 48 if (policy == LoadPolicy::DISALLOW) { | 52 if (policy == LoadPolicy::DISALLOW) { |
| 49 parent_frame_filter_->ReportDisallowedLoad(); | 53 parent_frame_filter_->ReportDisallowedLoad(); |
| 50 navigation_handle()->CancelDeferredNavigation( | 54 navigation_handle()->CancelDeferredNavigation( |
| 51 content::NavigationThrottle::CANCEL); | 55 content::NavigationThrottle::CANCEL); |
| 52 } else { | 56 } else { |
| 53 navigation_handle()->Resume(); | 57 navigation_handle()->Resume(); |
| 54 } | 58 } |
| 55 } | 59 } |
| 56 | 60 |
| 57 } // namespace subresource_filter | 61 } // namespace subresource_filter |
| OLD | NEW |