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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 } | 254 } |
255 | 255 |
256 void WebContentsDelegateAndroid::WebContentsCreated( | 256 void WebContentsDelegateAndroid::WebContentsCreated( |
257 WebContents* source_contents, int opener_render_frame_id, | 257 WebContents* source_contents, int opener_render_frame_id, |
258 const base::string16& frame_name, const GURL& target_url, | 258 const base::string16& frame_name, const GURL& target_url, |
259 WebContents* new_contents) { | 259 WebContents* new_contents) { |
260 JNIEnv* env = AttachCurrentThread(); | 260 JNIEnv* env = AttachCurrentThread(); |
261 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env); | 261 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env); |
262 if (obj.is_null()) | 262 if (obj.is_null()) |
263 return; | 263 return; |
264 Java_WebContentsDelegateAndroid_webContentsCreated(env, obj.obj(), | 264 |
265 reinterpret_cast<intptr_t>(source_contents), | 265 ScopedJavaLocalRef<jobject> jsource_contents; |
| 266 if (source_contents) |
| 267 jsource_contents = source_contents->GetJavaWebContents(); |
| 268 ScopedJavaLocalRef<jobject> jnew_contents; |
| 269 if (new_contents) |
| 270 jnew_contents = new_contents->GetJavaWebContents(); |
| 271 |
| 272 Java_WebContentsDelegateAndroid_webContentsCreated( |
| 273 env, |
| 274 obj.obj(), |
| 275 jsource_contents.obj(), |
266 opener_render_frame_id, | 276 opener_render_frame_id, |
267 base::android::ConvertUTF16ToJavaString(env, frame_name).Release(), | 277 base::android::ConvertUTF16ToJavaString(env, frame_name).Release(), |
268 base::android::ConvertUTF8ToJavaString(env, target_url.spec()).Release(), | 278 base::android::ConvertUTF8ToJavaString(env, target_url.spec()).Release(), |
269 reinterpret_cast<intptr_t>(new_contents)); | 279 jnew_contents.obj()); |
270 } | 280 } |
271 | 281 |
272 void WebContentsDelegateAndroid::CloseContents(WebContents* source) { | 282 void WebContentsDelegateAndroid::CloseContents(WebContents* source) { |
273 JNIEnv* env = AttachCurrentThread(); | 283 JNIEnv* env = AttachCurrentThread(); |
274 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env); | 284 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env); |
275 if (obj.is_null()) | 285 if (obj.is_null()) |
276 return; | 286 return; |
277 Java_WebContentsDelegateAndroid_closeContents(env, obj.obj()); | 287 Java_WebContentsDelegateAndroid_closeContents(env, obj.obj()); |
278 } | 288 } |
279 | 289 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 // Native JNI methods | 450 // Native JNI methods |
441 // ---------------------------------------------------------------------------- | 451 // ---------------------------------------------------------------------------- |
442 | 452 |
443 // Register native methods | 453 // Register native methods |
444 | 454 |
445 bool RegisterWebContentsDelegateAndroid(JNIEnv* env) { | 455 bool RegisterWebContentsDelegateAndroid(JNIEnv* env) { |
446 return RegisterNativesImpl(env); | 456 return RegisterNativesImpl(env); |
447 } | 457 } |
448 | 458 |
449 } // namespace web_contents_delegate_android | 459 } // namespace web_contents_delegate_android |
OLD | NEW |