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 "chrome/browser/android/chrome_web_contents_delegate_android.h" | 5 #include "chrome/browser/android/chrome_web_contents_delegate_android.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/command_line.h" | 9 #include "base/command_line.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 DCHECK_NE(disposition, SAVE_TO_DISK); | 315 DCHECK_NE(disposition, SAVE_TO_DISK); |
316 // Can't create a new contents for the current tab - invalid case. | 316 // Can't create a new contents for the current tab - invalid case. |
317 DCHECK_NE(disposition, CURRENT_TAB); | 317 DCHECK_NE(disposition, CURRENT_TAB); |
318 | 318 |
319 TabHelpers::AttachTabHelpers(new_contents); | 319 TabHelpers::AttachTabHelpers(new_contents); |
320 | 320 |
321 JNIEnv* env = AttachCurrentThread(); | 321 JNIEnv* env = AttachCurrentThread(); |
322 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env); | 322 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env); |
323 bool handled = false; | 323 bool handled = false; |
324 if (!obj.is_null()) { | 324 if (!obj.is_null()) { |
| 325 ScopedJavaLocalRef<jobject> jsource; |
| 326 if (source) |
| 327 jsource = source->GetJavaWebContents(); |
| 328 ScopedJavaLocalRef<jobject> jnew_contents; |
| 329 if (new_contents) |
| 330 jnew_contents = new_contents->GetJavaWebContents(); |
| 331 |
325 handled = Java_ChromeWebContentsDelegateAndroid_addNewContents( | 332 handled = Java_ChromeWebContentsDelegateAndroid_addNewContents( |
326 env, | 333 env, |
327 obj.obj(), | 334 obj.obj(), |
328 reinterpret_cast<intptr_t>(source), | 335 jsource.obj(), |
329 reinterpret_cast<intptr_t>(new_contents), | 336 jnew_contents.obj(), |
330 static_cast<jint>(disposition), | 337 static_cast<jint>(disposition), |
331 NULL, | 338 NULL, |
332 user_gesture); | 339 user_gesture); |
333 } | 340 } |
334 | 341 |
335 if (was_blocked) | 342 if (was_blocked) |
336 *was_blocked = !handled; | 343 *was_blocked = !handled; |
337 if (!handled) | 344 if (!handled) |
338 delete new_contents; | 345 delete new_contents; |
339 } | 346 } |
340 | 347 |
341 } // namespace android | 348 } // namespace android |
342 } // namespace chrome | 349 } // namespace chrome |
OLD | NEW |