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/web_contents_delegate_android/web_contents_delegate_android .h" | 5 #include "components/web_contents_delegate_android/web_contents_delegate_android .h" |
6 | 6 |
7 #include <android/keycodes.h> | 7 #include <android/keycodes.h> |
8 | 8 |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
209 } | 209 } |
210 | 210 |
211 void WebContentsDelegateAndroid::RendererResponsive(WebContents* source) { | 211 void WebContentsDelegateAndroid::RendererResponsive(WebContents* source) { |
212 JNIEnv* env = AttachCurrentThread(); | 212 JNIEnv* env = AttachCurrentThread(); |
213 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env); | 213 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env); |
214 if (obj.is_null()) | 214 if (obj.is_null()) |
215 return; | 215 return; |
216 Java_WebContentsDelegateAndroid_rendererResponsive(env, obj.obj()); | 216 Java_WebContentsDelegateAndroid_rendererResponsive(env, obj.obj()); |
217 } | 217 } |
218 | 218 |
219 void WebContentsDelegateAndroid::DidNavigateToPendingEntry( | |
220 WebContents* source) { | |
221 JNIEnv* env = AttachCurrentThread(); | |
222 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env); | |
223 if (obj.is_null()) | |
224 return; | |
225 Java_WebContentsDelegateAndroid_didNavigateToPendingEntry(env, obj.obj()); | |
226 } | |
227 | |
228 bool WebContentsDelegateAndroid::ShouldCreateWebContents( | |
229 WebContents* web_contents, | |
230 int route_id, | |
231 WindowContainerType window_container_type, | |
232 const base::string16& frame_name, | |
233 const GURL& target_url, | |
234 const std::string& partition_id, | |
235 content::SessionStorageNamespace* session_storage_namespace) { | |
236 JNIEnv* env = AttachCurrentThread(); | |
237 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env); | |
238 if (obj.is_null()) | |
239 return true; | |
benm (inactive)
2014/11/05 14:44:27
is true the right return value here? It sounds a l
Ted C
2014/11/05 16:46:10
These are both the defaults in web_contents_delega
| |
240 ScopedJavaLocalRef<jstring> java_url = | |
241 ConvertUTF8ToJavaString(env, target_url.spec()); | |
242 return Java_WebContentsDelegateAndroid_shouldCreateWebContents(env, obj.obj(), | |
243 java_url.obj()); | |
244 } | |
245 | |
246 bool WebContentsDelegateAndroid::OnGoToEntryOffset(int offset) { | |
247 JNIEnv* env = AttachCurrentThread(); | |
248 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env); | |
249 if (obj.is_null()) | |
250 return true; | |
benm (inactive)
2014/11/05 14:44:27
is true the right return value here? It sounds a l
| |
251 return Java_WebContentsDelegateAndroid_onGoToEntryOffset(env, obj.obj(), | |
252 offset); | |
253 } | |
254 | |
255 void WebContentsDelegateAndroid::WebContentsCreated( | |
256 WebContents* source_contents, int opener_render_frame_id, | |
257 const base::string16& frame_name, const GURL& target_url, | |
258 WebContents* new_contents) { | |
259 JNIEnv* env = AttachCurrentThread(); | |
260 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env); | |
261 if (obj.is_null()) | |
262 return; | |
263 Java_WebContentsDelegateAndroid_webContentsCreated(env, obj.obj(), | |
264 reinterpret_cast<intptr_t>(source_contents), opener_render_frame_id, | |
Ted C
2014/11/05 16:46:10
Instead of passing the raw pointer to java, can yo
Ted C
2014/11/05 16:46:11
Since the params don't all fit on a single line, e
| |
265 base::android::ConvertUTF16ToJavaString(env, frame_name).Release(), | |
266 base::android::ConvertUTF8ToJavaString(env, target_url.spec()).Release(), | |
267 reinterpret_cast<intptr_t>(new_contents)); | |
268 } | |
269 | |
219 void WebContentsDelegateAndroid::CloseContents(WebContents* source) { | 270 void WebContentsDelegateAndroid::CloseContents(WebContents* source) { |
220 JNIEnv* env = AttachCurrentThread(); | 271 JNIEnv* env = AttachCurrentThread(); |
221 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env); | 272 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env); |
222 if (obj.is_null()) | 273 if (obj.is_null()) |
223 return; | 274 return; |
224 Java_WebContentsDelegateAndroid_closeContents(env, obj.obj()); | 275 Java_WebContentsDelegateAndroid_closeContents(env, obj.obj()); |
225 } | 276 } |
226 | 277 |
227 void WebContentsDelegateAndroid::MoveContents(WebContents* source, | 278 void WebContentsDelegateAndroid::MoveContents(WebContents* source, |
228 const gfx::Rect& pos) { | 279 const gfx::Rect& pos) { |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
377 // Native JNI methods | 428 // Native JNI methods |
378 // ---------------------------------------------------------------------------- | 429 // ---------------------------------------------------------------------------- |
379 | 430 |
380 // Register native methods | 431 // Register native methods |
381 | 432 |
382 bool RegisterWebContentsDelegateAndroid(JNIEnv* env) { | 433 bool RegisterWebContentsDelegateAndroid(JNIEnv* env) { |
383 return RegisterNativesImpl(env); | 434 return RegisterNativesImpl(env); |
384 } | 435 } |
385 | 436 |
386 } // namespace web_contents_delegate_android | 437 } // namespace web_contents_delegate_android |
OLD | NEW |