| 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_RENDERER_HOST_INTERCEPT_NAVIGATION_RESOURCE_THROTTLE_H_ | |
| 6 #define CHROME_BROWSER_RENDERER_HOST_INTERCEPT_NAVIGATION_RESOURCE_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 // This class allows the provider of the Callback to selectively ignore top | |
| 26 // level navigations. | |
| 27 class InterceptNavigationResourceThrottle : public content::ResourceThrottle { | |
| 28 public: | |
| 29 typedef base::Callback<bool(content::RenderViewHost* /* source */, | |
| 30 const GURL& /*url*/, | |
| 31 const content::Referrer& /*referrer*/, | |
| 32 bool /*is_content_initiated*/)> | |
| 33 CheckOnUIThreadCallback; | |
| 34 | |
| 35 InterceptNavigationResourceThrottle( | |
| 36 net::URLRequest* request, | |
| 37 CheckOnUIThreadCallback should_ignore_callback); | |
| 38 virtual ~InterceptNavigationResourceThrottle(); | |
| 39 | |
| 40 // content::ResourceThrottle implementation: | |
| 41 virtual void WillStartRequest(bool* defer) OVERRIDE; | |
| 42 virtual void WillRedirectRequest(const GURL& new_url, bool* defer) OVERRIDE; | |
| 43 | |
| 44 private: | |
| 45 bool CheckIfShouldIgnoreNavigation(const GURL& url); | |
| 46 void OnResultObtained(bool should_ignore_navigation); | |
| 47 | |
| 48 net::URLRequest* request_; | |
| 49 CheckOnUIThreadCallback should_ignore_callback_; | |
| 50 base::WeakPtrFactory<InterceptNavigationResourceThrottle> weak_ptr_factory_; | |
| 51 | |
| 52 DISALLOW_COPY_AND_ASSIGN(InterceptNavigationResourceThrottle); | |
| 53 }; | |
| 54 | |
| 55 #endif // CHROME_BROWSER_RENDERER_HOST_INTERCEPT_NAVIGATION_RESOURCE_THROTTLE_H
_ | |
| OLD | NEW |