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" | |
|
davidben
2015/09/01 21:55:17
[Wow, this file is so much smaller! :-D]
| |
| 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 content::WebContents* web_contents, | |
| 15 CheckCallback should_ignore_callback) | |
| 16 : content::NavigationThrottle(navigation_handle), | |
| 17 web_contents_(web_contents), | |
| 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()->GetSanitizedReferrer(), | |
| 37 navigation_handle()->HasUserGesture(), navigation_handle()->IsPost(), | |
| 38 navigation_handle()->GetPageTransition(), is_redirect, | |
| 39 navigation_handle()->IsExternalProtocol(), true); | |
| 40 | |
| 41 bool should_ignore_navigation = | |
| 42 should_ignore_callback_.Run(web_contents_, navigation_params); | |
| 43 return should_ignore_navigation | |
| 44 ? content::NavigationThrottle::CANCEL_AND_IGNORE | |
| 45 : content::NavigationThrottle::PROCEED; | |
| 46 } | |
| 47 | |
| 48 } // namespace navigation_interception | |
| OLD | NEW |