OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_RESOURCE
_THROTTLE_H_ | 5 #ifndef COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_RESOURCE_THROTTL
E_H_ |
6 #define CONTENT_COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_RESOURCE
_THROTTLE_H_ | 6 #define COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_RESOURCE_THROTTL
E_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/resource_throttle.h" | 12 #include "content/public/browser/resource_throttle.h" |
13 #include "content/public/common/page_transition_types.h" | 13 #include "content/public/common/page_transition_types.h" |
14 | 14 |
15 class GURL; | 15 class GURL; |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 class RenderViewHost; | 18 class RenderViewHost; |
19 struct Referrer; | 19 struct Referrer; |
20 } | 20 } |
21 | 21 |
22 namespace net { | 22 namespace net { |
23 class URLRequest; | 23 class URLRequest; |
24 } | 24 } |
25 | 25 |
26 namespace content { | 26 namespace components { |
27 | 27 |
28 // This class allows the provider of the Callback to selectively ignore top | 28 // This class allows the provider of the Callback to selectively ignore top |
29 // level navigations. | 29 // level navigations. |
30 class InterceptNavigationResourceThrottle : public content::ResourceThrottle { | 30 class InterceptNavigationResourceThrottle : public content::ResourceThrottle { |
31 public: | 31 public: |
32 typedef base::Callback<bool(content::RenderViewHost* /* source */, | 32 typedef base::Callback< |
33 const GURL& /* url */, | 33 bool(content::RenderViewHost* /* source */, |
34 const content::Referrer& /*referrer*/, | 34 const GURL& /* url */, |
35 bool /* is_post */, | 35 const content::Referrer& /*referrer*/, |
36 bool /* has_user_gesture */, | 36 bool /* is_post */, |
37 PageTransition /* page transition type */)> | 37 bool /* has_user_gesture */, |
| 38 content::PageTransition /* page transition type */)> |
38 CheckOnUIThreadCallback; | 39 CheckOnUIThreadCallback; |
39 | 40 |
40 InterceptNavigationResourceThrottle( | 41 InterceptNavigationResourceThrottle( |
41 net::URLRequest* request, | 42 net::URLRequest* request, |
42 CheckOnUIThreadCallback should_ignore_callback); | 43 CheckOnUIThreadCallback should_ignore_callback); |
43 virtual ~InterceptNavigationResourceThrottle(); | 44 virtual ~InterceptNavigationResourceThrottle(); |
44 | 45 |
45 // content::ResourceThrottle implementation: | 46 // content::ResourceThrottle implementation: |
46 virtual void WillStartRequest(bool* defer) OVERRIDE; | 47 virtual void WillStartRequest(bool* defer) OVERRIDE; |
47 virtual void WillRedirectRequest(const GURL& new_url, bool* defer) OVERRIDE; | 48 virtual void WillRedirectRequest(const GURL& new_url, bool* defer) OVERRIDE; |
48 | 49 |
49 private: | 50 private: |
50 bool CheckIfShouldIgnoreNavigation(const GURL& url); | 51 bool CheckIfShouldIgnoreNavigation(const GURL& url); |
51 void OnResultObtained(bool should_ignore_navigation); | 52 void OnResultObtained(bool should_ignore_navigation); |
52 | 53 |
53 net::URLRequest* request_; | 54 net::URLRequest* request_; |
54 CheckOnUIThreadCallback should_ignore_callback_; | 55 CheckOnUIThreadCallback should_ignore_callback_; |
55 base::WeakPtrFactory<InterceptNavigationResourceThrottle> weak_ptr_factory_; | 56 base::WeakPtrFactory<InterceptNavigationResourceThrottle> weak_ptr_factory_; |
56 | 57 |
57 DISALLOW_COPY_AND_ASSIGN(InterceptNavigationResourceThrottle); | 58 DISALLOW_COPY_AND_ASSIGN(InterceptNavigationResourceThrottle); |
58 }; | 59 }; |
59 | 60 |
60 } // namespace content | 61 } // namespace components |
61 | 62 |
62 #endif // CONTENT_COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_RESOU
RCE_THROTTLE_H_ | 63 #endif // COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_RESOURCE_THRO
TTLE_H_ |
OLD | NEW |