Chromium Code Reviews| Index: components/navigation_interception/intercept_navigation_throttle.cc |
| diff --git a/components/navigation_interception/intercept_navigation_throttle.cc b/components/navigation_interception/intercept_navigation_throttle.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..212fbb6c2a770af116708579a3c09e8de537b131 |
| --- /dev/null |
| +++ b/components/navigation_interception/intercept_navigation_throttle.cc |
| @@ -0,0 +1,48 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "components/navigation_interception/intercept_navigation_throttle.h" |
|
davidben
2015/09/01 21:55:17
[Wow, this file is so much smaller! :-D]
|
| + |
| +#include "components/navigation_interception/navigation_params.h" |
| +#include "content/public/browser/navigation_handle.h" |
| + |
| +namespace navigation_interception { |
| + |
| +InterceptNavigationThrottle::InterceptNavigationThrottle( |
| + content::NavigationHandle* navigation_handle, |
| + content::WebContents* web_contents, |
| + CheckCallback should_ignore_callback) |
| + : content::NavigationThrottle(navigation_handle), |
| + web_contents_(web_contents), |
| + should_ignore_callback_(should_ignore_callback) {} |
| + |
| +InterceptNavigationThrottle::~InterceptNavigationThrottle() {} |
| + |
| +content::NavigationThrottle::ThrottleCheckResult |
| +InterceptNavigationThrottle::WillStartRequest() { |
| + return CheckIfShouldIgnoreNavigation(false); |
| +} |
| + |
| +content::NavigationThrottle::ThrottleCheckResult |
| +InterceptNavigationThrottle::WillRedirectRequest() { |
| + return CheckIfShouldIgnoreNavigation(true); |
| +} |
| + |
| +content::NavigationThrottle::ThrottleCheckResult |
| +InterceptNavigationThrottle::CheckIfShouldIgnoreNavigation(bool is_redirect) { |
| + NavigationParams navigation_params( |
| + navigation_handle()->GetValidatedURL(), |
| + navigation_handle()->GetSanitizedReferrer(), |
| + navigation_handle()->HasUserGesture(), navigation_handle()->IsPost(), |
| + navigation_handle()->GetPageTransition(), is_redirect, |
| + navigation_handle()->IsExternalProtocol(), true); |
| + |
| + bool should_ignore_navigation = |
| + should_ignore_callback_.Run(web_contents_, navigation_params); |
| + return should_ignore_navigation |
| + ? content::NavigationThrottle::CANCEL_AND_IGNORE |
| + : content::NavigationThrottle::PROCEED; |
| +} |
| + |
| +} // namespace navigation_interception |