Chromium Code Reviews| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 // ---------------------------------------------------------------------------- | 65 // ---------------------------------------------------------------------------- |
| 66 // Implementation of static ContentViewCore public interfaces | 66 // Implementation of static ContentViewCore public interfaces |
| 67 | 67 |
| 68 ContentViewCore* ContentViewCore::Create(JNIEnv* env, jobject obj, | 68 ContentViewCore* ContentViewCore::Create(JNIEnv* env, jobject obj, |
| 69 WebContents* web_contents) { | 69 WebContents* web_contents) { |
| 70 return new ContentViewCoreImpl(env, obj, web_contents); | 70 return new ContentViewCoreImpl(env, obj, web_contents); |
| 71 } | 71 } |
| 72 | 72 |
| 73 // static | |
| 74 ContentViewCore* ContentViewCore::FromWebContents(WebContents* web_contents) { | |
| 75 return web_contents->GetContentNativeView(); | |
| 76 } | |
| 77 | |
| 78 // static | |
| 73 ContentViewCore* ContentViewCore::GetNativeContentViewCore(JNIEnv* env, | 79 ContentViewCore* ContentViewCore::GetNativeContentViewCore(JNIEnv* env, |
| 74 jobject obj) { | 80 jobject obj) { |
| 75 return reinterpret_cast<ContentViewCore*>( | 81 return reinterpret_cast<ContentViewCore*>( |
| 76 env->GetIntField(obj, g_native_content_view)); | 82 env->GetIntField(obj, g_native_content_view)); |
| 77 } | 83 } |
| 78 | 84 |
| 79 // ---------------------------------------------------------------------------- | 85 // ---------------------------------------------------------------------------- |
| 80 | 86 |
| 81 ContentViewCoreImpl::ContentViewCoreImpl(JNIEnv* env, jobject obj, | 87 ContentViewCoreImpl::ContentViewCoreImpl(JNIEnv* env, jobject obj, |
| 82 WebContents* web_contents) | 88 WebContents* web_contents) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 } | 146 } |
| 141 | 147 |
| 142 RenderWidgetHostViewAndroid* | 148 RenderWidgetHostViewAndroid* |
| 143 ContentViewCoreImpl::GetRenderWidgetHostViewAndroid() { | 149 ContentViewCoreImpl::GetRenderWidgetHostViewAndroid() { |
| 144 RenderWidgetHostView* rwhv = NULL; | 150 RenderWidgetHostView* rwhv = NULL; |
| 145 if (web_contents_) | 151 if (web_contents_) |
| 146 rwhv = web_contents_->GetRenderWidgetHostView(); | 152 rwhv = web_contents_->GetRenderWidgetHostView(); |
| 147 return static_cast<RenderWidgetHostViewAndroid*>(rwhv); | 153 return static_cast<RenderWidgetHostViewAndroid*>(rwhv); |
| 148 } | 154 } |
| 149 | 155 |
| 156 bool ContentViewCoreImpl::ShouldUseNativeJsModalDialog( | |
| 157 JavaScriptMessageType type, | |
| 158 bool is_before_unload_dialog, | |
| 159 const string16& message, | |
| 160 const string16& default_text, | |
| 161 jobject js_result) { | |
| 162 if (!content_view_client_.get()) | |
| 163 return true; | |
| 164 return !content_view_client_->OnJsModalDialog(type, | |
|
joth
2012/08/15 06:11:25
this is another example of adding an awkward API o
| |
| 165 is_before_unload_dialog, | |
| 166 web_contents_->GetURL(), | |
| 167 message, | |
| 168 default_text, | |
| 169 js_result); | |
| 170 } | |
| 150 // ---------------------------------------------------------------------------- | 171 // ---------------------------------------------------------------------------- |
| 151 // Methods called from Java via JNI | 172 // Methods called from Java via JNI |
| 152 // ---------------------------------------------------------------------------- | 173 // ---------------------------------------------------------------------------- |
| 153 | 174 |
| 154 void ContentViewCoreImpl::SelectPopupMenuItems(JNIEnv* env, jobject obj, | 175 void ContentViewCoreImpl::SelectPopupMenuItems(JNIEnv* env, jobject obj, |
| 155 jintArray indices) { | 176 jintArray indices) { |
| 156 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( | 177 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( |
| 157 web_contents_->GetRenderViewHost()); | 178 web_contents_->GetRenderViewHost()); |
| 158 DCHECK(rvhi); | 179 DCHECK(rvhi); |
| 159 if (indices == NULL) { | 180 if (indices == NULL) { |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 557 void ContentViewCoreImpl::DidSetNeedTouchEvents(bool need_touch_events) { | 578 void ContentViewCoreImpl::DidSetNeedTouchEvents(bool need_touch_events) { |
| 558 JNIEnv* env = AttachCurrentThread(); | 579 JNIEnv* env = AttachCurrentThread(); |
| 559 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 580 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
| 560 if (j_obj.is_null()) | 581 if (j_obj.is_null()) |
| 561 return; | 582 return; |
| 562 Java_ContentViewCore_didSetNeedTouchEvents(env, | 583 Java_ContentViewCore_didSetNeedTouchEvents(env, |
| 563 j_obj.obj(), | 584 j_obj.obj(), |
| 564 need_touch_events); | 585 need_touch_events); |
| 565 } | 586 } |
| 566 | 587 |
| 588 ScopedJavaLocalRef<jobject> ContentViewCoreImpl::GetJavaObject() { | |
| 589 JNIEnv* env = AttachCurrentThread(); | |
| 590 return java_ref_.get(env); | |
| 591 } | |
| 592 | |
| 567 bool ContentViewCoreImpl::HasFocus() { | 593 bool ContentViewCoreImpl::HasFocus() { |
| 568 NOTIMPLEMENTED() << "not upstreamed yet"; | 594 NOTIMPLEMENTED() << "not upstreamed yet"; |
| 569 return false; | 595 return false; |
| 570 } | 596 } |
| 571 | 597 |
| 572 void ContentViewCoreImpl::OnSelectionChanged(const std::string& text) { | 598 void ContentViewCoreImpl::OnSelectionChanged(const std::string& text) { |
| 573 NOTIMPLEMENTED() << "not upstreamed yet"; | 599 NOTIMPLEMENTED() << "not upstreamed yet"; |
| 574 } | 600 } |
| 575 | 601 |
| 576 void ContentViewCoreImpl::OnSelectionBoundsChanged( | 602 void ContentViewCoreImpl::OnSelectionBoundsChanged( |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 623 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) { | 649 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) { |
| 624 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!"; | 650 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!"; |
| 625 return false; | 651 return false; |
| 626 } | 652 } |
| 627 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I"); | 653 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I"); |
| 628 | 654 |
| 629 return RegisterNativesImpl(env) >= 0; | 655 return RegisterNativesImpl(env) >= 0; |
| 630 } | 656 } |
| 631 | 657 |
| 632 } // namespace content | 658 } // namespace content |
| OLD | NEW |