BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / components / navigation_interception / intercept_navigation_throttle.cc
blobcc256a1273e0a0889e1df2cbabd3f999c3350bbb
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.
5 #include "components/navigation_interception/intercept_navigation_throttle.h"
7 #include "components/navigation_interception/navigation_params.h"
8 #include "content/public/browser/browser_thread.h"
9 #include "content/public/browser/navigation_handle.h"
11 namespace navigation_interception {
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) {}
19 InterceptNavigationThrottle::~InterceptNavigationThrottle() {}
21 content::NavigationThrottle::ThrottleCheckResult
22 InterceptNavigationThrottle::WillStartRequest() {
23 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
24 return CheckIfShouldIgnoreNavigation(false);
27 content::NavigationThrottle::ThrottleCheckResult
28 InterceptNavigationThrottle::WillRedirectRequest() {
29 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
30 return CheckIfShouldIgnoreNavigation(true);
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);
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;
49 } // namespace navigation_interception