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 "base/memory/ptr_util.h" |
10 #include "components/navigation_interception/intercept_navigation_throttle.h" | 11 #include "components/navigation_interception/intercept_navigation_throttle.h" |
11 #include "components/navigation_interception/navigation_params_android.h" | 12 #include "components/navigation_interception/navigation_params_android.h" |
12 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
13 #include "content/public/browser/navigation_throttle.h" | 14 #include "content/public/browser/navigation_throttle.h" |
14 #include "content/public/browser/render_frame_host.h" | 15 #include "content/public/browser/render_frame_host.h" |
15 #include "content/public/browser/render_view_host.h" | 16 #include "content/public/browser/render_view_host.h" |
16 #include "content/public/browser/resource_request_info.h" | 17 #include "content/public/browser/resource_request_info.h" |
17 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
18 #include "jni/InterceptNavigationDelegate_jni.h" | 19 #include "jni/InterceptNavigationDelegate_jni.h" |
19 #include "net/url_request/url_request.h" | 20 #include "net/url_request/url_request.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 if (intercept_navigation_delegate) { | 65 if (intercept_navigation_delegate) { |
65 intercept_navigation_delegate->UpdateLastUserGestureCarryoverTimestamp(); | 66 intercept_navigation_delegate->UpdateLastUserGestureCarryoverTimestamp(); |
66 } | 67 } |
67 } | 68 } |
68 | 69 |
69 } // namespace | 70 } // namespace |
70 | 71 |
71 // static | 72 // static |
72 void InterceptNavigationDelegate::Associate( | 73 void InterceptNavigationDelegate::Associate( |
73 WebContents* web_contents, | 74 WebContents* web_contents, |
74 scoped_ptr<InterceptNavigationDelegate> delegate) { | 75 std::unique_ptr<InterceptNavigationDelegate> delegate) { |
75 web_contents->SetUserData(kInterceptNavigationDelegateUserDataKey, | 76 web_contents->SetUserData(kInterceptNavigationDelegateUserDataKey, |
76 delegate.release()); | 77 delegate.release()); |
77 } | 78 } |
78 | 79 |
79 // static | 80 // static |
80 InterceptNavigationDelegate* InterceptNavigationDelegate::Get( | 81 InterceptNavigationDelegate* InterceptNavigationDelegate::Get( |
81 WebContents* web_contents) { | 82 WebContents* web_contents) { |
82 return static_cast<InterceptNavigationDelegate*>( | 83 return static_cast<InterceptNavigationDelegate*>( |
83 web_contents->GetUserData(kInterceptNavigationDelegateUserDataKey)); | 84 web_contents->GetUserData(kInterceptNavigationDelegateUserDataKey)); |
84 } | 85 } |
85 | 86 |
86 // static | 87 // static |
87 scoped_ptr<content::NavigationThrottle> | 88 std::unique_ptr<content::NavigationThrottle> |
88 InterceptNavigationDelegate::CreateThrottleFor( | 89 InterceptNavigationDelegate::CreateThrottleFor( |
89 content::NavigationHandle* handle) { | 90 content::NavigationHandle* handle) { |
90 return scoped_ptr<content::NavigationThrottle>( | 91 return base::WrapUnique(new InterceptNavigationThrottle( |
91 new InterceptNavigationThrottle( | 92 handle, base::Bind(&CheckIfShouldIgnoreNavigationOnUIThread), false)); |
92 handle, base::Bind(&CheckIfShouldIgnoreNavigationOnUIThread), false)); | |
93 } | 93 } |
94 | 94 |
95 // static | 95 // static |
96 void InterceptNavigationDelegate::UpdateUserGestureCarryoverInfo( | 96 void InterceptNavigationDelegate::UpdateUserGestureCarryoverInfo( |
97 net::URLRequest* request) { | 97 net::URLRequest* request) { |
98 const content::ResourceRequestInfo* info = | 98 const content::ResourceRequestInfo* info = |
99 content::ResourceRequestInfo::ForRequest(request); | 99 content::ResourceRequestInfo::ForRequest(request); |
100 if (!info || !info->HasUserGesture()) | 100 if (!info || !info->HasUserGesture()) |
101 return; | 101 return; |
102 | 102 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 last_user_gesture_carryover_timestamp_ = base::TimeTicks::Now(); | 147 last_user_gesture_carryover_timestamp_ = base::TimeTicks::Now(); |
148 } | 148 } |
149 | 149 |
150 // Register native methods. | 150 // Register native methods. |
151 | 151 |
152 bool RegisterInterceptNavigationDelegate(JNIEnv* env) { | 152 bool RegisterInterceptNavigationDelegate(JNIEnv* env) { |
153 return RegisterNativesImpl(env); | 153 return RegisterNativesImpl(env); |
154 } | 154 } |
155 | 155 |
156 } // namespace navigation_interception | 156 } // namespace navigation_interception |
OLD | NEW |