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.
5 #ifndef COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_RESOURCE_THROTTLE_H_
6 #define COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_RESOURCE_THROTTLE_H_
10 #include "base/callback.h"
11 #include "base/memory/weak_ptr.h"
12 #include "content/public/browser/resource_throttle.h"
24 namespace navigation_interception {
26 class NavigationParams;
28 // This class allows the provider of the Callback to selectively ignore top
30 class InterceptNavigationResourceThrottle : public content::ResourceThrottle {
32 typedef base::Callback<bool(
33 content::RenderViewHost* /* source */,
34 const NavigationParams& /* navigation_params */)>
35 CheckOnUIThreadCallback;
37 InterceptNavigationResourceThrottle(
38 net::URLRequest* request,
39 CheckOnUIThreadCallback should_ignore_callback);
40 virtual ~InterceptNavigationResourceThrottle();
42 // content::ResourceThrottle implementation:
43 virtual void WillStartRequest(bool* defer) OVERRIDE;
44 virtual void WillRedirectRequest(const GURL& new_url, bool* defer) OVERRIDE;
47 std::string GetMethodAfterRedirect();
48 bool CheckIfShouldIgnoreNavigation(const GURL& url,
49 const std::string& method,
51 void OnResultObtained(bool should_ignore_navigation);
53 net::URLRequest* request_;
54 CheckOnUIThreadCallback should_ignore_callback_;
55 base::WeakPtrFactory<InterceptNavigationResourceThrottle> weak_ptr_factory_;
57 DISALLOW_COPY_AND_ASSIGN(InterceptNavigationResourceThrottle);
60 } // namespace navigation_interception
62 #endif // COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_RESOURCE_THROTTLE_H_