OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_COMPONENT_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_RE
SOURCE_THROTTLE_H_ | |
6 #define CHROME_BROWSER_COMPONENT_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_RE
SOURCE_THROTTLE_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/callback.h" | |
11 #include "base/memory/weak_ptr.h" | |
12 #include "content/public/browser/resource_throttle.h" | |
13 | |
14 class GURL; | |
15 | |
16 namespace content { | |
17 class RenderViewHost; | |
18 struct Referrer; | |
19 } | |
20 | |
21 namespace net { | |
22 class URLRequest; | |
23 } | |
24 | |
25 namespace navigation_interception { | |
26 | |
27 // This class allows the provider of the Callback to selectively ignore top | |
28 // level navigations. | |
29 class InterceptNavigationResourceThrottle : public content::ResourceThrottle { | |
30 public: | |
31 typedef base::Callback<bool(content::RenderViewHost* /* source */, | |
32 const GURL& /*url*/, | |
33 const content::Referrer& /*referrer*/, | |
34 bool /*has_user_gesture*/)> | |
35 CheckOnUIThreadCallback; | |
36 | |
37 InterceptNavigationResourceThrottle( | |
38 net::URLRequest* request, | |
39 CheckOnUIThreadCallback should_ignore_callback); | |
40 virtual ~InterceptNavigationResourceThrottle(); | |
41 | |
42 // content::ResourceThrottle implementation: | |
43 virtual void WillStartRequest(bool* defer) OVERRIDE; | |
44 virtual void WillRedirectRequest(const GURL& new_url, bool* defer) OVERRIDE; | |
45 | |
46 private: | |
47 bool CheckIfShouldIgnoreNavigation(const GURL& url); | |
48 void OnResultObtained(bool should_ignore_navigation); | |
49 | |
50 net::URLRequest* request_; | |
51 CheckOnUIThreadCallback should_ignore_callback_; | |
52 base::WeakPtrFactory<InterceptNavigationResourceThrottle> weak_ptr_factory_; | |
53 | |
54 DISALLOW_COPY_AND_ASSIGN(InterceptNavigationResourceThrottle); | |
55 }; | |
56 | |
57 } // namespace navigation_interception | |
58 | |
59 #endif // CHROME_BROWSER_COMPONENT_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION
_RESOURCE_THROTTLE_H_ | |
OLD | NEW |