Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: chrome/browser/component/navigation_interception/intercept_navigation_resource_throttle.h

Issue 10946008: Componentize IgnoreNavigationResourceThrottle and add chrome and webview specific implementations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: moved jni to component, added Java test code Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_RENDERER_HOST_INTERCEPT_NAVIGATION_RESOURCE_THROTTLE_H_ 5 #ifndef CHROME_BROWSER_COMPONENT_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_RE SOURCE_THROTTLE_H_
6 #define CHROME_BROWSER_RENDERER_HOST_INTERCEPT_NAVIGATION_RESOURCE_THROTTLE_H_ 6 #define CHROME_BROWSER_COMPONENT_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_RE SOURCE_THROTTLE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "content/public/browser/resource_throttle.h" 12 #include "content/public/browser/resource_throttle.h"
13 13
14 class GURL; 14 class GURL;
15 15
16 namespace content { 16 namespace content {
17 class RenderViewHost; 17 class RenderViewHost;
18 struct Referrer; 18 struct Referrer;
19 } 19 }
20 20
21 namespace net { 21 namespace net {
22 class URLRequest; 22 class URLRequest;
23 } 23 }
24 24
25 namespace navigation_interception {
26
25 // This class allows the provider of the Callback to selectively ignore top 27 // This class allows the provider of the Callback to selectively ignore top
26 // level navigations. 28 // level navigations.
27 class InterceptNavigationResourceThrottle : public content::ResourceThrottle { 29 class InterceptNavigationResourceThrottle : public content::ResourceThrottle {
28 public: 30 public:
29 typedef base::Callback<bool(content::RenderViewHost* /* source */, 31 typedef base::Callback<bool(content::RenderViewHost* /* source */,
30 const GURL& /*url*/, 32 const GURL& /*url*/,
31 const content::Referrer& /*referrer*/, 33 const content::Referrer& /*referrer*/,
32 bool /*is_content_initiated*/)> 34 bool /*has_user_gesture*/)>
benm (inactive) 2012/10/05 13:42:15 s/has/is/ ?
mkosiba (inactive) 2012/10/08 15:09:12 This is just a copy of the ResourceRequestInfo::Ge
33 CheckOnUIThreadCallback; 35 CheckOnUIThreadCallback;
34 36
35 InterceptNavigationResourceThrottle( 37 InterceptNavigationResourceThrottle(
36 net::URLRequest* request, 38 net::URLRequest* request,
37 CheckOnUIThreadCallback should_ignore_callback); 39 CheckOnUIThreadCallback should_ignore_callback);
38 virtual ~InterceptNavigationResourceThrottle(); 40 virtual ~InterceptNavigationResourceThrottle();
39 41
40 // content::ResourceThrottle implementation: 42 // content::ResourceThrottle implementation:
41 virtual void WillStartRequest(bool* defer) OVERRIDE; 43 virtual void WillStartRequest(bool* defer) OVERRIDE;
42 virtual void WillRedirectRequest(const GURL& new_url, bool* defer) OVERRIDE; 44 virtual void WillRedirectRequest(const GURL& new_url, bool* defer) OVERRIDE;
43 45
44 private: 46 private:
45 bool CheckIfShouldIgnoreNavigation(const GURL& url); 47 bool CheckIfShouldIgnoreNavigation(const GURL& url);
46 void OnResultObtained(bool should_ignore_navigation); 48 void OnResultObtained(bool should_ignore_navigation);
47 49
48 net::URLRequest* request_; 50 net::URLRequest* request_;
49 CheckOnUIThreadCallback should_ignore_callback_; 51 CheckOnUIThreadCallback should_ignore_callback_;
50 base::WeakPtrFactory<InterceptNavigationResourceThrottle> weak_ptr_factory_; 52 base::WeakPtrFactory<InterceptNavigationResourceThrottle> weak_ptr_factory_;
51 53
52 DISALLOW_COPY_AND_ASSIGN(InterceptNavigationResourceThrottle); 54 DISALLOW_COPY_AND_ASSIGN(InterceptNavigationResourceThrottle);
53 }; 55 };
54 56
55 #endif // CHROME_BROWSER_RENDERER_HOST_INTERCEPT_NAVIGATION_RESOURCE_THROTTLE_H _ 57 } // namespace navigation_interception
58
59 #endif // CHROME_BROWSER_COMPONENT_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION _RESOURCE_THROTTLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698