OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_THROTTLE_H_ | 5 #ifndef COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_THROTTLE_H_ |
6 #define COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_THROTTLE_H_ | 6 #define COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_THROTTLE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "content/public/browser/navigation_throttle.h" | 12 #include "content/public/browser/navigation_throttle.h" |
13 | 13 |
14 class GURL; | 14 class GURL; |
15 | 15 |
16 namespace content { | 16 namespace content { |
17 class NavigationHandle; | 17 class NavigationHandle; |
18 class WebContents; | 18 class WebContents; |
19 } | 19 } |
20 | 20 |
21 namespace navigation_interception { | 21 namespace navigation_interception { |
22 | 22 |
23 class NavigationParams; | 23 class NavigationParams; |
24 | 24 |
25 // This class allows the provider of the Callback to selectively ignore top | 25 // This class allows the provider of the Callback to selectively ignore top |
26 // level navigations. This is a UI thread class. | 26 // level navigations. This is a UI thread class. |
27 class InterceptNavigationThrottle : public content::NavigationThrottle { | 27 class InterceptNavigationThrottle |
| 28 : public content::NavigationThrottle { |
28 public: | 29 public: |
29 typedef base::Callback<bool(content::WebContents* /* source */, | 30 typedef base::Callback<bool(content::WebContents* /* source */, |
30 const NavigationParams& /* navigation_params */)> | 31 const NavigationParams& /* navigation_params */)> |
31 CheckCallback; | 32 CheckCallback; |
32 | 33 |
33 InterceptNavigationThrottle(content::NavigationHandle* navigation_handle, | 34 InterceptNavigationThrottle(content::NavigationHandle* navigation_handle, |
34 CheckCallback should_ignore_callback); | 35 CheckCallback should_ignore_callback); |
35 ~InterceptNavigationThrottle() override; | 36 ~InterceptNavigationThrottle() override; |
36 | 37 |
37 // content::NavigationThrottle implementation: | 38 // content::NavigationThrottle implementation: |
38 ThrottleCheckResult WillStartRequest() override; | 39 ThrottleCheckResult WillStartRequest() override; |
39 ThrottleCheckResult WillRedirectRequest() override; | 40 ThrottleCheckResult WillRedirectRequest() override; |
40 | 41 |
41 private: | 42 private: |
42 ThrottleCheckResult CheckIfShouldIgnoreNavigation(bool is_redirect); | 43 ThrottleCheckResult CheckIfShouldIgnoreNavigation(bool is_redirect); |
43 | 44 |
44 CheckCallback should_ignore_callback_; | 45 CheckCallback should_ignore_callback_; |
45 | 46 |
| 47 base::WeakPtrFactory<InterceptNavigationThrottle> weak_factory_; |
| 48 |
46 DISALLOW_COPY_AND_ASSIGN(InterceptNavigationThrottle); | 49 DISALLOW_COPY_AND_ASSIGN(InterceptNavigationThrottle); |
47 }; | 50 }; |
48 | 51 |
49 } // namespace navigation_interception | 52 } // namespace navigation_interception |
50 | 53 |
51 #endif // COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_THROTTLE_H_ | 54 #endif // COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_THROTTLE_H_ |
OLD | NEW |