Chromium Code Reviews| Index: chrome/browser/renderer_host/intercept_navigation_resource_throttle.h |
| diff --git a/chrome/browser/renderer_host/intercept_navigation_resource_throttle.h b/chrome/browser/renderer_host/intercept_navigation_resource_throttle.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7bf973739d5c5b20319d870876108a7db007fe38 |
| --- /dev/null |
| +++ b/chrome/browser/renderer_host/intercept_navigation_resource_throttle.h |
| @@ -0,0 +1,56 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_RENDERER_HOST_INTERCEPT_NAVIGATION_RESOURCE_THROTTLE_H_ |
| +#define CHROME_BROWSER_RENDERER_HOST_INTERCEPT_NAVIGATION_RESOURCE_THROTTLE_H_ |
| +#pragma once |
| + |
| +#include <string> |
| + |
| +#include "base/callback.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "content/public/browser/resource_throttle.h" |
| + |
| +class GURL; |
| + |
| +namespace content { |
| +class WebContents; |
|
darin (slow to review)
2012/06/15 19:52:55
usually code in renderer_host does not see WebCont
mkosiba (inactive)
2012/06/18 10:47:06
Done.
|
| +class Referrer; |
| +} // namespace content |
| + |
| +namespace net { |
| +class URLRequest; |
| +} // namespace net |
| + |
| +// This class allows the embedder (via WebContentsDelegate) to selectively |
|
darin (slow to review)
2012/06/15 19:52:55
this comment seems wrong now.
mkosiba (inactive)
2012/06/18 10:47:06
Done.
|
| +// ignore top level navigations. |
| +class InterceptNavigationResourceThrottle : public content::ResourceThrottle { |
| + public: |
| + typedef base::Callback<bool(content::WebContents* /* source */, |
| + const GURL& /*url*/, |
| + const content::Referrer& /*referrer*/, |
| + bool /*is_content_initiated*/)> |
| + CheckOnUIThreadCallback; |
| + InterceptNavigationResourceThrottle( |
| + net::URLRequest* request, |
| + CheckOnUIThreadCallback should_ignore_callback); |
| + virtual ~InterceptNavigationResourceThrottle(); |
| + |
| + // content::ResourceThrottle implementation: |
| + virtual void WillStartRequest(bool* defer) OVERRIDE; |
| + virtual void WillRedirectRequest(const GURL& new_url, bool* defer) OVERRIDE; |
| + |
| + private: |
| + bool ShouldDeferRequestForURL(const GURL& url); |
| + void OnResultObtained(bool should_ignore_navigation); |
| + |
| + net::URLRequest* request_; |
| + CheckOnUIThreadCallback should_ignore_callback_; |
| + base::WeakPtrFactory<InterceptNavigationResourceThrottle> |
| + weak_ptr_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(InterceptNavigationResourceThrottle); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_RENDERER_HOST_INTERCEPT_NAVIGATION_RESOURCE_THROTTLE_H_ |