Chromium Code Reviews| 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::WebContents* web_contents, | |
| 14 content::NavigationHandle* navigation_handle, | |
| 15 CheckCallback should_ignore_callback) | |
| 16 : content::NavigationThrottle(navigation_handle), | |
| 17 web_contents_(web_contents), | |
|
nasko
2015/09/04 23:36:49
If we expose WebContents from NavigationHandle, we
clamy
2015/09/08 16:27:18
Done.
| |
| 18 should_ignore_callback_(should_ignore_callback) {} | |
| 19 | |
| 20 InterceptNavigationThrottle::~InterceptNavigationThrottle() {} | |
| 21 | |
| 22 content::NavigationThrottle::ThrottleCheckResult | |
| 23 InterceptNavigationThrottle::WillStartRequest() { | |
| 24 return CheckIfShouldIgnoreNavigation(false); | |
| 25 } | |
| 26 | |
| 27 content::NavigationThrottle::ThrottleCheckResult | |
| 28 InterceptNavigationThrottle::WillRedirectRequest() { | |
| 29 return CheckIfShouldIgnoreNavigation(true); | |
| 30 } | |
| 31 | |
| 32 content::NavigationThrottle::ThrottleCheckResult | |
| 33 InterceptNavigationThrottle::CheckIfShouldIgnoreNavigation(bool is_redirect) { | |
| 34 NavigationParams navigation_params( | |
| 35 navigation_handle()->GetValidatedURL(), | |
| 36 navigation_handle()->GetReferrer(), navigation_handle()->HasUserGesture(), | |
| 37 navigation_handle()->IsPost(), navigation_handle()->GetPageTransition(), | |
| 38 is_redirect, navigation_handle()->IsExternalProtocol(), true); | |
| 39 | |
| 40 bool should_ignore_navigation = | |
| 41 should_ignore_callback_.Run(web_contents_, navigation_params); | |
| 42 return should_ignore_navigation | |
| 43 ? content::NavigationThrottle::CANCEL_AND_IGNORE | |
| 44 : content::NavigationThrottle::PROCEED; | |
| 45 } | |
| 46 | |
| 47 } // namespace navigation_interception | |
| OLD | NEW |