| 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 "content/browser/android/content_view_core_impl.h" | 5 #include "content/browser/android/content_view_core_impl.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "content/public/browser/notification_source.h" | 27 #include "content/public/browser/notification_source.h" |
| 28 #include "content/public/browser/notification_types.h" | 28 #include "content/public/browser/notification_types.h" |
| 29 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
| 30 #include "content/public/common/content_client.h" | 30 #include "content/public/common/content_client.h" |
| 31 #include "content/public/common/page_transition_types.h" | 31 #include "content/public/common/page_transition_types.h" |
| 32 #include "jni/ContentViewCore_jni.h" | 32 #include "jni/ContentViewCore_jni.h" |
| 33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | 33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
| 34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
| 35 #include "third_party/WebKit/Source/WebKit/chromium/public/android/WebInputEvent
Factory.h" | 35 #include "third_party/WebKit/Source/WebKit/chromium/public/android/WebInputEvent
Factory.h" |
| 36 #include "ui/gfx/android/java_bitmap.h" | 36 #include "ui/gfx/android/java_bitmap.h" |
| 37 #include "ui/gfx/android/window_android.h" |
| 37 #include "webkit/glue/webmenuitem.h" | 38 #include "webkit/glue/webmenuitem.h" |
| 38 #include "webkit/user_agent/user_agent_util.h" | 39 #include "webkit/user_agent/user_agent_util.h" |
| 39 | 40 |
| 40 using base::android::AttachCurrentThread; | 41 using base::android::AttachCurrentThread; |
| 41 using base::android::ConvertJavaStringToUTF16; | 42 using base::android::ConvertJavaStringToUTF16; |
| 42 using base::android::ConvertJavaStringToUTF8; | 43 using base::android::ConvertJavaStringToUTF8; |
| 43 using base::android::ConvertUTF16ToJavaString; | 44 using base::android::ConvertUTF16ToJavaString; |
| 44 using base::android::ConvertUTF8ToJavaString; | 45 using base::android::ConvertUTF8ToJavaString; |
| 45 using base::android::GetClass; | 46 using base::android::GetClass; |
| 46 using base::android::HasField; | 47 using base::android::HasField; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 71 ContentViewCore* ContentViewCore::GetNativeContentViewCore(JNIEnv* env, | 72 ContentViewCore* ContentViewCore::GetNativeContentViewCore(JNIEnv* env, |
| 72 jobject obj) { | 73 jobject obj) { |
| 73 return reinterpret_cast<ContentViewCore*>( | 74 return reinterpret_cast<ContentViewCore*>( |
| 74 env->GetIntField(obj, g_native_content_view)); | 75 env->GetIntField(obj, g_native_content_view)); |
| 75 } | 76 } |
| 76 | 77 |
| 77 | 78 |
| 78 ContentViewCoreImpl::ContentViewCoreImpl(JNIEnv* env, jobject obj, | 79 ContentViewCoreImpl::ContentViewCoreImpl(JNIEnv* env, jobject obj, |
| 79 bool hardware_accelerated, | 80 bool hardware_accelerated, |
| 80 bool take_ownership_of_web_contents, | 81 bool take_ownership_of_web_contents, |
| 81 WebContents* web_contents) | 82 WebContents* web_contents, |
| 83 ui::WindowAndroid* window_android) |
| 82 : java_ref_(env, obj), | 84 : java_ref_(env, obj), |
| 83 web_contents_(static_cast<WebContentsImpl*>(web_contents)), | 85 web_contents_(static_cast<WebContentsImpl*>(web_contents)), |
| 84 owns_web_contents_(take_ownership_of_web_contents), | 86 owns_web_contents_(take_ownership_of_web_contents), |
| 85 tab_crashed_(false) { | 87 tab_crashed_(false), |
| 88 window_android_(window_android) { |
| 86 DCHECK(web_contents) << | 89 DCHECK(web_contents) << |
| 87 "A ContentViewCoreImpl should be created with a valid WebContents."; | 90 "A ContentViewCoreImpl should be created with a valid WebContents."; |
| 88 | 91 |
| 89 // TODO(leandrogracia): make use of the hardware_accelerated argument. | 92 // TODO(leandrogracia): make use of the hardware_accelerated argument. |
| 90 | 93 |
| 91 InitJNI(env, obj); | 94 InitJNI(env, obj); |
| 92 | 95 |
| 93 notification_registrar_.Add(this, | 96 notification_registrar_.Add(this, |
| 94 NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT, | 97 NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT, |
| 95 NotificationService::AllSources()); | 98 NotificationService::AllSources()); |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 // -------------------------------------------------------------------------- | 522 // -------------------------------------------------------------------------- |
| 520 // Methods called from native code | 523 // Methods called from native code |
| 521 // -------------------------------------------------------------------------- | 524 // -------------------------------------------------------------------------- |
| 522 | 525 |
| 523 void ContentViewCoreImpl::LoadUrl( | 526 void ContentViewCoreImpl::LoadUrl( |
| 524 NavigationController::LoadURLParams& params) { | 527 NavigationController::LoadURLParams& params) { |
| 525 web_contents()->GetController().LoadURLWithParams(params); | 528 web_contents()->GetController().LoadURLWithParams(params); |
| 526 tab_crashed_ = false; | 529 tab_crashed_ = false; |
| 527 } | 530 } |
| 528 | 531 |
| 532 ui::WindowAndroid* ContentViewCoreImpl::GetWindowAndroid() { |
| 533 return window_android_; |
| 534 } |
| 535 |
| 529 // ---------------------------------------------------------------------------- | 536 // ---------------------------------------------------------------------------- |
| 530 // Native JNI methods | 537 // Native JNI methods |
| 531 // ---------------------------------------------------------------------------- | 538 // ---------------------------------------------------------------------------- |
| 532 | 539 |
| 533 // This is called for each ContentViewCore. | 540 // This is called for each ContentViewCore. |
| 534 jint Init(JNIEnv* env, jobject obj, | 541 jint Init(JNIEnv* env, jobject obj, |
| 535 jboolean hardware_accelerated, | 542 jboolean hardware_accelerated, |
| 536 jboolean take_ownership_of_web_contents, | 543 jboolean take_ownership_of_web_contents, |
| 537 jint native_web_contents) { | 544 jint native_web_contents, |
| 545 jint native_window) { |
| 538 ContentViewCoreImpl* view = new ContentViewCoreImpl( | 546 ContentViewCoreImpl* view = new ContentViewCoreImpl( |
| 539 env, obj, hardware_accelerated, take_ownership_of_web_contents, | 547 env, obj, hardware_accelerated, take_ownership_of_web_contents, |
| 540 reinterpret_cast<WebContents*>(native_web_contents)); | 548 reinterpret_cast<WebContents*>(native_web_contents), |
| 549 reinterpret_cast<ui::WindowAndroid*>(native_window)); |
| 541 return reinterpret_cast<jint>(view); | 550 return reinterpret_cast<jint>(view); |
| 542 } | 551 } |
| 543 | 552 |
| 544 jint EvaluateJavaScript(JNIEnv* env, jobject obj, jstring script) { | 553 jint EvaluateJavaScript(JNIEnv* env, jobject obj, jstring script) { |
| 545 ContentViewCoreImpl* view = static_cast<ContentViewCoreImpl*> | 554 ContentViewCoreImpl* view = static_cast<ContentViewCoreImpl*> |
| 546 (ContentViewCore::GetNativeContentViewCore(env, obj)); | 555 (ContentViewCore::GetNativeContentViewCore(env, obj)); |
| 547 | 556 |
| 548 return view->EvaluateJavaScript(env, obj, script); | 557 return view->EvaluateJavaScript(env, obj, script); |
| 549 } | 558 } |
| 550 | 559 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) { | 715 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) { |
| 707 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!"; | 716 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!"; |
| 708 return false; | 717 return false; |
| 709 } | 718 } |
| 710 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I"); | 719 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I"); |
| 711 | 720 |
| 712 return RegisterNativesImpl(env) >= 0; | 721 return RegisterNativesImpl(env) >= 0; |
| 713 } | 722 } |
| 714 | 723 |
| 715 } // namespace content | 724 } // namespace content |
| OLD | NEW |