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 scoped_ptr<content::NavigationThrottle> |
87 net::URLRequest* request) { | 88 InterceptNavigationDelegate::CreateThrottleFor( |
88 return new InterceptNavigationResourceThrottle( | 89 content::NavigationHandle* handle, |
89 request, base::Bind(&CheckIfShouldIgnoreNavigationOnUIThread)); | 90 content::WebContents* web_contents) { |
91 return scoped_ptr<InterceptNavigationThrottle>( | |
davidben
2015/09/01 21:55:17
Optional: This can be
return make_scoped_ptr(ne
clamy
2015/09/03 15:30:51
Due to a change in the interface for registering t
| |
92 new InterceptNavigationThrottle( | |
93 handle, web_contents, | |
94 base::Bind(&CheckIfShouldIgnoreNavigationOnUIThread))); | |
90 } | 95 } |
91 | 96 |
92 // static | 97 // static |
93 void InterceptNavigationDelegate::UpdateUserGestureCarryoverInfo( | 98 void InterceptNavigationDelegate::UpdateUserGestureCarryoverInfo( |
94 net::URLRequest* request) { | 99 net::URLRequest* request) { |
95 const content::ResourceRequestInfo* info = | 100 const content::ResourceRequestInfo* info = |
96 content::ResourceRequestInfo::ForRequest(request); | 101 content::ResourceRequestInfo::ForRequest(request); |
97 if (!info || !info->HasUserGesture()) | 102 if (!info || !info->HasUserGesture()) |
98 return; | 103 return; |
99 | 104 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 last_user_gesture_carryover_timestamp_ = base::TimeTicks::Now(); | 149 last_user_gesture_carryover_timestamp_ = base::TimeTicks::Now(); |
145 } | 150 } |
146 | 151 |
147 // Register native methods. | 152 // Register native methods. |
148 | 153 |
149 bool RegisterInterceptNavigationDelegate(JNIEnv* env) { | 154 bool RegisterInterceptNavigationDelegate(JNIEnv* env) { |
150 return RegisterNativesImpl(env); | 155 return RegisterNativesImpl(env); |
151 } | 156 } |
152 | 157 |
153 } // namespace navigation_interception | 158 } // namespace navigation_interception |
OLD | NEW |