[content shell] hook up testRunner.dumpEditingCallbacks
[chromium-blink-merge.git] / content / components / navigation_interception / intercept_navigation_resource_throttle.h
blobcbff6014423764162b5ef3e49a90d3118ad10a3d
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 CONTENT_COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_RESOURCE_THROTTLE_H_
6 #define CONTENT_COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_RESOURCE_THROTTLE_H_
8 #include <string>
10 #include "base/callback.h"
11 #include "base/memory/weak_ptr.h"
12 #include "content/public/browser/resource_throttle.h"
13 #include "content/public/common/page_transition_types.h"
15 class GURL;
17 namespace content {
18 class RenderViewHost;
19 struct Referrer;
22 namespace net {
23 class URLRequest;
26 namespace content {
28 // This class allows the provider of the Callback to selectively ignore top
29 // level navigations.
30 class InterceptNavigationResourceThrottle : public content::ResourceThrottle {
31 public:
32 typedef base::Callback<bool(content::RenderViewHost* /* source */,
33 const GURL& /* url */,
34 const content::Referrer& /*referrer*/,
35 bool /* is_post */,
36 bool /* has_user_gesture */,
37 PageTransition /* page transition type */)>
38 CheckOnUIThreadCallback;
40 InterceptNavigationResourceThrottle(
41 net::URLRequest* request,
42 CheckOnUIThreadCallback should_ignore_callback);
43 virtual ~InterceptNavigationResourceThrottle();
45 // content::ResourceThrottle implementation:
46 virtual void WillStartRequest(bool* defer) OVERRIDE;
47 virtual void WillRedirectRequest(const GURL& new_url, bool* defer) OVERRIDE;
49 private:
50 bool CheckIfShouldIgnoreNavigation(const GURL& url);
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 content
62 #endif // CONTENT_COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_RESOURCE_THROTTLE_H_