OLD | NEW |
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 #include "components/navigation_interception/intercept_navigation_delegate.h" | 5 #include "components/navigation_interception/intercept_navigation_delegate.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "components/navigation_interception/intercept_navigation_resource_throt
tle.h" | 10 #include "components/navigation_interception/intercept_navigation_throttle.h" |
11 #include "components/navigation_interception/navigation_params_android.h" | 11 #include "components/navigation_interception/navigation_params_android.h" |
12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 13 #include "content/public/browser/navigation_throttle.h" |
13 #include "content/public/browser/render_frame_host.h" | 14 #include "content/public/browser/render_frame_host.h" |
14 #include "content/public/browser/render_view_host.h" | 15 #include "content/public/browser/render_view_host.h" |
15 #include "content/public/browser/resource_request_info.h" | 16 #include "content/public/browser/resource_request_info.h" |
16 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
17 #include "jni/InterceptNavigationDelegate_jni.h" | 18 #include "jni/InterceptNavigationDelegate_jni.h" |
18 #include "net/url_request/url_request.h" | 19 #include "net/url_request/url_request.h" |
19 #include "url/gurl.h" | 20 #include "url/gurl.h" |
20 | 21 |
21 using base::android::ConvertUTF8ToJavaString; | 22 using base::android::ConvertUTF8ToJavaString; |
22 using base::android::ScopedJavaLocalRef; | 23 using base::android::ScopedJavaLocalRef; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 } | 77 } |
77 | 78 |
78 // static | 79 // static |
79 InterceptNavigationDelegate* InterceptNavigationDelegate::Get( | 80 InterceptNavigationDelegate* InterceptNavigationDelegate::Get( |
80 WebContents* web_contents) { | 81 WebContents* web_contents) { |
81 return static_cast<InterceptNavigationDelegate*>( | 82 return static_cast<InterceptNavigationDelegate*>( |
82 web_contents->GetUserData(kInterceptNavigationDelegateUserDataKey)); | 83 web_contents->GetUserData(kInterceptNavigationDelegateUserDataKey)); |
83 } | 84 } |
84 | 85 |
85 // static | 86 // static |
86 content::ResourceThrottle* InterceptNavigationDelegate::CreateThrottleFor( | 87 content::NavigationThrottle* InterceptNavigationDelegate::CreateThrottleFor( |
87 net::URLRequest* request) { | 88 content::NavigationHandle* handle) { |
88 return new InterceptNavigationResourceThrottle( | 89 return new InterceptNavigationThrottle( |
89 request, base::Bind(&CheckIfShouldIgnoreNavigationOnUIThread)); | 90 handle->GetWebContents(), handle, |
| 91 base::Bind(&CheckIfShouldIgnoreNavigationOnUIThread)); |
90 } | 92 } |
91 | 93 |
92 // static | 94 // static |
93 void InterceptNavigationDelegate::UpdateUserGestureCarryoverInfo( | 95 void InterceptNavigationDelegate::UpdateUserGestureCarryoverInfo( |
94 net::URLRequest* request) { | 96 net::URLRequest* request) { |
95 const content::ResourceRequestInfo* info = | 97 const content::ResourceRequestInfo* info = |
96 content::ResourceRequestInfo::ForRequest(request); | 98 content::ResourceRequestInfo::ForRequest(request); |
97 if (!info || !info->HasUserGesture()) | 99 if (!info || !info->HasUserGesture()) |
98 return; | 100 return; |
99 | 101 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 last_user_gesture_carryover_timestamp_ = base::TimeTicks::Now(); | 146 last_user_gesture_carryover_timestamp_ = base::TimeTicks::Now(); |
145 } | 147 } |
146 | 148 |
147 // Register native methods. | 149 // Register native methods. |
148 | 150 |
149 bool RegisterInterceptNavigationDelegate(JNIEnv* env) { | 151 bool RegisterInterceptNavigationDelegate(JNIEnv* env) { |
150 return RegisterNativesImpl(env); | 152 return RegisterNativesImpl(env); |
151 } | 153 } |
152 | 154 |
153 } // namespace navigation_interception | 155 } // namespace navigation_interception |
OLD | NEW |