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 COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_RESOURCE_THROTTL
E_H_ |
| 6 #define COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_RESOURCE_THROTTL
E_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 WebContents; |
| 18 } |
| 19 |
| 20 namespace net { |
| 21 class URLRequest; |
| 22 } |
| 23 |
| 24 namespace navigation_interception { |
| 25 |
| 26 class NavigationParams; |
| 27 |
| 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( |
| 33 content::WebContents* /* source */, |
| 34 const NavigationParams& /* navigation_params */)> |
| 35 CheckOnUIThreadCallback; |
| 36 |
| 37 InterceptNavigationResourceThrottle( |
| 38 net::URLRequest* request, |
| 39 CheckOnUIThreadCallback should_ignore_callback); |
| 40 ~InterceptNavigationResourceThrottle() override; |
| 41 |
| 42 // content::ResourceThrottle implementation: |
| 43 void WillStartRequest(bool* defer) override; |
| 44 void WillRedirectRequest(const net::RedirectInfo& redirect_info, |
| 45 bool* defer) override; |
| 46 const char* GetNameForLogging() const override; |
| 47 |
| 48 private: |
| 49 bool CheckIfShouldIgnoreNavigation(const GURL& url, |
| 50 const std::string& method, |
| 51 bool is_redirect); |
| 52 void OnResultObtained(bool should_ignore_navigation); |
| 53 |
| 54 net::URLRequest* request_; |
| 55 CheckOnUIThreadCallback should_ignore_callback_; |
| 56 base::WeakPtrFactory<InterceptNavigationResourceThrottle> weak_ptr_factory_; |
| 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(InterceptNavigationResourceThrottle); |
| 59 }; |
| 60 |
| 61 } // namespace navigation_interception |
| 62 |
| 63 #endif // COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_RESOURCE_THRO
TTLE_H_ |
OLD | NEW |