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

Side by Side Diff: components/navigation_interception/intercept_navigation_delegate.h

Issue 1350913008: Revert of Add a NavigationThrottle to the public content/ interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@navigation-api
Patch Set: Created 5 years, 3 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
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 COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_DELEGATE_H_ 5 #ifndef COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_DELEGATE_H_
6 #define COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_DELEGATE_H_ 6 #define COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_DELEGATE_H_
7 7
8 #include "base/android/jni_weak_ref.h" 8 #include "base/android/jni_weak_ref.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/supports_user_data.h" 10 #include "base/supports_user_data.h"
11 11
12 class GURL; 12 class GURL;
13 13
14 namespace content { 14 namespace content {
15 class NavigationHandle; 15 class ResourceThrottle;
16 class NavigationThrottle;
17 class WebContents; 16 class WebContents;
18 } 17 }
19 18
20 namespace net { 19 namespace net {
21 class URLRequest; 20 class URLRequest;
22 } 21 }
23 22
24 namespace navigation_interception { 23 namespace navigation_interception {
25 24
26 class NavigationParams; 25 class NavigationParams;
27 26
28 // Native side of the InterceptNavigationDelegate Java interface. 27 // Native side of the InterceptNavigationDelegate Java interface.
29 // This is used to create a InterceptNavigationResourceThrottle that calls the 28 // This is used to create a InterceptNavigationResourceThrottle that calls the
30 // Java interface method to determine whether a navigation should be ignored or 29 // Java interface method to determine whether a navigation should be ignored or
31 // not. 30 // not.
32 // To us this class: 31 // To us this class:
33 // 1) the Java-side interface implementation must be associated (via the 32 // 1) the Java-side interface implementation must be associated (via the
34 // Associate method) with a WebContents for which URLRequests are to be 33 // Associate method) with a WebContents for which URLRequests are to be
35 // intercepted, 34 // intercepted,
36 // 2) the NavigationThrottle obtained via CreateThrottleFor must be associated 35 // 2) the ResourceThrottle obtained via CreateThrottleFor must be associated
37 // with the NavigationHandle in the ContentBrowserClient implementation. 36 // with the URLRequests in the ResourceDispatcherHostDelegate
37 // implementation.
38 class InterceptNavigationDelegate : public base::SupportsUserData::Data { 38 class InterceptNavigationDelegate : public base::SupportsUserData::Data {
39 public: 39 public:
40 InterceptNavigationDelegate(JNIEnv* env, jobject jdelegate); 40 InterceptNavigationDelegate(JNIEnv* env, jobject jdelegate);
41 ~InterceptNavigationDelegate() override; 41 ~InterceptNavigationDelegate() override;
42 42
43 // Associates the InterceptNavigationDelegate with a WebContents using the 43 // Associates the InterceptNavigationDelegate with a WebContents using the
44 // SupportsUserData mechanism. 44 // SupportsUserData mechanism.
45 // As implied by the use of scoped_ptr, the WebContents will assume ownership 45 // As implied by the use of scoped_ptr, the WebContents will assume ownership
46 // of |delegate|. 46 // of |delegate|.
47 static void Associate(content::WebContents* web_contents, 47 static void Associate(content::WebContents* web_contents,
48 scoped_ptr<InterceptNavigationDelegate> delegate); 48 scoped_ptr<InterceptNavigationDelegate> delegate);
49 // Gets the InterceptNavigationDelegate associated with the WebContents, 49 // Gets the InterceptNavigationDelegate associated with the WebContents,
50 // can be null. 50 // can be null.
51 static InterceptNavigationDelegate* Get(content::WebContents* web_contents); 51 static InterceptNavigationDelegate* Get(content::WebContents* web_contents);
52 52
53 // Creates a InterceptNavigationThrottle that will direct all callbacks to 53 // Creates a InterceptNavigationResourceThrottle that will direct all
54 // the InterceptNavigationDelegate. 54 // callbacks to the InterceptNavigationDelegate.
55 static scoped_ptr<content::NavigationThrottle> CreateThrottleFor( 55 static content::ResourceThrottle* CreateThrottleFor(
56 content::NavigationHandle* handle); 56 net::URLRequest* request);
57 57
58 // Updates information to determine whether to have user gesture carryover or 58 // Updates information to determine whether to have user gesture carryover or
59 // not. 59 // not.
60 static void UpdateUserGestureCarryoverInfo(net::URLRequest* request); 60 static void UpdateUserGestureCarryoverInfo(net::URLRequest* request);
61 61
62 virtual bool ShouldIgnoreNavigation( 62 virtual bool ShouldIgnoreNavigation(
63 const NavigationParams& navigation_params); 63 const NavigationParams& navigation_params);
64 64
65 // Updates |last_user_gesture_carryover_timestamp_| when user gesture is 65 // Updates |last_user_gesture_carryover_timestamp_| when user gesture is
66 // carried over. 66 // carried over.
67 void UpdateLastUserGestureCarryoverTimestamp(); 67 void UpdateLastUserGestureCarryoverTimestamp();
68 68
69 private: 69 private:
70 JavaObjectWeakGlobalRef weak_jdelegate_; 70 JavaObjectWeakGlobalRef weak_jdelegate_;
71 base::TimeTicks last_user_gesture_carryover_timestamp_; 71 base::TimeTicks last_user_gesture_carryover_timestamp_;
72 72
73 DISALLOW_COPY_AND_ASSIGN(InterceptNavigationDelegate); 73 DISALLOW_COPY_AND_ASSIGN(InterceptNavigationDelegate);
74 }; 74 };
75 75
76 bool RegisterInterceptNavigationDelegate(JNIEnv* env); 76 bool RegisterInterceptNavigationDelegate(JNIEnv* env);
77 77
78 } // namespace navigation_interception 78 } // namespace navigation_interception
79 79
80 #endif // COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_DELEGATE_H_ 80 #endif // COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_DELEGATE_H_
OLDNEW
« no previous file with comments | « components/navigation_interception/BUILD.gn ('k') | components/navigation_interception/intercept_navigation_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698