| 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/browser_thread.h" | |
| 9 #include "content/public/browser/navigation_handle.h" | |
| 10 | |
| 11 namespace navigation_interception { | |
| 12 | |
| 13 InterceptNavigationThrottle::InterceptNavigationThrottle( | |
| 14 content::NavigationHandle* navigation_handle, | |
| 15 CheckCallback should_ignore_callback) | |
| 16 : content::NavigationThrottle(navigation_handle), | |
| 17 should_ignore_callback_(should_ignore_callback) {} | |
| 18 | |
| 19 InterceptNavigationThrottle::~InterceptNavigationThrottle() {} | |
| 20 | |
| 21 content::NavigationThrottle::ThrottleCheckResult | |
| 22 InterceptNavigationThrottle::WillStartRequest() { | |
| 23 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
| 24 return CheckIfShouldIgnoreNavigation(false); | |
| 25 } | |
| 26 | |
| 27 content::NavigationThrottle::ThrottleCheckResult | |
| 28 InterceptNavigationThrottle::WillRedirectRequest() { | |
| 29 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
| 30 return CheckIfShouldIgnoreNavigation(true); | |
| 31 } | |
| 32 | |
| 33 content::NavigationThrottle::ThrottleCheckResult | |
| 34 InterceptNavigationThrottle::CheckIfShouldIgnoreNavigation(bool is_redirect) { | |
| 35 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
| 36 NavigationParams navigation_params( | |
| 37 navigation_handle()->GetURL(), navigation_handle()->GetReferrer(), | |
| 38 navigation_handle()->HasUserGesture(), navigation_handle()->IsPost(), | |
| 39 navigation_handle()->GetPageTransition(), is_redirect, | |
| 40 navigation_handle()->IsExternalProtocol(), true); | |
| 41 | |
| 42 bool should_ignore_navigation = should_ignore_callback_.Run( | |
| 43 navigation_handle()->GetWebContents(), navigation_params); | |
| 44 return should_ignore_navigation | |
| 45 ? content::NavigationThrottle::CANCEL_AND_IGNORE | |
| 46 : content::NavigationThrottle::PROCEED; | |
| 47 } | |
| 48 | |
| 49 } // namespace navigation_interception | |
| OLD | NEW |