Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Side by Side Diff: components/navigation_interception/intercept_navigation_throttle.cc

Issue 1269813002: Add a NavigationThrottle to the public content/ interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@navigation-api
Patch Set: Addressed comments Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698