OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/navigation_interception/intercept_navigation_throttle.h" |
| 6 |
| 7 #include "components/navigation_interception/navigation_params.h" |
| 8 #include "content/public/browser/navigation_handle.h" |
| 9 |
| 10 namespace navigation_interception { |
| 11 |
| 12 InterceptNavigationThrottle::InterceptNavigationThrottle( |
| 13 content::NavigationHandle* navigation_handle, |
| 14 CheckCallback should_ignore_callback) |
| 15 : content::NavigationThrottle(navigation_handle), |
| 16 should_ignore_callback_(should_ignore_callback) {} |
| 17 |
| 18 InterceptNavigationThrottle::~InterceptNavigationThrottle() {} |
| 19 |
| 20 content::NavigationThrottle::ThrottleCheckResult |
| 21 InterceptNavigationThrottle::WillStartRequest() { |
| 22 return CheckIfShouldIgnoreNavigation(false); |
| 23 } |
| 24 |
| 25 content::NavigationThrottle::ThrottleCheckResult |
| 26 InterceptNavigationThrottle::WillRedirectRequest() { |
| 27 return CheckIfShouldIgnoreNavigation(true); |
| 28 } |
| 29 |
| 30 content::NavigationThrottle::ThrottleCheckResult |
| 31 InterceptNavigationThrottle::CheckIfShouldIgnoreNavigation(bool is_redirect) { |
| 32 NavigationParams navigation_params( |
| 33 navigation_handle()->GetValidatedURL(), |
| 34 navigation_handle()->GetReferrer(), navigation_handle()->HasUserGesture(), |
| 35 navigation_handle()->IsPost(), navigation_handle()->GetPageTransition(), |
| 36 is_redirect, navigation_handle()->IsExternalProtocol(), true); |
| 37 |
| 38 bool should_ignore_navigation = should_ignore_callback_.Run( |
| 39 navigation_handle()->GetWebContents(), navigation_params); |
| 40 return should_ignore_navigation |
| 41 ? content::NavigationThrottle::CANCEL_AND_IGNORE |
| 42 : content::NavigationThrottle::PROCEED; |
| 43 } |
| 44 |
| 45 } // namespace navigation_interception |
OLD | NEW |